February 10, 2012

When the subselect runs faster

A few weeks ago, we had a query optimization request from one of our customer. The query was very simple like: SELECT * FROM `table` WHERE (col1=’A'||col1=’B') ORDER BY id DESC LIMIT 20 OFFSET 0 This column in the table is looks like this: `col1` enum(‘A’,'B’,'C’,'CD’,'DE’,'F’,'G’,'HI’) default NULL The table have 549252 rows and of [...]