这条sql语句什么意思啊?特别耗cpu

2016-07-07 15:12 来源:www.chinab4c.com 作者:ecshop专家

运行 show full processlist 显示出来的:

SELECT g.goods_id, g.goods_name, g.shop_price, g.goods_thumb, SUM(og.goods_number) as goods_number FROM `51_com`.`ecs_goods` AS g, `51_com`.`ecs_order_info` AS o, `51_com`.`ecs_order_goods` AS og WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 AND (g.cat_idIN ('7','153','150','152','112','218','1','202','201','4','170','194','196','3','173','172','174','176','178','180','179','5','186','185','182','183','210','171','191','193','190','189','219','2','205','217','207','216','212','220','6','86','115','161','165','145','103','146','130','126','99','148','109','162','121','127')OR g.goods_id IN ('27','43','46','62','65','66','67','68','69','80','88','89','93','98','99','100','101','103','104','109','110','111','117','146','147','148','149','150','151','155','156','157','158','160','161','165','166','167','173','174','176','177','178','179','181','190','192','202','203','209','233','234','239','240','266','277','281','286','327','334','335','338','347','361','366','367','370','376','383','391','401','411','412','416','417','419','427','435','446','448','450','455','456','473','485','486','487','488','489','490','495','496','497','502','514','515','524','531','534','538','540','553','556','557','565','570','571','572','573','574','577','584','587','598','607','608','614','615','630','631','632','634','637','648','649','653','659','660','664','665','666','667','668','673','674','678','679','687','688','689','690','695','696','697','698','701','702','707','708','715','716','717','718','719','723','724','725','729','730','731','732','733','734','735','736','737','738','739','740','741','742','743','744','745','746','747','749','751','762','763','764','765','766','767','768','771','772','774','778','779','780','783','784','785','792','793','794','798','801','802','803','804','805','809','810','815','821','825','826','827','830','831','832','837','838','839','843','848','849','850','851','852','853','854','855','856','858','859','860','861','862','863','864','865','866','867','868','869','870','872','873','874','875','878','883','891','892','894','895','896','897','900','901','902','903','904','905','907','908','909','910','911','912','913','914','915','923','924','925','926','927','928','929','930','931','932','933','934','936','938','947','948','949','950','951','963','964','966','967','968','969','974','975','976','977','978','981','983','984','987','988','989','990','991','994','995','996','997','998','999','1001','1002','1003','1004','1005','1006','1007','1010','1013','1014','1018','1019','1020','1021','1022','1023','1024','1025','1026','1027','1028','1029','1030','1031','1032','1033','1034','1036','1039','1040','1047','1050','1051','1052','1053','1054','1055','1056','1057','1058','1059','1060','1061','1062','1063','1064','1065') ) AND g.goods_number > 0AND og.order_id = o.order_id AND og.goods_id = g.goods_id AND (o.order_status = '1' OR o.order_status = '5') AND (o.pay_status = '2' OR o.pay_status = '1') AND (o.shipping_status = '1' OR o.shipping_status = '2') GROUP BY g.goods_id ORDER BY goods_number DESC, g.goods_id DESC LIMIT 10



大侠帮我看看这条语句是干什么的啊

回答:
该怎么优化它呢

这里没人啦。。。。

应该是筛选引起的。。。减少筛选的选项,没办法,ecshop就是这样。。。我之前也出现过这类问题,去掉大部分筛选条件后,有改善。。

关键是这条语句在哪里我还没有找到

筛选多就报错?

lz,这是哪里的语句啊?

我执行了,速度挺快,因为没有数据

goods_id in应该不会引起性能问题

筛选到底怎么弄比较好