Re: Index not used with prepared statement

Поиск
Список
Период
Сортировка
Искать
От
Guido Neitzer
Тема
Re: Index not used with prepared statement
Дата
Msg-id
9FDFDA1B-5A2B-465F-A4BA-ED70D1BCE62A@pharmaline.de
Ответ на
Список
Дерево обсуждения
Index not used with prepared statement Guido Neitzer <guido.neitzer@pharmaline.de>
Re: Index not used with prepared statement Andreas Seltenreich <andreas+pg@gate450.dyndns.org>
Re: Index not used with prepared statement Guido Neitzer <guido.neitzer@pharmaline.de>
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
В списке pgsql-performance по дате отправления
От: Andreas Seltenreich
Дата:
От: John A Meinel
Дата:
Сообщение: Re: shared buffers
FAQ