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
Hmm. Now I get it. So I have to look that my framework doesn't
produce a preparedStatement, instead build a complete statement
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
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.
---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not