select * from table where deleted_at = ? and owner_id = ? order by status, id desc limit ?
select * from table no1 join(select id from table where deleted_at = ? and owner_id = ? order by status, id desc ) no2 on no1.id=no2.id limit ?;
使用上面这种写法的原因:原始的“select * from table where deleted_at = ? and owner_id = ? order by status, id desc limit ?” 会先读索引,再读数据,然后抛弃不需要的数据;而第二种写法只读索引,使用了主键索引,然后根据索引读取需要的列,效率更高
原文:https://www.cnblogs.com/javallh/p/12859627.html