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: 10358
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: 1818
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
No new posts Comparision with current time arunsoods DFSORT/ICETOOL 5 Thu Nov 09, 2017 10:37 am
This topic is locked: you cannot edit posts or make replies. Comparing current time with the time ... arunsoods SYNCSORT 1 Mon Oct 30, 2017 4:07 pm
This topic is locked: you cannot edit posts or make replies. Incrementing current time field by 30... arunsoods DFSORT/ICETOOL 11 Thu Oct 26, 2017 3:22 pm
This topic is locked: you cannot edit posts or make replies. 00D3003B - time outs in DB2 when invo... chavinash2004 DB2 2 Mon Oct 09, 2017 4:39 pm
No new posts VSAM RLS Wait time blayek JCL & VSAM 2 Mon Oct 02, 2017 9:05 pm

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