Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

SQL query taking more time

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

New User


Joined: 29 May 2005
Posts: 1
Location: Mysore

PostPosted: Fri Apr 18, 2008 2:15 pm    Post subject: SQL query taking more time
Reply with quote

Hi,
following query is taking more CPU and Run time(more than 12hours for 65,0000 input records),do u have any sugeestions how to fine tune this DB2 query.

DECLARE EMP1 CURSOR WITH HOLD FOR
SELECT A.EMP1_LN_ID,
B.EMP2_LN_ID
FROM EMP1 A,
EMP2 B,
EMP3 C
WHERE A.STRT_LN_LOC_C = :POE
A.END_LN_LOC_C = :POI
A.EMP1_LN_ID = B.EMP1_LN_ID
B.EMP2_LN_ID = C.EMP2_LN_ID
C.DEPTR_D > :WS-CURR-DATE
A.SCAC_C = :CODE
WITH UR
FOR FETCH ONLY


pls let me know ur suggestins for fine tuning this query.
Back to top
View user's profile Send private message

ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Fri Apr 18, 2008 3:12 pm    Post subject:
Reply with quote

what are the predicates you are using in the where clause 'OR' / 'AND' ?
provide more detials like the keys, indexes etc .. and if u r using the cursor for only fetch y the with hold ? wht are you using this cursor for ?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri Apr 18, 2008 8:07 pm    Post subject:
Reply with quote

Why the HOLD?

because even a FETCH only cursor should be COMMITted occaisionally to release resources.

by the way, I would remove table EMP2. you don"t need it.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Apr 18, 2008 9:02 pm    Post subject:
Reply with quote

Hello,

If the query execution caused multiple cartesian products (say 25k * 20k * 20k rows = 65k total input), the number of rows processed could be
10,000,000,000,000. . . .

I suspect that would take some time. . .
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 Need DB2 query to fetch previous row ! Chandan1993 DB2 10 Sat Jun 03, 2017 10:43 am
No new posts DSNACCOX (can it be run on 1 db/ts, t... SRICOBSAS DB2 5 Sat May 06, 2017 12:59 am
No new posts LISTIDR compiled date/time jerryte IBM Tools 3 Thu Apr 20, 2017 7:37 pm
No new posts Application not run by time HH:MM tri... jzhardy IBM Tools 1 Sun Apr 09, 2017 3:22 pm
No new posts Date and time format in CICS Chandru3183 CICS 2 Sat Mar 18, 2017 12:46 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us