> It shouldn't work here either. Looks like a defect to me.
> No, it is not useful. It is the optimizer's job to figure out the correct
> selectivity.
>> It shouldn't work here either. Looks like a defect to me.
>
> How about this article:
> http://www-128.ibm.com/developerworks/db2/library/tips/dm-0312yip/
> ?
I wasn't aware that you set the DB2 registry variable DB2_SELECTIVITY to
YES. If you don't do that, then SELECTIVITY is applicable to user-defined
predicates as the error message says.
>> No, it is not useful. It is the optimizer's job to figure out the
>> correct selectivity.
>
> How would you figure out the correct selectivity for this dynamically
> prepared statement:
> select * from tab where dt between ? and ?;
Ok, you are right on that. The optimizer can only guess/use defaults there
or rely on some sort of statistics and information about previous queries.

Signature
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany
Serge Rielau - 07 Feb 2007 13:03 GMT
>> How about this article:
>> http://www-128.ibm.com/developerworks/db2/library/tips/dm-0312yip/
[quoted text clipped - 3 lines]
> YES. If you don't do that, then SELECTIVITY is applicable to user-defined
> predicates as the error message says.
You can also set it to ALL. In that case there are virtually no
restrictions on where it can be used. However obedience by the optimizer
is also limited to "best effort".
If there are "typical" scenarios for the BETWEEN with parameter markers
I would recommend looking into REOPT(ONCE) re-optimization. That way the
optimizer is trained using the very set of actual values.
Cheers
Serge

Signature
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
4.spam@mail.ru - 07 Feb 2007 13:29 GMT
> If there are "typical" scenarios for the BETWEEN with parameter markers
> I would recommend looking into REOPT(ONCE) re-optimization. That way the
> optimizer is trained using the very set of actual values.
But what shall I do in cli application?
AFAIK REOPT applicable only to packages. Is it true?
I don't want to rebind cli packages with this option.
And I couldn't find any "online" command to change optimizator's
behaviour (to use or not to use re-optimization) in cli
applications...
Serge Rielau - 07 Feb 2007 13:45 GMT
>> If there are "typical" scenarios for the BETWEEN with parameter markers
>> I would recommend looking into REOPT(ONCE) re-optimization. That way the
[quoted text clipped - 6 lines]
> behaviour (to use or not to use re-optimization) in cli
> applications...
I'm not sure how it works with CLI..
Cheers
Serge

Signature
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab