添加索引后查询占用了太多时间

时间:2015-03-12 04:09:38

标签: mysql

添加索引后查询占用了太多时间。

    SELECT bc.billabletreatmentsetup_id, bs.name, IFNULL(bc.charges_for,'OPD') 
    as charges_for_vals, bc.nc_applicable, bc.unit_value, bc.taxtype_id, bc.id, bc.amount, bc.effective_date 
    FROM billabletreatmentcharges bc, billabletreatmentsetups bs 
    WHERE bs.id = bc.billabletreatmentsetup_id 
    AND bs.status='Active' 
    AND bs.branch_id = '9197651b-e2b9-1924-b931-54f13cfc31c0' 
    AND bs.deleted=0 
    AND ( bc.billabletreatmentsetup_id, bc.effective_date, bc.date_modified, IFNULL(bc.charges_for,'OPD') ) 
    IN ( 
        SELECT billabletreatmentsetup_id, max( effective_date ) , max( date_modified ), IFNULL(charges_for,'OPD') 
        FROM billabletreatmentcharges 
        WHERE effective_date <= '2015-03-12' 
        AND insprovider_id IS NULL GROUP BY billabletreatmentsetup_id, charges_for 
       )
    AND bc.insprovider_id IS NULL ORDER BY bs.name, bc.charges_for ASC

0 个答案:

没有答案