MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Can this query be optimized

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
jajularamesh
Beginner


Joined: 14 Apr 2006
Posts: 87
Topics: 33

PostPosted: Mon Jun 04, 2007 9:28 am    Post subject: Can this query be optimized Reply with quote

Code:

FROM   MUS.T7627_TRAN            T27                 
        , MUS.T7617_CLIENT       T17                                                       
        , MUS.T7621_ACCOUNT      T21                 
        , MUS.T7626_PRODUCT      T26                 
        , MUS.T7628_SLS_PER      T28                 
        , MUS.T7628_SLS_PER      T28B               
        , MUS.T7638_FLD_BUS_UNIT T38                 
        , MUS.T7663_REG_REPT_HDR T63                 
  WHERE  T27.CRTE_DATE > :HV-TRAN-RUN-DATE           
  AND    T17.CDS_CL_ID   = T27.CURR_OWN_CDS_CL_ID               
  AND    T21.CDS_ACCT_ID = T27.CDS_ACCT_ID           
  AND    T26.CDS_PROD_ID = T27.CDS_PROD_ID           
  AND    T28.CDS_SP_ID   = T27.CURR_SRV_CDS_SP_ID   
  AND    T38.CDS_FBU_ID  = T28.CURR_CDS_AO_FBU_ID 
  AND    T21.CDS_ACCT_ID = T27.CDS_ACCT_ID           
 AND    T26.CDS_PROD_ID = T27.CDS_PROD_ID           
 AND    T28.CDS_SP_ID   = T27.CURR_SRV_CDS_SP_ID   
 AND    T38.CDS_FBU_ID  = T28.CURR_CDS_AO_FBU_ID   
 AND    T28B.CDS_SP_ID  = T27.SERV_MPR_CDS_SP_ID   
 AND    T63.RP_ID       = T27.SERV_MPR_CDS_SP_ID   
  ORDER BY T27.CDS_TRAN_ID       

Actually here same table given

MUS.T7628_SLS_PER has repeated twice with references T28,T28B i am not sure why this is given like this

Can we use a single reference T28
Code:

T28.CDS_SP_ID   = T27.CURR_SRV_CDS_SP_ID 
T28B.CDS_SP_ID  = T27.SERV_MPR_CDS_SP_ID 

can't we change this as
Code:

T28.CDS_SP_ID   = T27.CURR_SRV_CDS_SP_ID and 
T28.CDS_SP_ID  = T27.SERV_MPR_CDS_SP_ID 

or can't we change like this
Code:

T28.CDS_SP_ID   = (T27.CURR_SRV_CDS_SP_ID or   T27.SERV_MPR_CDS_SP_ID) 

Actually we are getting some duplicate records which actullay not required

As far as query optimization is concerned what can be done.

Regards,
Ramesh(Venkata Apparao Jajula)
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Mon Jun 04, 2007 9:35 am    Post subject: Reply with quote

jajularamesh,

You got to understand that without the indexes involved in the query there is nothing WE can help you to optimize the query.

Did you try running an EXPLAIN?

Quote:

Actually we are getting some duplicate records which actullay not required


I think that is the precise reason as to why I think they referred the same table twice.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group