On 11.09.2005, at 11:03 Uhr, Andreas Seltenreich wrote:
> I'm not perfectly sure, but since the index could only be used with a
> subset of all possible parameters (the pattern for like has to be
> left-anchored), I could imagine the planner has to avoid the index in
> order to produce an universal plan (the thing behind a prepared
> statement).
Hmm. Now I get it. So I have to look that my framework doesn't
produce a preparedStatement, instead build a complete statement
string. Weird.
> Is there a reason you are using the like operator at all? IMO using
> the =-operator instead in your example should produce an "index-using
> prepared statement".
Yes, you are right, but then I can't pass anything like '45%' to the
query. It will just return nothing.
I use the "like" because I build the queries on the fly and add a %
at the end where necessary.
And, to be clear: this is a minimal example, most of my queries are
generated by a framework. This was an example to test the behaviour.
Okay, I had problems with the understanding of prepared statements on
the client and the server side. What I thought was, that I get a
preparedStatement by JDBC which also inserts the values into the
string and this is executed on the server side.
cug