Manual:Reduce size of the database
It is possible to reduce the size of the MediaWiki database.
Without destroying dataEdit
Compress page textEdit
By default, MediaWiki saves text into the database uncompressed. The size of the 'text' table entries for new edits can be reduced by about half by enabling $wgCompressRevisions. This requires PHP to have zlib support enabled, which is usually the case.
Beware that text will be completely unreadable if you later move to a server without the PHP zlib module, or if you are trying to work with wiki page text directly in the database. This will affect extensions that attempt to do search-and-replace on existing article text. One example of those extensions is Extension:ReplaceText, which cannot work with compressed article texts, but there are many more.
See the next section for how to apply compression to existing revisions.
Compress old revisionsEdit
By default, MediaWiki saves a full copy of every version of every page on the wiki, which can add up on frequently-edited pages. You can run the compressOld.php maintenance script to compress, or re-compress, existing text entries in your database.
cd /path/to/wiki/maintenance/storage php compressOld.php
Even if you've been using $wgCompressRevisions for basic compression from the beginning, compressOld can apply the 'concat' or 'diff' compression modes to combine adjacent revisions much more efficiently.
Be aware that these advanced compression modes will also likely be incompatible with some unofficial extensions that attempt to read or write text directly to the database.
Compress database rowsEdit
Using InnoDB row compression (
ROW_FORMAT=COMPRESSED;) on the database server, the size of all tables can be reduced transparently, without destroying data and without affecting extensions that rely on a clear text database.
By destroying unwanted dataEdit
Permanently remove the history of deleted pagesEdit
To permanently remove the history of all deleted pages, first delete the pages using the normal page deletion feature.
Then run the deleteArchivedRevisions.php maintenance script
php maintenance/deleteArchivedRevisions.php --delete Delete archived revisions Deleting archived revisions... done. 45560 revisions deleted. Searching for active text records in revisions table...done. Searching for active text records in archive table...done. Searching for inactive text records...done. 45560 inactive items found. Deleting...done.
This will clear out the archive table, where deleted revisions are stored, and will also remove the text of the deleted pages. If you were to delete entries from the archive table directly (
TRUNCATE TABLE archive;), then you would need to use the purgeOldText.php maintenance script to purge linked text records. Only removing old revisions usually does not help much because most of the data in an active wiki is taken up by the text table.
Depending on your database settings, you may want to run the MySql command
OPTIMIZE TABLE text, archive after deleting revisions
Truncate the objectcache tableEdit
The objectcache table can be truncated (delete all rows of the table) safely.