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
 

 

MAX function is taking more cpu time

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

Active User


Joined: 13 Jul 2005
Posts: 136

PostPosted: Tue Aug 05, 2014 10:36 pm    Post subject: MAX function is taking more cpu time
Reply with quote

SELECT OAORNO
FROM tablename
WHERE
OAFACI = 812 AND
OAORNO = (SELECT MAX(OAORNO)
FROM tableName
WHERE OAFACI = 812)

The above query was taking more cpu time. We have defined index for the "OAFACI" & "OAORNO" columns. Let me know if you have any idea to reduce the cpu time.
Back to top
View user's profile Send private message

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Wed Aug 06, 2014 5:58 pm    Post subject: Reply to: MAX function is taking more cpu time
Reply with quote

Quote:
was taking more cpu time.


more as compared to what ???
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Thu Aug 07, 2014 12:51 am    Post subject:
Reply with quote

Try this, but you need to let us know the volume of data in underlying table and also what is the cpu time you are talking about?
Code:
SELECT OAORNO
FROM tablename
WHERE
OAFACI = 812
order by OAORNO desc
fetch first row only
Back to top
View user's profile Send private message
chandan.inst

Active User


Joined: 03 Nov 2005
Posts: 269
Location: Mumbai

PostPosted: Thu Aug 07, 2014 12:52 pm    Post subject: Reply to: MAX function is taking more cpu time
Reply with quote

What if you execute only subquery as below?
you didn't get desired result or that also taking more time?

Code:
SELECT MAX(OAORNO)
FROM tableName
WHERE OAFACI = 812


Why you need subquery in where clause if you interested in max value of OAORNO?
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
This topic is locked: you cannot edit posts or make replies. Get a job submitted itself every time... arunsoods JCL & VSAM 3 Tue Nov 22, 2016 4:05 pm
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts Check System time(Minute) Using TIME1... balaji81_k DFSORT/ICETOOL 5 Fri Nov 11, 2016 10:53 am
This topic is locked: you cannot edit posts or make replies. Get correct date and time when curren... balaji81_k DB2 24 Fri Oct 14, 2016 10:40 pm
No new posts Strange EXEC function call in z/VM Willy Jensen CLIST & REXX 3 Wed Oct 05, 2016 2:07 pm


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