mysql - ORDER BY uses all rows -
i want show 10 latest forum topics , ordering date asc. put index on date, however, still gets rows check (i use explain see that).
what problem or can't see without seeing table?
thank you.
depending on type of index, ordering date need full scan. think can't mysql.
nevertheless, 1 solution "cut" search using clause. eg
where date > 10 days ago
the ordering not done on full scan on left after clause.
weird may seem, , depending on table, may able optimize query ... 2 queries. eg :
select max(primary key) topics => $max select topic topics primary key >= $max - 10
these 2 request faster full scan if table has many lines , give same result if primary key auto-increment.
i hope you
jerome wagner
Comments
Post a Comment