优化前:
select b.type, ifnull(count(0),0) as qty from b_sell_quotationd a,b_sell_quotation b where b.quotationNo=a.quotationNo and a.status=‘N‘ and b.companycode=‘XXXXX‘ AND b.type=‘general‘;
优化后:
select COUNT(0) from b_sell_quotationd a LEFT JOIN (SELECT * FROM b_sell_quotation WHERE type=‘general‘) b ON b.quotationNo=a.quotationNo WHERE b.companycode=‘XXXXXX‘ and a.status=‘N‘
原文:http://4925054.blog.51cto.com/4915054/1883231