Home » RDBMS Server » Performance Tuning » help on Query tuning (oracle 10g)
help on Query tuning [message #486188] Tue, 14 December 2010 03:53 Go to next message
saaya123
Messages: 76
Registered: September 2010
Member
SELECT iu.instd_unit_id, iu.fk_cust_id, bill_cd,
         iu.mfg_prod_cd, iu.mfg_prod_seq_no, ccequip.fk_mkt_cd,
         eff_tmstmp, cust_ord_id, ord_dt, iu.xnac_co_cd,
         iu.xnac_div_cd, smmr_wvr_cd, warr_expn_dt,
         iu.auto_replen_ind, iu.ms_stat_cd,
         inst_dist_id, instn_dt, iu.last_auto_dt,
         iu.replen_freq_vlu, cpc_pln_cd, std_sply_ind,
         emcv_total_qty, tot_actl_cpy_qty, init_emcv_tot_qty, ms_tran_cd,
         ord_typ_cd, cap_doc_tran_cd, xeep_cust_no, cms_contr_no,
         mthly_emcv_pct, iu.last_upd_dt,
         iu.last_upd_src_id, fsma_bill_code, old_mfg_prod_cd,
         old_mfg_prod_seq_no, auto_rpln_stat_cd, rpln_stat_chng_dt,
         prod_retro_cd, dist_cd_serv, serv_rep_id, invc_pllg_id,
         poolg_typ_cd, iu.fk_cust_id, ' ', ccstat.ms_stat_cd_desc,
         get_cancel_dt (iu.ms_stat_cd, eff_tmstmp),
         ccgroup.soc_id, mtr_read_reqd_ind1, msq_eff_dt,
         mtr_read_reqd_ind2, mtr_read_reqd_ind3, mtr_read_reqd_ind4,
         mtr_read_reqd_ind5, mtr_read_reqd_ind6, mtr_read_reqd_ind7,
         mtr_read_reqd_ind8, iu.sbi,
         ccequip.metered_ind,
         get_meter_desc (
            iu.mfg_prod_cd,
            1,
            iu.instd_unit_id,
            iu.ms_stat_cd
         ),
         get_meter_desc (
            iu.mfg_prod_cd,
            2,
            iu.instd_unit_id,
            iu.ms_stat_cd
         ),
         get_meter_desc (
            iu.mfg_prod_cd,
            3,
            iu.instd_unit_id,
            iu.ms_stat_cd
         ),
         get_meter_desc (
            iu.mfg_prod_cd,
            4,
            iu.instd_unit_id,
            iu.ms_stat_cd
         ),
         get_meter_desc (
            iu.mfg_prod_cd,
            5,
            iu.instd_unit_id,
            iu.ms_stat_cd
         ),
         get_meter_desc (
            iu.mfg_prod_cd,
            6,
            iu.instd_unit_id,
            iu.ms_stat_cd
         ),
         get_meter_desc (
            iu.mfg_prod_cd,
            7,
            iu.instd_unit_id,
            iu.ms_stat_cd
         ),
         get_meter_desc (
            iu.mfg_prod_cd,
            8,
            iu.instd_unit_id,
            iu.ms_stat_cd
         ),
         ccstat.group_code,
         ccstat.fk_ms_stat_cd,
         iu.xbs_ops_br_no_info,
         iu.xbs_contr_id,
         iu.org_unit_cd,
         iu.xbs_ind,
         decode(et. mfg_prod_cd,'','N','Y'), 
         get_mtr_rd_multiplier(iu.mfg_prod_cd,1),
         get_mtr_rd_multiplier(iu.mfg_prod_cd,2),
         get_mtr_rd_multiplier(iu.mfg_prod_cd,3),
         get_mtr_rd_multiplier(iu.mfg_prod_cd,4),
         get_mtr_rd_multiplier(iu.mfg_prod_cd,5),
         get_mtr_rd_multiplier(iu.mfg_prod_cd,6),
         get_mtr_rd_multiplier(iu.mfg_prod_cd,7),
         get_mtr_rd_multiplier(iu.mfg_prod_cd,8),
         iu.asr_ind
         FROM installed_unit iu,
             complete_call_ms_stat_desc ccstat,
             complete_call_equipment ccequip,
             complete_call_grouping ccgroup,
             emax_table172 et
         WHERE ccequip.fk_complete_call_id = 785841
         AND iu.fk_cust_id = ccequip.fk_cust_id
         AND iu.instd_unit_id = ccequip.instd_unit_id
         AND iu.ms_stat_cd = ccstat.fk_ms_stat_cd
         AND ccequip.fk_complete_call_id = ccgroup.fk_complete_call_id
         AND ccequip.fk_cust_id = ccgroup.fk_cust_id
         AND ccequip.display =to_char('Y')
         AND iu.mfg_prod_cd = et.mfg_prod_cd (+)
         AND iu.mfg_prod_seq_no = et.mfg_prod_seq_no (+)
         ORDER BY sort_asc1,
                  sort_desc1 DESC,
                  sort_asc2,
                  sort_desc2 DESC,
                  sort_asc3,
                  sort_desc3 DESC,
                  sort_asc4,
                  sort_desc4 DESC,
                  sort_asc5,
                  sort_desc5 DESC,
                  ccstat.group_code,
                  ccstat.fk_ms_stat_cd,
                  ccgroup.soc_id,
                  cust_typ_ind,
                  ccgroup.fk_cust_id,
                  iu.mfg_prod_cd,
                  iu.mfg_prod_seq_no;



here is query and attached is the plan. need some points where I need to tune the query.

thanks in advance

/forum/fa/8536/0/
  • Attachment: p1.jpg
    (Size: 105.50KB, Downloaded 1286 times)
Re: help on Query tuning [message #486206 is a reply to message #486188] Tue, 14 December 2010 04:59 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
Can you re-run the explain plan in sqlplus like this:
SQL> 
SQL> 
SQL> 
SQL> 
SQL> 
SQL> 
SQL> 
SQL> 
SQL> 
SQL> 
SQL> 
SQL> 
SQL> 
SQL> 
SQL> 
SQL> 
SQL> explain plan for select sysdate from dual;

Explained.

SQL> select * from table(dbms_xplan.display);


That output is a lot easier to read.
Re: help on Query tuning [message #486213 is a reply to message #486206] Tue, 14 December 2010 05:24 Go to previous messageGo to next message
saaya123
Messages: 76
Registered: September 2010
Member
SQL> select * from table(dbms_xplan.display);

PLAN_TABLE_OUTPUT                                                               
--------------------------------------------------------------------------------
                                                                                
--------------------------------------------------------------------------------
--------------------                                                            
                                                                                
| Id  | Operation                        | Name                       | Rows  | 
Bytes | Cost (%CPU)|                                                            
                                                                                
--------------------------------------------------------------------------------
--------------------                                                            
                                                                                
|   0 | SELECT STATEMENT                 |                            |   102 | 

PLAN_TABLE_OUTPUT                                                               
--------------------------------------------------------------------------------
36312 |  3487   (1)|                                                            
                                                                                
|   1 |  SORT ORDER BY                   |                            |   102 | 
36312 |  3487   (1)|                                                            
                                                                                
|   2 |   NESTED LOOPS                   |                            |   102 | 
36312 |  3486   (1)|                                                            
                                                                                
|   3 |    NESTED LOOPS OUTER            |                            |   102 | 
31110 |  3294   (1)|                                                            
                                                                                

PLAN_TABLE_OUTPUT                                                               
--------------------------------------------------------------------------------
|*  4 |     HASH JOIN                    |                            |   102 | 
29988 |  3294   (1)|                                                            
                                                                                
|   5 |      TABLE ACCESS FULL           | COMPLETE_CALL_MS_STAT_DESC |    12 | 
  168 |     3   (0)|                                                            
                                                                                
|   6 |      NESTED LOOPS                |                            |   102 | 
28560 |  3291   (1)|                                                            
                                                                                
|*  7 |       TABLE ACCESS BY INDEX ROWID| COMPLETE_CALL_EQUIPMENT    |  1857 | 
  108K|  1418   (1)|                                                            

PLAN_TABLE_OUTPUT                                                               
--------------------------------------------------------------------------------
                                                                                
|*  8 |        INDEX RANGE SCAN          | XMSEQ_AC01                 |  3714 | 
      |    14   (0)|                                                            
                                                                                
|*  9 |       TABLE ACCESS BY INDEX ROWID| INSTALLED_UNIT             |     1 | 
  220 |     2   (0)|                                                            
                                                                                
|* 10 |        INDEX UNIQUE SCAN         | IXIU001                    |     1 | 
      |     1   (0)|                                                            
                                                                                
|* 11 |     INDEX UNIQUE SCAN            | XMSET01_UK                 |     1 | 

PLAN_TABLE_OUTPUT                                                               
--------------------------------------------------------------------------------
   11 |     0   (0)|                                                            
                                                                                
|  12 |    TABLE ACCESS BY INDEX ROWID   | COMPLETE_CALL_GROUPING     |     1 | 
   51 |     2   (0)|                                                            
                                                                                
|* 13 |     INDEX UNIQUE SCAN            | COMPLETE_CALL_GROUPING_IDX |     1 | 
      |     1   (0)|                                                            
                                                                                
--------------------------------------------------------------------------------
--------------------                                                            
                                                                                

PLAN_TABLE_OUTPUT                                                               
--------------------------------------------------------------------------------
                                                                                
Predicate Information (identified by operation id):                             
---------------------------------------------------                             
                                                                                
   4 - access("IU"."MS_STAT_CD"="CCSTAT"."FK_MS_STAT_CD")                       
   7 - filter("CCEQUIP"."DISPLAY"='Y')                                          
   8 - access("CCEQUIP"."FK_COMPLETE_CALL_ID"=785841)                           
   9 - filter("IU"."FK_CUST_ID"="CCEQUIP"."FK_CUST_ID")                         
  10 - access("IU"."INSTD_UNIT_ID"="CCEQUIP"."INSTD_UNIT_ID")                   
  11 - access("IU"."MFG_PROD_CD"="ET"."MFG_PROD_CD"(+) AND                      
              "IU"."MFG_PROD_SEQ_NO"="ET"."MFG_PROD_SEQ_NO"(+))                 

PLAN_TABLE_OUTPUT                                                               
--------------------------------------------------------------------------------
  13 - access("CCGROUP"."FK_COMPLETE_CALL_ID"=785841 AND                        
              "CCEQUIP"."FK_CUST_ID"="CCGROUP"."FK_CUST_ID")                    
                                                                                
Note                                                                            
-----                                                                           
   - 'PLAN_TABLE' is old version                                                

36 rows selected.

SQL> spool off


Re: help on Query tuning [message #486224 is a reply to message #486213] Tue, 14 December 2010 05:55 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
saaya123 wrote on Tue, 14 December 2010 11:24
   - 'PLAN_TABLE' is old version                                                


Fix that. Nothing the explain plan tells you can be trusted until you do. And next time set lines wide enough to avoid multilining the output.
Re: help on Query tuning [message #486233 is a reply to message #486224] Tue, 14 December 2010 06:25 Go to previous message
rleishman
Messages: 3728
Registered: October 2005
Location: Melbourne, Australia
Senior Member
Plan looks OK. Try removing the function calls in the SELECT clause. If it is fast, then they are the problem.

How many rows does it return?

Ross Leishman
Previous Topic: Index leading columns
Next Topic: dbms_lob.append
Goto Forum:
  


Current Time: Sat Apr 27 19:14:30 CDT 2024