DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: same query on 2 Dbs, different explain plan

  1. #1
    Join Date
    Oct 2002
    Posts
    182

    same query on 2 Dbs, different explain plan

    Would there be any reason why the same query on two different databases with the same data and indexes would have explain-plans that are so different??

    It is obvious why one runs in 100 msecs and the other takes 3secs, but I caqnnot figure out why one starts with BILLING_PERIOD and the other doesn't. Then you have the whole FULL table access on the second as well.

    The tables have been analyzed.
    I am confused.


    Code:
    Operation	Object Name	Rows	Bytes	Cost	TQ	In/Out	PStart	PStop
    
    SELECT STATEMENT Hint=CHOOSE		1  	 	238  	 	      	             	 
      SORT GROUP BY		1  	177  	238  	 	      	             	 
        TABLE ACCESS BY INDEX ROWID	METER_NORMALIZATION_CONTROL	61 K	954 K	217  	 	      	             	 
          NESTED LOOPS		1  	177  	223  	 	      	             	 
            NESTED LOOPS		1  	161  	6  	 	      	             	 
              MERGE JOIN CARTESIAN		1  	126  	5  	 	      	             	 
                NESTED LOOPS		1  	66  	3  	 	      	             	 
                  NESTED LOOPS		1  	46  	2  	 	      	             	 
                    TABLE ACCESS BY INDEX ROWID	ACCOUNT	1  	18  	1  	 	      	             	 
                      INDEX UNIQUE SCAN	ACC_PREM_ORG_PK	190  	 	 	 	      	             	 
                    TABLE ACCESS BY INDEX ROWID	CUSTOMER	1  	28  	1  	 	      	             	 
                      INDEX UNIQUE SCAN	CUST_CUST_PK	190  	 	 	 	      	             	 
                  INDEX RANGE SCAN	ACC_DEV_ACC_DEV_PK	1  	20  	1  	 	      	             	 
                BUFFER SORT		1  	60  	4  	 	      	             	 
                  TABLE ACCESS BY INDEX ROWID	BILLING_PERIOD	1  	60  	2  	 	      	             	 
                    INDEX RANGE SCAN	BIL_PRD_ACC_RTPLN_STDT_PK	1  	 	1  	 	      	             	 
              TABLE ACCESS BY INDEX ROWID	RATE_PLAN	2  	70  	1  	 	      	             	 
                INDEX UNIQUE SCAN	RP_ORG_RP_PK	13  	 	 	 	      	             	 
            INDEX RANGE SCAN	METER_NRM_NRM_PK	317  	 	3  	 	      	             	 
    
    
    
    
    Operation	Object Name	Rows	Bytes	Cost	TQ	In/Out	PStart	PStop
    
    SELECT STATEMENT Hint=CHOOSE		1  	 	191  	 	      	             	 
      SORT GROUP BY		1  	350  	191  	 	      	             	 
        TABLE ACCESS BY INDEX ROWID	BILLING_PERIOD	1  	60  	2  	 	      	             	 
          NESTED LOOPS		1  	350  	181  	 	      	             	 
            MERGE JOIN CARTESIAN		1  	290  	179  	 	      	             	 
              NESTED LOOPS		1  	205  	178  	 	      	             	 
                NESTED LOOPS		61 K	7 M	178  	 	      	             	 
                  NESTED LOOPS		1  	116  	2  	 	      	             	 
                    TABLE ACCESS BY INDEX ROWID	ACCOUNT	1  	73  	1  	 	      	             	 
                      INDEX RANGE SCAN	ACC_DR_RES_TYPE_IX	1  	 	2  	 	      	             	 
                    TABLE ACCESS BY INDEX ROWID	CUSTOMER	1  	43  	1  	 	      	             	 
                      INDEX UNIQUE SCAN	CUST_CUST_PK	409  	 	 	 	      	             	 
                  TABLE ACCESS FULL	METER_NORMALIZATION_CONTROL	61 K	953 K	176  	 	      	             	 
                INDEX UNIQUE SCAN	ACC_DEV_ACC_DEV_PK	1  	73  	 	 	      	             	 
              BUFFER SORT		1  	85  	179  	 	      	             	 
                TABLE ACCESS BY INDEX ROWID	RATE_PLAN	1  	85  	1  	 	      	             	 
                  INDEX RANGE SCAN	RP_ORG_RP_PK	1  	 	1  	 	      	             	 
            INDEX RANGE SCAN	TEMP_BP	1  	 	1
    query:

    PHP Code:
    SELECT  
             bp
    .org_id AS org_idbp.svc_type_cd AS svc_type_cd
             
    bp.cust_id AS cust_idbp.prem_seq_nbr AS prem_seq_nbr
             
    c.cust_tz_cd AS cust_tz_cda.rt_cmpr_cd AS account_rt_cmpr_cd
             
    bp.start_dt AS start_dtbp.end_dt AS end_dt
             
    bp.est_usage_nbr AS est_usagebp.est_cost_amt AS est_cost
             
    bp.bill_usage_nbr AS bill_usagebp.bill_cost_amt AS bill_cost
             
    rp.org_id AS rp_org_idrp.svc_type_cd AS rp_svc_type_cd
             
    rp.rate_plan_cd AS rp_rate_plan_cdrp.rt_cmpr_cd AS rp_rt_cmpr_cd
             
    rp.rate_plan_type_cd AS rp_rate_plan_type_cd
             
    MIN(mnc.erlst_rdng_dt) AS earliest_norm_dt 
        FROM BILLING_PERIOD bp

             
    CUSTOMER c
             
    ACCOUNT a
             
    RATE_PLAN rp
             
    ACCOUNT_DEVICE ad
             
    METER_NORMALIZATION_CONTROL mnc 
       WHERE bp
    .org_id 'ME' 
         
    AND bp.svc_type_cd 'E' 
         
    AND bp.cust_id '064014442500' 
         
    AND bp.prem_seq_nbr '1' 
         
    AND bp.bill_usage_nbr IS NULL 
         
    AND bp.bill_cost_amt IS NULL 
         
    AND bp.est_usage_nbr IS NULL 
         
    AND bp.est_cost_amt IS NULL 
         
    AND c.org_id bp.org_id 
         
    AND c.cust_id bp.cust_id 
         
    AND a.org_id bp.org_id 
         
    AND a.svc_type_cd bp.svc_type_cd 
         
    AND a.cust_id bp.cust_id 
         
    AND a.prem_seq_nbr bp.prem_seq_nbr 
         
    AND rp.org_id bp.org_id 
         
    AND rp.svc_type_cd bp.svc_type_cd 
         
    AND rp.rate_plan_cd bp.rate_plan_cd 
         
    AND ad.org_id bp.org_id 
         
    AND ad.svc_type_cd bp.svc_type_cd 
         
    AND ad.cust_id bp.cust_id 
         
    AND ad.prem_seq_nbr bp.prem_seq_nbr 
         
    AND mnc.org_id ad.org_id 
         
    AND mnc.device_id ad.device_id 
    GROUP BY bp
    .org_id
             
    bp.svc_type_cd
             
    bp.cust_id
             
    bp.prem_seq_nbr
             
    c.cust_tz_cd
             
    a.rt_cmpr_cd
             
    bp.start_dt
             
    bp.end_dt
             
    bp.est_usage_nbr
             
    bp.est_cost_amt
             
    bp.bill_usage_nbr
             
    bp.bill_cost_amt
             
    rp.org_id
             
    rp.svc_type_cd
             
    rp.rate_plan_cd
             
    rp.rt_cmpr_cd
             
    rp.rate_plan_type_cd
    - Cookies

  2. #2
    Join Date
    Oct 2002
    Posts
    182
    ah!

    got it working with this:
    CREATE INDEX temp_mnc
    ON METER_NORMALIZATION_CONTROL (org_id, device_id, erlst_rdng_dt)
    NOLOGGING TABLESPACE INDX;

    thanks for reading.
    - Cookies

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width