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

Eliminate MAX Clause for fine tuning SQL


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

New User


Joined: 16 Dec 2006
Posts: 1
Location: Chennai

PostPosted: Sat Dec 16, 2006 12:29 pm
Reply with quote

Can any one help me to eliminate MAX Clause for SQL fine tuning
This table has some 5 million records. Job is running for a long time.

For Eg:
SELECT MAX(XXX_NBR)
FROM XXX_YYY
WHERE XXX_NBR > :WS-MIN-NBR
AND YYY = :WS-YYY
WITH UR
Back to top
View user's profile Send private message
die7nadal

Active User


Joined: 23 Mar 2005
Posts: 156

PostPosted: Mon Dec 18, 2006 10:04 am
Reply with quote

What do u want to acomplish thru this query. If u need the Max value, then then u shud use the MAX.
But here are a few things to consider.
1) Are XXX_NBR and YYY Indexed, if not try doing it.
2) If both the columns are indexed, is the predicate that brings back less rows executed first. If not try forcing the predicate that brings back more rows to execute last by concatenating Null to the corresponding host variable as here YYY = :WS-YYY || ''.
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Mon Dec 18, 2006 11:49 am
Reply with quote

Try GROUP BY ...
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 To search DB2 table based on Conditio... DB2 1
No new posts COBOL Performance Tuning COBOL Programming 6
No new posts NOT IN clause in COBOL pgm COBOL Programming 8
No new posts a copybook getting improper values in... COBOL Programming 7
No new posts SUSBSCRIPT WITH SIGN IN PIC CLAUSE COBOL Programming 3
Search our Forums:

Back to Top