- 查询走全表扫描可能会导致查询慢 可以通过解释语句查看那个表是全表扫描
SELECT COUNT(1) FROM ( SELECT sh.id, sh.warehouse_code, sh.customer_warehouse_c服务器托管网ode, sh.company_code, sh.inbound_advice_number, sh.inbound_out_no, sh.batch_number, sh.store_code, sh.store_name, sh.transfer_order_no, sh.product_property_bin, sh.order_type, sh.remark, sh.remark2, sh.expected_arrival_date, sh.ata, sh.clearance_date, sh.inbound_time, sh.putaway_time, sh.create_time, sh.update_time, sh.is_send_wms, planDn.planNumber, actualDn.actualNumber, (CASE WHEN planDn.planNumber = actualDn.actualNumber THEN 1 ELSE 0 END) AS dnAgreement FROM asn_head sh LEFT JOIN asn_line sa ON sh.inbound_advice_number = sa.inbound_advice_number LEFT JOIN (SELECT sah.inbound_advice_number, sum(sa.quantity) AS planNumber FROM asn_head sah LEFT JOIN asn_line sa ON sah.inbound_advice_number = sa.inbound_advice_number GROUP BY sah.inbound_advice_number) planDn ON planDn.inbound_advice_number = sh.inbound_advice_number LEFT JOIN (SELECT sah.inbound_advice_number, sum(saic.quantity) AS actualNumber FROM asn_head sah LEFT JOIN asn_confirm_inbound saic ON sah.inboun服务器托管网d_advice_number = saic.inbound_advice_number GROUP BY sah.inbound_advice_number) actualDn ON actualDn.inbound_advice_number = sh.inbound_advice_number AND sh.company_code = sa.company_code WHERE 1 = 1 AND sh.company_code = 'Dior' GROUP BY sh.inbound_advice_number ORDER BY sh.create_time DESC ) TOTAL
- 对全表扫描的表进行创建索引 用连接查询的字段
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
机房租用,北京机房租用,IDC机房托管, http://www.fwqtg.net
一、治理背景 数据服务器托管网库系统性能问题会对应用程序的性能和用户体验产生负面影响。慢查询可能导致应用程序响应变慢、请求堆积、系统负载增加等问题,甚至引发系统崩溃或不可用的情况。慢SQL治理是在数据库系统中针对执行缓慢的SQL查询进行优化和改进的一项重要工作…