商城怎么优化 慢查询记录了很多条类似的慢查询

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

用了慢查询,没两天,log文件就达到100多M。。不知道怎么优化才好。大部分是以下的查询:
  1. # User@Host: ec_shop_99[ec_shop_99] @ AY12120a [52.151.96.158]
  2. # Query_time: 3.084763Lock_time: 0.469696 Rows_sent: 14Rows_examined: 1740
  3. SET times**p=1357708317;
  4. SELECT a.attr_id, MIN(a.goods_attr_id ) AS goods_id, a.attr_value AS attr_value FROM `ec_shop_99`.`ecs_goods_attr` AS a, `ec_shop_99`.`ecs_goods` AS g WHERE (g.cat_idIN ('283','1041','382','919','381','918','380','379','378','377','376','384','921','383','920')OR g.goods_id IN ('1','2','3','4','5','6','405','406','407','408','409','410','804','805','806','807','808','809','1201','1202','1203','1567','1672','1913','2464','2468','2471','2622','2623','2829','2832','2833','2834','2835','2847','2848','2849','2850','2887','3116','3135','3252','3344','3345','3346','3347','3348','3349','3350','3351','3352','3353','3354','3355','3356','3357','3358','3359','3360','3361','3362','3363','3364','3365','3366','3367','3368','3369','3370','3371','3372','3373','3374','3375','3376','3377','3378','3379','3380','3381','3382','3383','3384','3385','3386','3387','3388','3389','3390','3391','3392','3393','3394','3395','3396','3397','3398','3930','3998','4056','4057','4058','4224','4225','4226','4227','4228','4421','4729','4730','4731','4732','4733','4734','4735','4736','4737','4738','4801','4802','4808','4809','4811','4844','4872','4873','4874','4875','4876','4877','4878','4879','4883','4885','4886','4887','4888','4891','4892','4895','4896','4897','4898','4899','4900','4901','4902','4903','7179','7180','7181','7182','7183','7184','7185','7186','7187','7188','7189','7190','7191','7192','7193','7194','7195','7196','7197','7198','7199','7200','7201','7202','7203','7204','7205','7206','7207','7208','7209','7210','7211','7212','7213','7214','7215','7216','7217','7218','7219','7220','7221','7222','7223','7224','7225','7226','7227','7228','7229','7230','7231','7232','7233','7234','7235','7236','7237','7238','7239','7240','7241','7242','7243','7244','7245','7246','7247','7248','7249','7250','7251','7252','7253','7254','7255','7256','7257','7258','7259','7260','7261','7262','7263','7264','7265','7266','7267','7268','7269','7270','7271','7272','7273','7274','7275','7276','7277','7278','7291','7292','7295','7296','7297','7298','7299','7375','7376','7377','7378','7379','7380','7381','7382','7383','7384','7385','7386','7387','7388','7389','7390','7391','7392','7393','7394','7395','7396','7519','7520','7521','7522','7523','7524','7525','7526','7527','7528','7529','7530','7531','7532','7533','7534','7535','7536','7537','7538','7539','7540','7541','7542','7543','7544','7545','7546','7547','7548','7549','7550','7570','7581','7585','7589','7590','7591','7616','7617','7618','7644','7651','7652','7653','7654','7709','7981','8067','8104','8132','8135','8136','8623','8624','8626','8627','8628','8629','8630','8631','8632','8633','8634','8637','8644','8646','8647','8648','8649','8650','8654','8656','8657','8744','8837','9146','9147','9162','9164','9166','9190','9194','9195','9207','9208','9244','9248','9254','9261','9262','9339','9352','9354','9450','9463','9486','9534','9553','9559','9564','9590','9594','9628','9657','9785','9811','9812','9814','9818','9819','9821','9823','9824','9826','9828','9835','9836','9837','9842','9845','9846','9848','9849','9851','9854','9858','9874','9877','9951','10010','10480','10481','10513','10525','10597','10886','10910','10937','10952','11032','11040','11049','11159','11176','11196','11207','11280','11282','11329','11365','11368','11369','11374','11407','11545','11569','11598','11618','11621','11624','11654','11668','11671','11794','11821','11829','11830','11833','11861','11959','11961','11976','11982','11990','11995','12045','12069','12141','12143','12260','12695','12755','12772','12792','12857','12925','12930','12958','12974','12977','13026','13028','13068','13127','13138','13139','13271','13308','13315','13321','13325','13340','13353','13362','13375','13408','13410','13421','13424','13425','13515','13542','13602','13604','13605','13612','13614','13619','13637','13646','13654','13698','13866','13868','13890','13895','13908','13909','13911','13912','13913','13915','13916','13918','13919','13935','13936','13939','13941','13942','13946','13947','13951','13981','14018','14023','14046','14048','14049','14062','14106','14161','14228','14240','14278','14281','14283','14284','14287','14301','14302','14327','14376','14411','14413','14414','14416','14417','14419','14420','14421','14424','14427','14442','14444','14445','14446','14447','14476','14478','14479','14485','14494','14705','14766','14776','14795','14800','14801','14802','14803','14805','14808','14826','14835','14854','15009','15020','15083','15156','15179','15186','15197','15198','15200','15231','15233','15256','15279','15281','15294','15364','15373','15570','15641','15659','15828','15831','15864','15879','15888','15925','15930','15938','16046','16048','16064','16067','16068','16071','16072','16075','16159','16212','16305','16308','16336','16356','16422','16443','16449','16479','16535','16608','16870','16935','17076','17081','17101','17125','17198','17212','17241','17286','17289','17306','17311','17320','17361','17391','17427','17459','17464','17517','17528','17529','17543','17559','17571','17669','17672','17694','17697','17708','17757','17775','17778','17782','17786','17796','17798','17827','17833','17839','17845','17849','17850','17851','17852','17919','18061','18064','18067','18082','18090','18091','18094','18133','18188','18215','18242','18267','18352','18354','18355','18356','18358','18363','18365','18377','18383','18387','18404','18407','18408','18416','18420','18427','18431','18433','18435','18438','18450','18461','18514','18637','18643','18667','18689','18743','18779','18810','18851','18853','18867','18869','18887','18940','19023','19078','19080','19156','19164','19167','19183','19190','19205','19221','19241','19291','19316','19317','19348','19385','19440','19445','19447','19449','19455','19458','19461','19465','19624','19692','19701','19727','19747','19748','19835','19838','19942','19969','19972','20000','20010','20172','20182','20190','20195','20197','20210','20215','20216','20220','20222','20241','20245','20369','20373','20377','20400','20402','20403','20404','20418','20435','20465','20470','20473','20482','20484','20485','20509','20522','20523','20921','20932','20958','20960','20964','20967','20971','20978','20987','20988','20989','20991','20993','20995','21011','21012','21017','21019','21021','21028','21029','21030','21031','21040','21041','21044','21045','21055','21056','21069','21078','21088','21122','21213','21249','21255','21282','21311','21413','21420','21482','21485','21503','21537','21549','21550','21603','21612','21642') ) AND g.goods_id = a.goods_id AND g.is_delete = 0 AND g.is_on_sale = 1 AND g.is_alone_sale = 1AND a.attr_id='74'GROUP BY a.attr_value;
复制代码

回答:
不会啊啊。。。。。。。。。

看着就晕头了

这个要适当的修改存储结构。

怎么修改?

180以下小朋友路过。。。