Posts

Showing posts from March, 2012

The Myth of MySQL Query Cache on Write-Heavy Workloads

For years, forum tutorials told junior sysadmins to bump query_cache_size to 256M and call it a day. In production, that advice has caused more catastrophic database stalls than almost anything else. On write-heavy web applications, every single INSERT, UPDATE, or DELETE on a table invalidates every cached query associated with that table. The server spends more CPU cycles acquiring global mutex locks to purge and re-evaluate cached results than it would take to simply execute the clean query against properly indexed InnoDB buffer pools. Turn it off or keep it under 32MB. Profile your slow query log instead of throwing cache memory at un-indexed joins.