Исходный код вики Space Used
Редактировал(а) Dmitriy Rybakov 08.08.2025, 15:49
Скрыть последних авторов
| author | version | line-number | content |
|---|---|---|---|
| |
1.1 | 1 | The following page shows the space used in MegaBytes by usually biggest tables. |
| 2 | |||
| 3 | __xwikirecyclebin__ : Here is store the deleted documents. You can shrink the recycle bin [[here>>Admin.ShrinkRecycleBins]]. | ||
| 4 | __xwikircs__ : Versioning of documents. | ||
| 5 | |||
| 6 | {{warning}}The following tables will not be shown if you're using [[Filesystem Attachment feature>>http://platform.xwiki.org/xwiki/bin/view/AdminGuide/Attachments#HFilesystemAttachmentStore]].{{/warning}} | ||
| 7 | __xwikiattachment_content__ : Stores the content of attachments in database. | ||
| 8 | __xwikiattachment_archive__ : Versioning of attachments | ||
| 9 | __xwikiattrecyclebin__ : Recycle bin of attachments. | ||
| 10 | |||
| 11 | {{velocity}} | ||
| 12 | ## Check if Filesystem Storage is enabled at the moment. | ||
| 13 | #set($fsstore = false) | ||
| 14 | #if($xcontext.getContext().getWiki().getAttachmentStore().getClass().getName().contains("Filesystem")) | ||
| 15 | #set($fsstore = true) | ||
| 16 | #end | ||
| 17 | |||
| 18 | #if($hasProgramming) | ||
| 19 | #set($sqlTools = $xwiki.parseGroovyFromPage('Admin.SQLToolsGroovy')) | ||
| 20 | #set($system = $sqlTools.getXWikiDatabaseSystemFromDatabaseMetadata($xcontext)) | ||
| 21 | Your database is: **$system** | ||
| 22 | #if($system == 'HSQL Database Engine') | ||
| 23 | {{warning}}$system is not supported for this action{{/warning}} | ||
| 24 | #else | ||
| |
2.1 | 25 | ## >>> FIX: никогда не используем wikimanager (ломается на Hibernate 6) |
| 26 | #if($services.wiki) | ||
| |
1.1 | 27 | #set($dbs = $services.wiki.getAllIds()) |
| 28 | #else | ||
| 29 | #set($dbs = ["$xcontext.getDatabase()"]) | ||
| 30 | #end | ||
| |
2.1 | 31 | ## <<< |
| |
1.1 | 32 | |
| 33 | #if($fsstore) | ||
| 34 | #set($tables = ['xwikirecyclebin','xwikircs']) | ||
| 35 | #else | ||
| 36 | #set($tables = ['xwikirecyclebin','xwikircs','xwikiattachment_content','xwikiattachment_archive','xwikiattrecyclebin']) | ||
| 37 | #end | ||
| 38 | |||
| 39 | #set($prefix = $xwiki.getXWiki().Param('xwiki.db.prefix','')) | ||
| 40 | #set($connection = $sqlTools.getXWikiConnection($xwiki, $xcontext)) | ||
| |
2.1 | 41 | |
| |
1.1 | 42 | #foreach($schema in $dbs) |
| 43 | #set($alltables = '') | ||
| 44 | $xcontext.setDatabase($schema) | ||
| 45 | == Used space of wiki ${schema} in MB == | ||
| 46 | #if($schema == "xwiki") | ||
| 47 | #set($schema = $xwiki.getXWiki().Param('xwiki.db', $schema)) | ||
| 48 | #end | ||
| |
2.1 | 49 | |
| |
1.1 | 50 | #foreach($table in $tables) |
| 51 | #set($query = "select sum(round(data_length/1024/1024,2)) as '${table}' from information_schema.tables where table_name='${table}' and table_schema='${prefix}${schema}';") | ||
| 52 | #set($results = $sqlTools.getResults($connection, $query, false)) | ||
| 53 | #set($alltables = $alltables + $results) | ||
| 54 | #end | ||
| |
2.1 | 55 | |
| |
1.1 | 56 | $alltables |
| 57 | #end | ||
| 58 | #end | ||
| 59 | #else | ||
| 60 | {{error}}Sorry, you need the programming rights to use this tool{{/error}} | ||
| 61 | #end | ||
| 62 | |||
| 63 | == Recommendations == | ||
| 64 | |||
| 65 | #if($fsstore != true) | ||
| 66 | {{warning}}It appears that you're not using the filesystem attachment store feature. You should use it if you plan to have large documents in your wiki. This feature is available since XWiki 3.4. More information [[here>>http://platform.xwiki.org/xwiki/bin/view/AdminGuide/Attachments#HFilesystemAttachmentStore]]{{/warning}} | ||
| 67 | #end | ||
| |
2.1 | 68 | |
| |
1.1 | 69 | {{/velocity}} |