Yesterday I blogged about the MySQL Challenge to limit rows accessed. Sheeri had some great comments about the subject, but didn't know either why the first 4 rows were not counted in my original solution:
mysql> explain select actor_id from actor where actor_id % 5 = 0 and actor_id < 26;
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: actor
type: range
possible_keys: PRIMARY
key: PRIMARY
key_len: 2
ref: NULL
rows: 20
Extra: Using where; Using index
mysql>
I've been thinking about this some more, and wondered what would
happen if I tried this query:
mysql> select actor_id from actor where actor_id …[Read more]