select * from mytable order by first_col desc, sec_col asc limit 1;
when using only one order by filter, the query finished rather quickly(a few seconds), but the above query took hours. would a two开发者_运维百科 column index speed this up? is there any way to speed up the query?
No, for now there is no solution to optimize "ORDER BY ... ASC, ... DESC". Mysql cannot create indexes with sorting order different than ASC.
ps: yes, I know it is a sorting order parameter in create index
but it still doesn't work and was added to satisfy some ansi sql requirements.
精彩评论