Forcing MySQL to use an index

Again, MySQL does stuff I don't expect. For example, the statement select * from T has very poor performance. While, the statement select * from T order by PK, where PK is the primary key, has very good performance. Since I don't care about record order both of these statements are effectively the same. MySQL's explain command says that the first statement does not use an index while the second does. Why on earth would an optimizer not use an index for the first statement? The upshot is that my DML is now scattered with extraneous order by clauses. Sigh.

No comments: