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 > Regarding Query execution

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-19-10, 10:14
infyravi infyravi is offline
Registered User
 
Join Date: Apr 2010
Posts: 19
Regarding Query execution

Hi,
I have a doubt regarding how the following dynamic queries will be executed from a preparedstatement in Java.

1) Select name, age,salary from employee where id in (?)

2) Select name, age,salary from employee where id in (?,?)

3) Select name, age,salary from employee where id in (?,?,?)

Will the query optimization happen only once or will DB2 treat each of the above queries as a different query and do optimization, do hard parsing and softparsing or it will only do soft parsing for 2 and 3.
Reply With Quote
  #2 (permalink)  
Old 08-19-10, 11:19
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
These will be treated as three different queries.
Reply With Quote
  #3 (permalink)  
Old 08-23-10, 08:24
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
The simple reason is that all 3 queries can lead to different access paths, i.e. because of the selectivity values.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
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