Magento数据库查询占用资源

时间:2015-10-06 14:42:22

标签: mysql sql-server magento

我在使用siteground托管的1.8.1.0版本上有一个magento商店。我的系统管理员已经通知我,我的数据库查询占用了太多的资源。这是他们寄给我的东西。我完全不知道如何处理这个问题,任何指针都会非常感激。

1执行9h 26m 48s ago for 16.454657 sec on Database - > DB_production 发布日期:2015-10-05 22:41:18查询时间:16.454657 Rows_examined:349107:Rows_sent 1 Lock_time:0.000301

SELECT count(DISTINCT e.entity_id) 
FROM report_event AS report_table_views 
  INNER JOIN catalog_product_entity AS e ON e.entity_id = report_table_views.object_id AND e.entity_type_id = 4 
  INNER JOIN catalog_product_entity_int AS at_visibility_default ON (at_visibility_default.entity_id = e.entity_id) AND (at_visibility_default.attribute_id = '102') AND at_visibility_default.store_id = 0 
  LEFT JOIN catalog_product_entity_int AS at_visibility ON (at_visibility.entity_id = e.entity_id) AND (at_visibility.attribute_id = '102') AND (at_visibility.store_id = 4) 
  INNER JOIN catalog_product_entity_int AS at_status_default ON (at_status_default.entity_id = e.entity_id) AND (at_status_default.attribute_id = '96') AND at_status_default.store_id = 0 
  LEFT JOIN catalog_product_entity_int AS at_status ON (at_status.entity_id = e.entity_id) AND (at_status.attribute_id = '96') AND (at_status.store_id = 4) 
WHERE (report_table_views.event_type_id = 1) AND (IF(at_visibility.value_id > 0, at_visibility.value, at_visibility_default.value) = '4') AND (IF(at_status.value_id > 0, at_status.value, at_status_default.value) = 1);

2执行9h 26m 48s ago for 16.381442 sec on Database - > DB_production 发布日期:2015-10-05 22:41:18查询时间:16.381442 Rows_examined:349107:Rows_sent 1 Lock_time:0.000517

SELECT count(DISTINCT e.entity_id) 
FROM report_event AS report_table_views 
  INNER JOIN catalog_product_entity AS e ON e.entity_id = report_table_views.object_id AND e.entity_type_id = 4 
  INNER JOIN catalog_product_entity_int AS at_visibility_default ON (at_visibility_default.entity_id = e.entity_id) AND (at_visibility_default.attribute_id = '102') AND at_visibility_default.store_id = 0 
  LEFT JOIN catalog_product_entity_int AS at_visibility ON (at_visibility.entity_id = e.entity_id) AND (at_visibility.attribute_id = '102') AND (at_visibility.store_id = 4) 
  INNER JOIN catalog_product_entity_int AS at_status_default ON (at_status_default.entity_id = e.entity_id) AND (at_status_default.attribute_id = '96') AND at_status_default.store_id = 0 
  LEFT JOIN catalog_product_entity_int AS at_status ON (at_status.entity_id = e.entity_id) AND (at_status.attribute_id = '96') AND (at_status.store_id = 4) 
WHERE (report_table_views.event_type_id = 1) AND (IF(at_visibility.value_id > 0, at_visibility.value, at_visibility_default.value) = '4') AND (IF(at_status.value_id > 0, at_status.value, at_status_default.value) = 1);

=== 1854年的前十名(总计)过去24小时的慢速查询========== [36; 1m 1.执行13h 30m 41s前,数据库为9.566494秒 - > [33; 1mDB_production [0m [0m [36m日期:2015-10-06 21:35:51 Query_time:9.566494 Rows_examined:234795:Rows_sent 68398 Lock_time:0.011157 [0m

SELECT t_dentity_idt_dattribute_idt_dvalue AS default_value,{{1} }。t_s AS value,IF(t_s.value_id IS NULL,t_d.value,t_s.value)AS store_value FROM value AS catalog_product_entity_varchar LEFT JOIN t_d AS catalog_product_entity_varchar ON t_s.attribute_id = t_d.attribute_id AND t_s.entity_id = t_d.entity_id AND t_s.store_id = 4 WHERE(t_d.entity_type_id = 4)AND(t_d.entity_id IN(1678, 1682,1828,1830,1834,1837,1839,1926,1942,1982,1983,1985,1987,1989,2316,2325,3299,1510,2055,2172,2282,2283,2328,2333,1075,1771, 1780,1818,1849,1850,1853,2569,2570,2572,2573,2574,2575,2576,2577,2578,2579,2728))AND(t_d.attribute_id IN('75','76','120 '))AND(t_d.store_id = 0)UNION ALL SELECT t_st_dentity_idt_dattribute_idt_d AS valuedefault_valuet_s AS value,IF(t_s.value_id IS NULL,t_d.value,t_s.value)AS store_value FROM {{1 AS value LEFT JOIN catalog_product_entity_datetime AS t_d ON t_s.attribute_id = t_d.attribute_id AND t_s.entity_id = t_d.entity_id AND t_s.store_id = 4 WHERE(t_d.entity_type_id = 4 )AND(t_d.entity_id IN(1678,1682,1 828,1830,1834,1837,1839,1926,1942,1982,1983,1985,1987,1989,2316,2325,3299,1510,2055,2172,2282,2283,2328,2333,1075,1771,1780, 1818年,1849年,1850年,1853年,

======我截断了这篇文章的很多实体ID =======

3456,3453,3458,3459,3460,3461,3462,3463,3464,3465,3466,3467,3468,2545,2546,2547,2548,2549,2550,2551,2552,2553,2554,2555 ,2558,2559,2560,2561,2562,2563,2564,2565,2566,2567,2568,2569,2570,2572,2573,2574,2575,2576,2577,2578,2579,2728))和(t_d。 attribute_id IN('96','122','124','126','127','128','129','132','134'))AND(t_d.store_id = 0);

2 个答案:

答案 0 :(得分:0)

我和magento和Siteground一样。他们阻止我的网站,因为查询速度很慢,但资源使用情况正常 - CPU时间和帐户执行没有超出限制; /他们建议我将计划升级到Cloud或Dedicated服务器。但此时我的网站还没有完全完成,没有访问者,也不知道为什么他们阻止我的网站只是因为查询速度慢; /我现在正在使用GrowBig共享主机,并且这是查询:

"我仔细检查了你,我可以看到仍有一些慢查询。你可以从这里查看结果: 码: 我仔细检查了你,我可以看到仍有一些缓慢的查询。你可以从这里查看结果: 码: 7.在数据库上执行8h 38m 41s前的3.789867秒 - > devakorp_mage878 日期:2015-10-12 19:41:24 Query_time:3.789867 Rows_examined:101030:Rows_sent 173 Lock_time:0.000547

SELECT e。*,IF(at_is_active.value_id> 0,at_is_active.value,at_is_active_default.value)AS is_active,IF(at_include_in_menu.value_id> 0,at_include_in_menu.value,at_include_in_menu_default .value)AS include_in_menumg_core_url_rewriterequest_path FROM mg_catalog_category_entity AS e INNER JOIN mg_catalog_category_entity_int AS at_is_active_default ON({{ 1}}。at_is_active_default = entity_ide)AND(entity_idat_is_active_default =' 42')和{{1} }。attribute_id = 0 LEFT JOIN at_is_active_default AS store_id ON(mg_catalog_category_entity_intat_is_active = at_is_activeentity_id)AND( eentity_id =' 42')和(at_is_activeattribute_id = 1)内部加入at_is_active AS store_id开(mg_catalog_category_entity_intat_include_in_menu_default = at_include_in_menu_defaultentity_id)和(eentity_id =' 67')和at_include_in_menu_defaultattribute_id = 0 LEFT JOIN at_include_in_menu_default AS store_id ON(mg_catalog_category_entity_intat_include_in_menu = at_include_in_menu。{{1} })AND(entity_ide =' 67')AND(entity_idat_include_in_menu = 1)LEFT JOIN attribute_id ON( mg_core_url_rewrite.category_id = e.entity_id)AND(mg_core_url_rewrite.is_system = 1 AND mg_core_url_rewrite.product_id IS NULL AND mg_core_url_rewrite.store_id =' 1' AND id_path LIKE' category /%')WHERE (at_include_in_menustore_id =' 3')和(mg_core_url_rewritee IN(' 3',' 180&# 39;,' 181',' 182',' 183',' 184',' 185',&# 39; 186',' 187',' 219',' 220',' 221',' 222&#39 ;,' 223',' 224',' 201',' 202',' 203',&#39 ; 204',' 205'' 206',' 207',' 208',' 209' ,' 210',' 211',' 212',' 213',' 216',' 217',' 218',' 27',' 151',' 152',' 28', ' 159',' 160',' 161',' 162',' 163',' 164& #39;,' 165',' 166',' 167',' 168',' 169',& #39; 170',' 171',' 29',' 172',' 173',' 174&# 39;,' 175',' 176',' 177',' 178',' 179',&# 39; 30',' 31',' 16',' 68',' 69',' 70&#39 ;,' 71',' 72',' 73',' 74',' 75',&#39 ; 76',' 77',' 78',' 79',' 80',' 81',' 82', ' 83',' 84',' 85',' 86',' 14',' 45& #39;,' 46',' 47',' 48',' 49',' 50',& #39; 51',' 52',' 53',' 54',' 55',' 56&# 39;,' 57',' 58',' 59',' 60',' 61',&# 39; 108',' 109',' 110',' 111',' 139',' 140&#39 ;,' 141',' 142',' 143',' 144',' 188',&#39 ; 189',' 190',' 191',' 192',' 193',' 38' ,' 199',' 62',' 63',' 64',' 65',' 66',' 67',' 17',' 114',' 115',' 116', ' 117',' 118',' 119',' 120',' 121',' 122& #39;,' 123',' 124',' 125',' 126',' 127',& #39; 128',' 129',' 1 30',' 131',' 132',' 133',' 134',' 135', ' 145',' 146',' 147',' 148',' 149',' 150& #39;,' 6',' 87',' 88',' 89',' 90',& #39; 91',' 92',' 93',' 94',' 198',' 18&# 39;,' 197',' 214',' 215',' 200',' 230',&# 39; 231',' 234',' 235',' 236',' 237',' 232&#39 ;,' 233'))AND(IF(at_is_active.value_id> 0,at_is_active.value,at_is_active_default.value)=' 1')AND(IF(at_include_in_menu.value_id> 0,at_include_in_menu.value,at_include_in_menu_default.value)=' 1');

  1. 在数据库上执行3小时18分25秒前执行3.449602秒 - > devakorp_mage878 发布日期:2015-10-13 01:01:40 Query_time:3.449602 Rows_examined:93735:Rows_sent 0 Lock_time:0.000094

    INSERT INTO entity_type_ideentity_idmg_catalog_product_index_eaventity_id)SELECT attribute_idstore_id,{{ 1}}。valuemg_catalog_product_index_eav_idxentity_idmg_catalog_product_index_eav_idxattribute_id FROM mg_catalog_product_index_eav_idx ON DUPLICATE KEY UPDATE store_id = VALUES (mg_catalog_product_index_eav_idx),value = VALUES(mg_catalog_product_index_eav_idx),entity_id = VALUES(entity_id),attribute_id = VALUES({{1} });

  2. 在数据库上执行8小时41分52秒前执行3.428078秒 - > devakorp_mage878 日期:2015-10-12 19:38:13 Query_time:3.428078 Rows_examined:0:Rows_sent 0 Lock_time:0.000000

    提交;

  3. 在数据库上执行1小时50分14秒前的3.172525秒 - > devakorp_mage878 日期:2015-10-13 02:29:51 Query_time:3.172525 Rows_examined:0:Rows_sent 0 Lock_time:0.003677 从attribute_id;

  4. 删除

答案 1 :(得分:0)

我已将主机更改为另一个。在siteground我支付14e pro月,现在我支付20e,我有VPS和两个magento商店有10 000 SKU,资源很少,网站更快。我对siteground感到失望,并对新托管www.netdc.pl(波兰托管)感到惊讶。