MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

query problem

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
nadh
Intermediate


Joined: 08 Oct 2004
Posts: 192
Topics: 89

PostPosted: Thu Feb 10, 2005 9:47 am    Post subject: query problem Reply with quote

Code:

SELECT PTY_ID
      ,ACCT_CO_CD
      ,CHK_DIG
      ,PTY_SUR
  FROM DB2.TA02513A
 WHERE PTY_ID >=:W-VAL1-SSA1-DB75B
   AND PTY_ID < :W-VAL2-SSA1-DB75B
 ORDER BY SUBSTR(PTY_ID,11,2)
 OPTIMIZE FOR 16 ROWS


for this i got a coment from dba as
About, the TA02513A-CURP2, the usage of OPTIMIZE for 16 Rows is in conflict with the sort !!

I did not understand what he is asking... cant we use optimize and sort in one query?

pls. any one help me out.

thanks in advance.
nadh
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Feb 10, 2005 10:17 am    Post subject: Reply with quote

Nadh,

Check this link which explains in detail about using OPTIMIZE and ORDER by in the same query with examples.

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/DSNAGH10/5.8.7.2?SHELF=&DT=20010212102121&CASE=

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
SureshKumar
Intermediate


Joined: 23 Jan 2003
Posts: 211
Topics: 21

PostPosted: Thu Feb 10, 2005 11:19 am    Post subject: Reply with quote

Nadh,
ORDER BY will invariably retrieve the entire result and sort it by the criteria. Optimize will be of no significant help here. If its expensive, work on the business requirements, using Index sort or verify if you would need a clustering index..etc.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group