Исходный код вики Space Used

Версия 1.1 от Dmitriy Rybakov на 05.08.2025, 13:07

Скрыть последних авторов
Dmitriy Rybakov 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
13 ## Check if Filesystem Storage is enabled at the moment.
14 #set($fsstore = false)
15 #if($xcontext.getContext().getWiki().getAttachmentStore().getClass().getName().contains("Filesystem"))
16 #set($fsstore = true)
17 #end
18
19
20 #if($hasProgramming)
21 #set($sqlTools = $xwiki.parseGroovyFromPage('Admin.SQLToolsGroovy'))
22 #set($system = $sqlTools.getXWikiDatabaseSystemFromDatabaseMetadata($xcontext))
23 Your database is: **$system**
24 #if($system == 'HSQL Database Engine')
25 {{warning}}$system is not supported for this action{{/warning}}
26 #else
27 #if($services.wikimanager)
28 #set($dbs = $services.wikimanager.getAllWikis())
29 #elseif($services.wiki)
30 #set($dbs = $services.wiki.getAllIds())
31 #else
32 #set($dbs = ["$xcontext.getDatabase()"])
33 #end
34
35 #if($fsstore)
36 #set($tables = ['xwikirecyclebin','xwikircs'])
37 #else
38 #set($tables = ['xwikirecyclebin','xwikircs','xwikiattachment_content','xwikiattachment_archive','xwikiattrecyclebin'])
39 #end
40
41 #set($prefix = $xwiki.getXWiki().Param('xwiki.db.prefix',''))
42 #set($connection = $sqlTools.getXWikiConnection($xwiki, $xcontext))
43 #foreach($schema in $dbs)
44 #set($alltables = '')
45 $xcontext.setDatabase($schema)
46 == Used space of wiki ${schema} in MB ==
47 #if($schema == "xwiki")
48 #set($schema = $xwiki.getXWiki().Param('xwiki.db', $schema))
49 #end
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
55 $alltables
56 #end
57 #end
58 #else
59 {{error}}Sorry, you need the programming rights to use this tool{{/error}}
60 #end
61
62 == Recommendations ==
63
64 #if($fsstore != true)
65 {{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}}
66 #end
67 {{/velocity}}