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 

SQL tuning for a CICS program

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


Joined: 09 May 2003
Posts: 131
Topics: 64

PostPosted: Fri Aug 26, 2005 2:57 pm    Post subject: SQL tuning for a CICS program Reply with quote

Hi,
I'm reading a table in an online program.

ID - Key

Status - (data part of the table)
timestamp - (data part of the table)

I need to show all records in the table (14 records per page) sorted in the following order status:timestamp:ID.

For paging logic I use

if
tbl-status|tbl-timestamp|tbl-id > w-status|w-timestamp|w-id

The logic works.But the response is slow because it is going thru a tablespace scan.

Any suggestions regarding the display of the table contents sorted by the
columns in the data part and not the key of the table.

VIjay
Back to top
View user's profile Send private message
Manas Biswal
Intermediate


Joined: 29 Nov 2002
Posts: 382
Topics: 27
Location: Chennai, India

PostPosted: Fri Aug 26, 2005 3:57 pm    Post subject: Reply with quote

vijay,

Its not the tablespace scan but actually the sort that is killing you. Basically, everytime this query is run (for each page), the whole table's data is sorted on status, timestamp and id and then the qualifying (greater than the last displayed record) records are fetched and returned.
If the table is small, then using your logic is OK. But if the table is big, then you can try other options. I am assuming that your online program is coded Pseudo -conversationally. The problem with pseudo-conversation is that useful facilities like scrollable cursors, GTTs etc. are rendered useless. Anyway, the only way that I can think off is - On the first invocation of your transaction, read the entire table using an order by clause and put it in a TSQ. After that, subsequent paging can retrieve data sequentially from the TSQ. The initial loading of the TSQ will take some time, but overall, the performance will improve.

HTH...Regards,
Manas
_________________
There is no path to peace. Peace is the path.
- Mahatma Gandhi (1869-1948)
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
a_seshu
Beginner


Joined: 30 Sep 2004
Posts: 16
Topics: 4
Location: Chennai

PostPosted: Mon Oct 24, 2005 1:24 pm    Post subject: Reply with quote

Hi Vijay,

Why dont you think the option of creating an index on the table with the columns.

ID, Status, timestamp

preferrably an ascending index...

CREATE INDEX <INDEX NAME> ON <TABLENAME> (ID ASC, STATUS ASC, TIMESTAMP ASC)

This would work for you...
_________________
I dont think I would ever stop learning. - Seshu.
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger
CZerfas
Intermediate


Joined: 31 Jan 2003
Posts: 211
Topics: 8

PostPosted: Tue Oct 25, 2005 4:13 am    Post subject: Reply with quote

Just to add to the last suggestion:
You should tell the optimizer, that you only intend to fetch the first forteen rows of the answer set by coding in the cursor definition "OPTIMIZE FOR 14 ROWS". With that the usage of the before mentioned index is likely, even when the data is not clustered.

regards
Christian
Back to top
View user's profile Send private message
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