Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
optimization of DB2 query

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
abdulrafi

Active User


Joined: 14 Sep 2009
Posts: 151
Location: Coimbatore

PostPosted: Thu Apr 07, 2011 5:01 am    Post subject: optimization of DB2 query
Reply with quote

Hi,

I have a select query like the one below,
SELECT A.Q_COLOR_PNTDSQFT
,A.I_PMIT_GRP
,A.I_PMIT
,A.I_CORPLOC
,A.I_YR
,A.I_MO
,A.I_DAY
,A.I_PMIT_CMPLNC
,A.C_BDY
,A.C_COLOR
FROM P.PDCRPT A
WHERE
A.I_PMIT_GRP = 'TOPCOAT DAILY COMPLIANCE '
AND A.I_PMIT > X'00' AND A.I_PMIT < X'FF'
AND A.I_CORPLOC >= ' '
AND A.I_YR >= ' '
AND A.I_MO >= ' '
AND A.I_DAY >= ' '
AND A.I_PMIT_CMPLNC >= ' '
AND A.C_BDY >= ' '
AND A.C_COLOR >= ' '
ORDER BY A.I_CORPLOC,A.I_YR,A.I_MO,A.I_DAY
;
it takes nearly 126 qunits and 0.00500 of cpu time which is very high. i have 10 more queries like these. when moved to production it runs for 4 hrs. i tried my level best to optimize it, but even then i am not able to. for the values which i can, i have given values for it. I have provided all indexes too.

please help me out If there is any solution to reduce the cpu time and run the query effectively.
Back to top
View user's profile Send private message

prino

Senior Member


Joined: 07 Feb 2009
Posts: 1074
Location: Oostende, Belgium

PostPosted: Thu Apr 07, 2011 5:13 am    Post subject:
Reply with quote

Wow, maybe next time you can also give the definition of the table and indices. We can only read minds on leap days in century years.
Back to top
View user's profile Send private message
chandracdac

New User


Joined: 15 Jun 2007
Posts: 92
Location: bangalore

PostPosted: Wed Apr 13, 2011 2:48 pm    Post subject: Reply to: optimization of DB2 query
Reply with quote

Hi

as per my knowledge and my observation if there are more conditions in where clause it will take more time to execute the query. pls try to reduce that no of condition in ur where clause as per your requirement.


Thanks,
Chandra
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6970
Location: porcelain throne

PostPosted: Wed Apr 13, 2011 4:33 pm    Post subject:
Reply with quote

use between for things like this:
AND A.I_PMIT > X'00' AND A.I_PMIT < X'FF'

AND A.I_PMIT BETWEEN X'01' AND X'FE'

chandracdac wrote:
as per my knowledge and my observation if there are more conditions in where clause it will take more time to execute the query


The quantity of WHERE clause conditions is not the problem.
you can have a large quantity of quality predicates that will enhance the query.
depends on the predicate stage.
Stage 1 predicates function better than Stage2.
Stage 2 precludes the use of indexes.
The idea of WHERE clause is to reduce the result set.
Back to top
View user's profile Send private message
abdulrafi

Active User


Joined: 14 Sep 2009
Posts: 151
Location: Coimbatore

PostPosted: Fri Apr 15, 2011 3:30 am    Post subject: Reply to: optimization of DB2 query
Reply with quote

Hi,

I tried BETWEEN option(A.I_PMIT BETWEEN X'01' AND X'FE'), but it dint make a difference. I am investigating still on how i could reduce the CPU usage time.

If any help it would be appreciable.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6970
Location: porcelain throne

PostPosted: Fri Apr 15, 2011 9:45 am    Post subject:
Reply with quote

you should start with an EXPLAIN which,
among other things,
will help you identify index opportunities.

The between usage will aid in using indexes, if they are available.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts reg query on DYNALLOC feature raghuraman123 SYNCSORT 12 Wed Jan 10, 2018 2:42 pm
No new posts query to fetch record which has only ... maxsubrat DB2 12 Mon Dec 11, 2017 5:03 pm
No new posts How to query MAXGENS of an existing P... Chuchulo Hatyzak JCL & VSAM 4 Wed Nov 22, 2017 10:23 pm
No new posts Native SQL Query kishpra DB2 1 Wed Nov 22, 2017 8:38 pm
No new posts Query on IEFBR14 with GDG Ashishpanpaliya JCL & VSAM 4 Tue Nov 07, 2017 8:34 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us