Quote:
|
Originally Posted by grofaty
2. Yes I have host variables in static SQL.
|
In that case, you will have to "convince" the optimizer to use a different access path, viz. the one used by the dynamic query.
So, run explain both with parameter markers ("?") and with explicit constants, and compare the access paths, especially the index(es) used in the two cases.
Most of the time, you can change the optimizer's opinion about an index that's being used and shouldn't by a simple query rewrite. Namely by making the condition on the (first) column in that index look "less efficient", e.g. by adding "+ 0" to its right-hand side (if numeric).