+------------------+---------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------------+---------------------+------+-----+---------+----------------+
| id | bigint(20) unsigned | NO | PRI | NULL | auto_increment |
| object | varchar(1000) | NO | UNI | NULL | |
| should_use | int(10) unsigned | NO | MUL | 0 | |
| last_used | datetime | NO | MUL | NULL | |
+------------------+---------------------+------+-----+---------+----------------+
select count(*)
93029 results
select count(*) where should_use=1
7970 results
Indexes on id(primary), should_use, last_used.
Look at the following queries, shouldn't the rand() query take longer than the other?
select id from table where should_use=1 order by last_used limit 1
0.17 sec
select id from table where should_use=1 order by rand() limit 1
0.04 sec
If I *DROP* the index on last_used, I get this:
select id from table where should_use=1 order by last_used limit 1
0.04 sec
I don't get it. It's all backwards.