1,同事报告了一条非常复杂的sql,说很慢,叫我优化下。
很慢的sql,也很长有几百行吧,^_^,如下:
select bm2.bis_must_id, bm2.qz_year_month, bm2.money, bm2.adjust_money, bm2.bis_cont_id, bm2.must_type, bm2.rent_last_pay_date, bc.BIS_STORE_IDS, bc.BIS_STORE_NOS, bc.BIS_SHOP_ID, bc.BIS_SHOP_NAME, bc.BIS_PROJECT_ID, bp.short_name, bp.project_name, bm2.billing_period_begin, bm2.billing_period_end from (selectsum(m.money) money, sum(aj.adjust_money) adjust_money, m.must_type must_type, m.qz_year_month qz_year_month, m.bis_project_id bis_project_id, m.bis_cont_id bis_cont_id, max(m.rent_last_pay_date) rent_last_pay_date, max(m.billing_period_begin) billing_period_begin, min(m.billing_period_end) billing_period_end, max(m.bis_must_id) bis_must_id from bis_must2 m, (select j.* from bis_mf_adjust j where (j.is_del = '1'or j.is_del isnull) and j.adjust_type = |