订单数量达到1W单后,在后台进行已发货未发货查询,耗时很长。
查询SQL慢语句
# Time: 210223 18:42:34# User@Host: xxx[xxx] @ localhost [127.0.0.1] Id: 735782# Query_time: 17.881947 Lock_time: 0.000017 Rows_sent: 1 Rows_examined: 55519765SET timestamp=1614076954;SELECT COUNT(*) AS tp_count FROM `fa_shopro_order` WHERE ( `status` IN (1,2) AND EXISTS ( SELECT * FROM `fa_shopro_order_item` WHERE ( order_id=fa_shopro_order.id ) AND `dispatch_status` = 0 AND `refund_status` NOT IN (2,3) ) ) AND `fa_shopro_order`.`deletetime` IS NULL ORDER BY `fa_shopro_order`.`id` DESC LIMIT 1;
进表增加相关条件索引
order表增加status、deletetime
order_item表增加order_id、dispatch_status、refund_status
速度恢复正常。
建议官方安装的时候也把索引加进去。
希望以上内容对你有所帮助!如果还有其他问题,请随时提问。 各类知识收集 拥有多年CMS企业建站经验,对 iCMS, Fastadmin, ClassCMS, LeCMS, PbootCMS, PHPCMS, 易优CMS, YzmCMS, 讯睿CMS, 极致CMS, Wordpress, HkCMS, YznCMS, WellCMS, ThinkCMF, 等各类cms的相互转化,程序开发,网站制作,bug修复,程序杀毒,插件定制都可以提供最佳解决方案。