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 

Fine tuning a query with Join on 4 tables

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


Joined: 18 May 2005
Posts: 108
Topics: 31
Location: USA

PostPosted: Tue May 31, 2005 8:07 am    Post subject: Fine tuning a query with Join on 4 tables Reply with quote

Hi, I need to tune the below query. Right now this query was giving timeout when I run production volume. I was running on the 32millions of data.
Code:

SELECT CASE RACE
       WHEN 'M' THEN 'Missing'
                      WHEN 'W' THEN 'White/Caucasian'
       WHEN 'B'  THEN 'Black/Aferican American'
                      WHEN 'O'  THEN 'Other'
 END CASE,
 g.outgrpid, outcmplo, outgrplbl, outgrpval, count(*)
FROM   IDPOUT01.ITOUOUTC c,   
  IDPOUT01.ITOUGROP g,
  IDPOUT01.ITOUADMN a,
  IDPOUT01.ITOUFACT f
WHERE  c.INSTTYPE   = '10'     
AND c.OUTTYPE ='EMPOWER'                     
AND   g.OUTGRPID   = c.OUTGRPID
AND   c.OUTID    = f.OUTID
AND  f.ADMINID  = a.ADMINID
AND  f.OUTVAL BETWEEN g.OUTCMPLO AND g.OUTCMPHI
GROUP BY Race, g.outgrpid, outcmplo, outgrplbl, outgrpval

OUTID
ADMINID
OUTGRPID are defined as indexes. Is there any otherway to write/tune this query. Please help me out.
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: Tue May 31, 2005 8:44 am    Post subject: Reply with quote

schintala,

Please post with meaningful topic titles. You already had a topic with "Query Optimization " and if you open another topic with the same title , it adds confusion. A better title would be "Fine tuning a query with Join on 4 tables." I am editing the topic title.

Also please try enclose your code in BBCODEs to enable the proper format of the code and also better readability.

put your code enclosed in between the bbcode and check it.

ex:
{code}
This is my query
{/code}

Now replace the { brackets with [ for {CODE} & {/CODE} and your code looks like this

Code:

This is my query



Try this query.


Code:

SELECT CASE RACE
       WHEN 'M' THEN 'Missing'
       WHEN 'W' THEN 'White/Caucasian'
       WHEN 'B' THEN 'Black/Aferican American'
       WHEN 'O' THEN 'Other'
       END CASE
      ,g.outgrpid
      ,outcmplo
      ,outgrplbl
      ,outgrpval
      ,count(*)
  FROM IDPOUT01.ITOUGROP g
      ,IDPOUT01.ITOUADMN a
      ,IDPOUT01.ITOUFACT f
 WHERE (g.OUTGRPID,F.OUTID) in (SELECT OUTGRPID
                                      ,OUTID
                                  FROM IDPOUT01.ITOUOUTC
                                 WHERE INSTTYPE   = '10'
                                   AND OUTTYPE    = 'EMPOWER')

   AND f.ADMINID  = a.ADMINID
   AND f.OUTVAL BETWEEN g.OUTCMPLO AND g.OUTCMPHI 
 GROUP BY Race
         ,g.outgrpid
         ,outcmplo
         ,outgrplbl
         ,outgrpval


Hope this helps...

Cheers

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