select * From tb order by istop desc, pid desc limit 20,20
这样要500+ msselect * From tb order by pid desc limit 20,20去掉 istop desc, 这样就是30ms 以下。istop 为tinyint(1) 值一般是0与1怎么办才可以加快速度。我把istop建索引基本没用。
这样要500+ msselect * From tb order by pid desc limit 20,20去掉 istop desc, 这样就是30ms 以下。istop 为tinyint(1) 值一般是0与1怎么办才可以加快速度。我把istop建索引基本没用。
OR
2、alter table tb order by pid desc;
现在如果要order by istop desc, pid desc不要WHERE就很快,或要WHERE不要order by istop desc, pid desc(要
order by pid desc ,两样都要还是慢。相差是上百倍呢
WHERE 里的我都建索引了的呀
i.e.select * From tb where a = ... order by istop desc, pid desc limit 20,20Then you can create an index defined with create index idx_u on tb(a,istop,pid);