From: | Guido Neitzer <guido(dot)neitzer(at)pharmaline(dot)de> |
---|---|
To: | Andreas Seltenreich <andreas+pg(at)gate450(dot)dyndns(dot)org>, pgsql-performance(at)postgresql(dot)org |
Subject: | Re: Index not used with prepared statement |
Date: | 2005-09-11 10:35:09 |
Message-ID: | 9FDFDA1B-5A2B-465F-A4BA-ED70D1BCE62A@pharmaline.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
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
From | Date | Subject | |
---|---|---|---|
Next Message | John A Meinel | 2005-09-11 12:35:53 | Re: shared buffers |
Previous Message | Andreas Seltenreich | 2005-09-11 09:03:23 | Re: Index not used with prepared statement |