sql优化

来源:互联网 发布:mac怎么卸载qq 编辑:程序博客网 时间:2024/06/05 17:42
1、select * from cz_order czOrder,(select order_id from cz_order where agent_id=880030 limit 10000,20) tempOrder where tempOrder.order_id=czOrder.order_id
该分页性能比select * from cz_order where agent_id=880030 limit 10000,20性能要高
因为select order_id from cz_order where agent_id=880030 limit 10000,20 查询了数据10000+20条的表所有列并返回20条数据
而select * from cz_order czOrder,(select order_id from cz_order where agent_id=880030 limit 10000,20) tempOrder where tempOrder.order_id=czOrder.order_id
只查询了数据10000+20条的表order_id列,没有查询出所有列
2、group by ;部分函数等会使得不走索引
0 0
原创粉丝点击