IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Cursor Optimize


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
cesaralt

New User


Joined: 19 Oct 2009
Posts: 3
Location: LIMA-PERU

PostPosted: Tue May 22, 2012 10:37 am
Reply with quote

A table TLDFDDLG has about 4’594,244 registers, a cursor is defined as follow:

EXEC SQL
DECLARE CURSORLG CURSOR FOR
SELECT
CLOG,
BLOG,
GLOG,
.
.
.
EYE_DAT
FROM TLDFDDLG
WHERE FSUBIDA = :WS-FSUBIDA
AND NSESION = :WS-XNSESION
AND TIZTRNID = :WS-TIBTRNID
AND CUSERID = :WS-CUSERID
ORDER BY CLOG DESC
END-EXEC.

This cursor is high CPU time consuming. The table TLDFDDLG has the following indexes:
D.LIB.DDL.DB2(TLDTDDLG)

CREATE UNIQUE INDEX I0_TLDFDDLG ON TLDFDDLG
(CLOG, FSUBIDA)
USING STOGROUP GDTLD001 PRIQTY 100 SECQTY 100
ERASE NO BUFFERPOOL BP2 CLOSE YES;

CREATE INDEX I1_TLDFDDLG ON TLDFDDLG
(CUSERID,FSUBIDA,CLOG)
USING STOGROUP GDTLD001 PRIQTY 100 SECQTY 100
ERASE NO BUFFERPOOL BP2 CLOSE YES;
COMMIT;

CREATE INDEX I2_TLDFDDLG ON TLDFDDLG
(FSUBIDA,NSESION,FLOG)
USING STOGROUP GDTLD001 PRIQTY 100 SECQTY 100
ERASE NO BUFFERPOOL BP2 CLOSE YES;
COMMIT;

CREATE INDEX I3_TLDFDDLG ON TLDFDDLG
(TS_PROC)
USING STOGROUP GDTLD001 PRIQTY 100 SECQTY 100
ERASE NO BUFFERPOOL BP2 CLOSE YES;
COMMIT;

CREATE INDEX I5_TLDFDDLG ON TLDFDDLG
(FSUBIDA, CTRANSID)
USING STOGROUP GDTLD001 PRIQTY 100 SECQTY 100
ERASE NO BUFFERPOOL BP2 CLOSE YES;
COMMIT;

CREATE INDEX I6_TLDFDDLG ON TLDFDDLG
(FSUBIDA,CLOG)
USING STOGROUP GDTLD001 PRIQTY 100 SECQTY 100
ERASE NO BUFFERPOOL BP2 CLOSE YES;

CREATE INDEX I7_TLDFDDLG ON TLDFDDLG
(FSUBIDA)
USING STOGROUP GDTLD001 PRIQTY 100 SECQTY 100
ERASE NO BUFFERPOOL BP2 CLOSE YES;

--PRUEBA
CREATE INDEX I4_TLDFDDLG ON TLDFDDLG
(DIASEM ASC)
USING STOGROUP GDTLD001 PRIQTY 100 SECQTY 100
ERASE NO

Do I have to crete another index to improve the OPEN Cursor?

Thanks for any help,

Regards,
Cesar A.
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Tue May 22, 2012 4:56 pm
Reply with quote

You can drop index I7_TLDFDDLG .

For this query the best index would be to have all 4 columns from the where clause, followed by CLOG DESC.

But you can't just make the perfect index for each statement. it takes a little more consideration and balancing between too many and too little indexes.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Products/Tools to Optimize Adabas Dat... Compuware & Other Tools 2
No new posts Is SQLCODE -811 possible while fetchi... DB2 1
No new posts Restart logic by using cursor name in... DB2 1
No new posts Seeking Resolution for SQKCODE -991 o... DB2 2
No new posts Multiple rows within Cursor when Coun... DB2 14
Search our Forums:

Back to Top