Why MySQL Skips an Index: Three Common Causes and How to Tell Them Apart
A slow query can read every row in a table even when an index exists on the filtered column. The article examines three causes: wrapping a datetime column in DATE(), comparing a VARCHAR column with an unquoted number, and joining tables whose character sets differ. The first cause is visible in the query text, while the other two are hidden in column types and character sets. The author tested these cases on MySQL 8.4 and 8.0 using EXPLAIN, SHOW WARNINGS, and slow query log data. The three causes can be distinguished by the possible_keys column in EXPLAIN and by warning 1739 shown right after running EXPLAIN.
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