Connecting Tech Pros Worldwide Help | Site Map

setting optimization level in stored procedure

  #1  
Old November 11th, 2008, 07:05 PM
db2admin
Guest
 
Posts: n/a
hi,

I have query which runs great when optimization level is changed to 3
but does not run fine with default optimization level of 5. since this
is a query in java code, i do not know how can i change optimization
level of this one sql. also, developers are not comfortable with this.

i am thinking of writing stored procedure in which i can execute sql
with lower optimization level and return resultset to java code.

is it possible to change optimization in stored procedure ? how can
this be accomplished ?
please share your thoughts.


regards,
db2admin
  #2  
Old November 11th, 2008, 08:05 PM
jefftyzzer
Guest
 
Posts: n/a

re: setting optimization level in stored procedure


On Nov 11, 11:00*am, db2admin <jag...@gmail.comwrote:
Quote:
hi,
>
I have query which runs great when optimization level is changed to 3
but does not run fine with default optimization level of 5. since this
is a query in java code, i do not know how can i change optimization
level of this one sql. also, developers are not comfortable with this.
>
i am thinking of writing stored procedure in which i can execute sql
with lower optimization level and return resultset to java code.
>
is it possible to change optimization in stored procedure ? how can
this be accomplished ?
please share your thoughts.
>
regards,
db2admin
Assuming we're talking dynamic SQL here--and you're on LUW--the SET
CURRENT QUERY OPTIMIZATION statement is dynamically preparable, so you
could execute this statement (via EXECUTE IMMEDIATE) before you
execute the SQL.

--Jeff
  #3  
Old November 11th, 2008, 08:05 PM
Serge Rielau
Guest
 
Posts: n/a

re: setting optimization level in stored procedure


db2admin wrote:
Quote:
hi,
>
I have query which runs great when optimization level is changed to 3
but does not run fine with default optimization level of 5. since this
is a query in java code, i do not know how can i change optimization
level of this one sql. also, developers are not comfortable with this.
>
i am thinking of writing stored procedure in which i can execute sql
with lower optimization level and return resultset to java code.
>
is it possible to change optimization in stored procedure ? how can
this be accomplished ?
please share your thoughts.
Is this JDBC or SQLJ?
You can just SET the current query optimization level before executing a
dynamic (JDBC) statement and then resetting it afterwards.

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
comp.lang.c Answers to Frequently Asked Questions (FAQ List) Steve Summit answers 0 November 14th, 2005 07:46 PM
comp.lang.c Answers to Frequently Asked Questions (FAQ List) Steve Summit answers 0 November 14th, 2005 03:55 PM
comp.lang.c Answers to Frequently Asked Questions (FAQ List) Steve Summit answers 5 November 14th, 2005 12:36 PM
ADP vs. MDB: Speed Neil answers 60 November 13th, 2005 10:11 AM