Manual:Reduce size of the database

It is possible to reduce the size of the MediaWiki database.

Compress page text
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 may affect some unofficial extensions that attempt to do search-and-replace on existing article text.

See the next section for how to apply compression to existing revisions.

Compress old revisions
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.

Permanently remove the history of deleted pages
To permanently remove the history of 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.

Delete the objectcache table
The objectcache table can be deleted safely.