Manual:Reduce size of the database

It is possible to reduce the size of the 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 clear out the archive table, where deleted revisions are stored, at the database level:

DELETE FROM archive;

or (which is sometimes MUCH faster)

TRUNCATE TABLE archive;

Of course, it will then no longer be possible to view and restore deleted pages and their history.

To remove the text records that are still unused, you can use the purgeOldText.php maintenance script:

$ php maintenance/purgeOldText.php --purge Searching for active text records in revisions table...done. Searching for active text records in archive table...done. Searching for inactive text records...done. 0 inactive items found.

Extensions

 * Extension:SpecialDeleteOldRevisions2 can drastically reduce the size of the database, more than 90% in some cases. It deletes old revisions of all articles, or in certain namespaces, or with titles matching a certain string. Optionally a cut date can be defined, so that older revision are deleted, and newer are kept. Page histories will be lost and only the current version (or recent versions since the cut date) of any article will be saved in the database.

Please consider your license, as you may not be allowed to do this, while keeping the current versions!