Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum 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

Senior Member


Joined: 14 Mar 2007
Posts: 10626
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: 2270
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: 273
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 LOAD JCL for db2 table, taking too lo... Somnath Giri DB2 2 Mon Oct 14, 2019 3:35 pm
This topic is locked: you cannot edit posts or make replies. COBOL/CICS with real time MQ Series u... BPranav CICS 2 Mon Sep 16, 2019 9:19 pm
No new posts Call DB2 user defined function from C... Ziko13 DB2 5 Thu Mar 14, 2019 4:46 pm
No new posts z/VM z/VSE Get CPU-time of a COBOL Ba... Andi1982 COBOL Programming 3 Mon Mar 11, 2019 3:36 pm
No new posts IEFSJREQ or SWBREQTU following SSI Fu... sidinpsl PL/I & Assembler 0 Tue Jan 08, 2019 1:20 am

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