If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > How to set the optimisation level for a single query in one statement ?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-07-07, 12:21
kunal kunal is offline
Registered User
 
Join Date: May 2006
Posts: 18
How to set the optimisation level for a single query in one statement ?

Hi .

I want to know how to set optimization level for any query in a single statement. I mean say I have query " select * from A", I want that for this query optimization setting should be 3. One way to do so is execute "set optimization level = 3 for current query " and execute that as a statement before it. But I want to do so in a single statement .(so that it can be automated)...what is the syntax for that?
Reply With Quote
  #2 (permalink)  
Old 02-07-07, 12:36
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
To my knowledge there is no single command to do what you want.

Andy
Reply With Quote
  #3 (permalink)  
Old 02-07-07, 12:52
grofaty grofaty is offline
Registered User
 
Join Date: Jan 2003
Posts: 1,570
kunal, if you have a need for automating try thinking into changing db cfg parameter for all statements. The level 3 is better for OLTP applications. The default is 5. So lowering this parameter on db cfg level can eliminate the need of any optimization level by statement.
Reply With Quote
  #4 (permalink)  
Old 02-07-07, 13:35
kunal kunal is offline
Registered User
 
Join Date: May 2006
Posts: 18
Hi, The reason why I dont want to change my default setting to 3 is coz ours is basically a data warehouse application with 80% data warehouse OLAP queries which works fine but there are few OLTP queries fired for which Db2 gives good performance only if we lower OPT level..Thats why I am looking for a single statement?
Reply With Quote
  #5 (permalink)  
Old 02-07-07, 14:27
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
You want to look at the following SQL command:

SET CURRENT QUERY OPTIMIZATION

I am not sure if this applies globably or only to the session that issues it.

BTW, in my tests of suing DB2 with the TCP-H benchmarks, some queries run faster with level 7.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #6 (permalink)  
Old 02-07-07, 14:42
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Marcus,
It only applies to the session. the SET DB CFG FOR bdalias using DBF_QUERYOPT sets it globally. The original post stated that he was looking for a way around using SET CURRENT QUERY OPTIMIZATION.

Andy
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On