sql - How to check on which column to create Index to optimize performance -




i have below query costing time , have optimize query performance. there no index on of table.

but query performance optimization thinking create index. not sure on particulary filtered column have create index. thinking group , count number of distinct records filtered column condition , decide on column should create index not sure this.

    select * order_mart fol fol.parent_prod_srcid  in  ( select e.parent_prod_srcid src_grp  join mar_grp b on a.h_lpgrp_id = b.h_lpgrp_id     join data_grp e on e.parent_prod_srcid = b.h_locpr_id a.child_locpr_id != 0  , dt_id between 20170101 , 20170731  , valid_order = 1   , a.prod_tp_code 'c%'     ) , fol.prod_srcid = 0 , is_caps = 1; 

below query execution plan: enter image description here

select *  order_mart fol       inner join (            select distinct e.parent_prod_srcid            src_grp             join mar_grp b on a.h_lpgrp_id = b.h_lpgrp_id                join data_grp e on e.parent_prod_srcid = b.h_locpr_id            a.child_locpr_id != 0 -- remove lines                               int_cdw_dv.s_local_prod_grp_main  child prod srcid equal 0            , dt_id between 20170101 , 20170731             , valid_order = 1 --and is_caps=1             , a.prod_tp_code 'c%'               ) sub on sub.parent_prod_srcid=fol.parent_prod_srcid  fol.prod_srcid = 0 , is_caps = 1; 

what if use join instead of in , add distinct reduce amount of rows in subquery.





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -

python - Read npy file directly from S3 StreamingBody -