问题描述
- mysql- sql查询 效率正常吗
- 以下是sql:
SELECT u.idu.orgcodeu.nameu.slaveuserCOUNT(*) FROM wx_xx_user u INNER JOIN wx_xx_wlzy w ON u.id=w.publisherid INNER JOIN wx_xx_wlzycomment wc ON w.id = wc.wlzyid INNER JOIN wx_xx_org org ON u.orgcode=org.orgcode WHERE w.state = 2 AND w.wlzytype = 5 AND wc.state =0 AND u.issuperadmin!=1 AND u.slaveuser IS NOT NULL AND u.slaveuser!='' AND org.autologin=1 GROUP BY u.id
explain结果:
数据量:wx_xx_wlzy 62W,wx_xx_wlzycomment 13W,wx_xx_user 38W
查询时间:2.9S, 还能再优化吗
解决方案
目前看来,效率还算正常。
解决方案二:
可以用explain等查看分析一下,能够利用索引的,可以简历索引
时间: 2024-10-04 13:15:34