MediaWiki stores every edit forever. That design choice is the engine behind its page history and diff features, but it also means your database grows relentlessly as the wiki ages. On a managed shared plan you cannot tune server-wide MySQL variables or run administrative commands, yet nearly all of the common MediaWiki database problems are repairable from inside your account using phpMyAdmin, the maintenance/ PHP scripts, and a correctly configured LocalSettings.php. Understanding which tables grow, why queries slow down, and how MediaWiki expects its schema to look lets you keep a busy wiki responsive without touching anything outside your hosting user.
Where MediaWiki Database Bloat Actually Comes From
The first step is identifying which tables are consuming space. In DirectAdmin open phpMyAdmin, select your wiki database, and sort the table list by the Size column (click the heading on the Structure overview). On almost every mature wiki the same handful of tables dominate.
The text table holds the actual wikitext of every revision ever saved. Because MediaWiki never deletes old revisions by default, a page edited a thousand times keeps a thousand copies of its content here. The revision and revision_comment_temp tables store the metadata for each of those edits. The pagelinks, templatelinks, categorylinks, and externallinks tables grow in proportion to how heavily your pages use templates and categories, and they are rebuilt constantly by the link update jobs.
Three other tables cause disproportionate trouble on shared hosting. The objectcache table balloons when you use the database as a cache backend instead of an external store. The l10n_cache table holds localised interface messages and is normally harmless but can be rebuilt if corrupted. Worst of all is the job table: if cron is not running your maintenance jobs, queued link updates, HTML cache purges, and transcode tasks pile up into tens of thousands of rows that are queried on every page view.
Run this read-only query in the phpMyAdmin SQL tab to get an immediate picture of the largest offenders:
SELECT table_name,
ROUND(((data_length + index_length) / 1024 / 1024), 2) AS size_mb,
table_rows
FROM information_schema.tables
WHERE table_schema = DATABASE()
ORDER BY (data_length + index_length) DESC
LIMIT 15;
A wiki with a 400 MB text table but only a few hundred articles tells you history is the cost, not content. A job table with 40,000 rows tells you cron is broken. A huge objectcache table tells you your cache configuration is pointed at the database. Each of these has a distinct fix.
Running MediaWiki's Built-in Maintenance Scripts
MediaWiki ships a set of PHP scripts in the maintenance/ directory that are the correct, schema-aware way to clean the database. They understand foreign-key-style relationships that raw DELETE statements do not, so prefer them over hand-written SQL whenever one exists. On shared hosting without SSH you run these as scheduled tasks or via a one-off cron entry.
In the Hostiso Client Portal or DirectAdmin Cron Jobs section, create a command that calls your PHP binary against the script. Use the PHP version matching your MultiPHP selection, for example:
/usr/local/bin/php /home/username/domains/example.com/public_html/wiki/maintenance/runJobs.php --maxjobs 50
Scheduling runJobs.php every five minutes is the single most important maintenance task. It drains the job table steadily and prevents the backlog that makes page loads crawl. Keep $wgJobRunRate = 0; in LocalSettings.php so jobs run from cron rather than on visitor requests, which otherwise injects latency into every page view.
To reclaim space from old revisions, deleteOldRevisions.php removes revisions beyond a chosen age or count, and purgeOldText.php then deletes the orphaned rows left behind in the text table. Always run them in that order, and always export a phpMyAdmin backup first:
php maintenance/deleteOldRevisions.php --delete --keep 25
php maintenance/purgeOldText.php --purge
Other high-value scripts include rebuildall.php to regenerate the link and category tables when counts look wrong, cleanupSpam.php to strip link spam, and refreshLinks.php to fix stale pagelinks entries. If you edit a script path into a cron job and it fails silently, check the per-site error_log in the wiki directory through File Manager; a wrong PHP binary path or a memory ceiling is the usual culprit. Raise limits for CLI-style runs by adding memory_limit = 256M and max_execution_time = 300 to a .user.ini file in the wiki root, since these long-running scripts routinely exceed the defaults tuned for web requests.
Repairing Broken Tables and Fixing Connection Errors
Unclean shutdowns, hitting disk quota mid-write, or an interrupted import can leave tables marked as crashed. MediaWiki surfaces this as a generic "database error" page, and the per-site error_log will contain a line referencing a specific table being marked as crashed or needing repair. Most MediaWiki installs on InnoDB recover automatically, but older MyISAM tables such as searchindex do not.
In phpMyAdmin, select the database, tick the suspect table on the Structure page, and choose Check table from the dropdown at the bottom. If the result is anything other than OK, run Repair table from the same menu. This issues CHECK TABLE and REPAIR TABLE within your own database only, which is permitted on an unprivileged account, unlike server-wide repair utilities you cannot reach. You can also run REPAIR TABLE searchindex; directly in the SQL tab. If a repair fails on InnoDB, the table generally needs rebuilding with ALTER TABLE tablename ENGINE=InnoDB;, which forces a clean copy and often clears minor corruption.
Connection errors are a separate problem and rarely mean the database is broken. A "Cannot access the database" message almost always traces back to credentials in LocalSettings.php. Open that file in File Manager and confirm $wgDBserver, $wgDBname, $wgDBuser, and $wgDBpassword exactly match what you see in DirectAdmin under MySQL Management. On most Hostiso accounts $wgDBserver should be localhost. After a password reset in DirectAdmin, the old value in LocalSettings.php becomes stale and must be updated by hand. Intermittent "too many connections" errors on shared hosting usually mean runaway jobs or a search bot hammering uncached pages rather than a configuration fault, so draining the job queue and enabling caching normally resolves them.
Diagnosing Slow Queries and Missing Indexes
When a specific page or Special page is slow while the rest of the wiki is fine, the cause is usually a query running without a usable index, often because a schema update was skipped. The definitive fix after any MediaWiki core or extension upgrade is to run maintenance/update.php, which creates any new tables and indexes the current version expects. Skipping this step is the most common reason production wikis end up with inefficient queries.
php maintenance/update.php --quick
To confirm whether a slow query is index-starved, capture the query from your error log or from a Special page and prefix it with EXPLAIN in the phpMyAdmin SQL tab. If the key column shows NULL and rows shows a large scan count, MediaWiki is reading the whole table. Compare the table's current indexes on the Structure tab against the canonical definitions in the maintenance/tables.sql file shipped with your version. A missing index on recentchanges or logging is a classic symptom of an aborted upgrade, and re-running update.php restores it without manual ALTER statements.
Reducing query volume matters as much as index health on a shared tier. Keeping the parser cache in a dedicated store rather than the objectcache table, scheduling runJobs.php, and letting LiteSpeed serve cached pages all cut the number of database round trips dramatically. The approach mirrors what we cover for other PHP applications in our ownCloud database maintenance guide, where the same phpMyAdmin diagnostics apply. Back up before every structural change, run one maintenance script at a time, and verify the result in the size query from the first section so you can prove the cleanup actually reclaimed space.