Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 10409
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: 1840
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: 271
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
No new posts Merging records, but not all the time prino DFSORT/ICETOOL 15 Sat Feb 17, 2018 4:20 pm
No new posts Need to identify top 10 costly or tim... ashek15 DB2 4 Wed Feb 14, 2018 3:20 am
No new posts Logic to skip Maximum time-stamp and ... vickey_dw DB2 2 Thu Feb 01, 2018 11:15 pm
No new posts Query to skip Max time-stamp and fetc... vickey_dw DB2 8 Sun Jan 28, 2018 1:09 am
No new posts Comparision with current time arunsoods DFSORT/ICETOOL 5 Thu Nov 09, 2017 10:37 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us