One MySQL query consumed 75% of CPU by scanning 16,000 rows to return just 6
A news platform began serving pages in over six seconds after a single MySQL full-text search query started dominating database activity, accounting for 75% of all active queries on the server. The query powered a 'related articles' feature, passing each article's full title and first 200 characters of its summary as a natural-language search term, which matched roughly 20% of the 80,000-row table on every execution. Because the ORDER BY clause ranked results by a computed relevance-to-age ratio, the database could not use an index, forcing it to score around 16,000 rows, load them into a temporary table, sort all of them, and discard nearly all to return just six results. The server's load average reached 16.7 on a 12-core machine, MySQL consumed 92% of CPU, and over 4.8 GB of memory spilled into swap. The investigation was resolved by sampling the process list repeatedly to identify the dominant query shape, rather than relying on a single snapshot or generic tuning measures.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in