Nesa wrote:
Thanks for your reply. Unfortunately it didn't help. Tried with both
once and always but no difference on response time (at least not a
noticeable one).
Differences in the execution plans are most likely the main issue here.
What you have to remember is that the DB2 optimizer has better information
if you provide exact values. For example, if you say "col > ?" then DB2
does not know how many rows might qualify for this predicate. But if you
say "col > 10000", then the estimate will be much more accurate (assuming
up-to-date statistics).
Also note that there is no reason why a stored procedure running a single
query would be any faster than running the query ad-hoc at the CLP. At
most you could save the compilation time. But the actual execution has to
be performed in both cases.
You can also try to use "db2batch" (or snapshots) to narrow things down a
bit more.
--
Knut Stolze
DB2 Information Integration Development
IBM Germany