Re: Prepared statement not using index

From: Dave Cramer <pg(at)fastcrypt(dot)com>
To: Guido Neitzer <guido(dot)neitzer(at)pharmaline(dot)de>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Prepared statement not using index
Date: 2005-09-12 12:38:35
Message-ID: 8800F410-0A1C-4AD4-96F0-B3193638056F@fastcrypt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

The difference between the 7.4 driver and the 8.0.3 driver is the
8.0.3 driver is using server side prepared statements and binding the
parameter to the type in setXXX(n,val).

The 7.4 driver just replaces the ? with the value and doesn't use
server side prepared statements.

Dave

On 1-Sep-05, at 7:09 PM, Guido Neitzer wrote:

> Hi.
>
> I have an interesting problem with the JDBC drivers. When I use a
> select like this:
>
> "SELECT t0.aktiv, t0.id, t0.ist_teilnehmer, t0.nachname, t0.plz,
> t0.vorname FROM public.dga_dienstleister t0 WHERE t0.plz
> like ?::varchar(256) ESCAPE '|'" withBindings: 1:"53111"(plz)>
>
> the existing index on the plz column is not used.
>
> When I the same select with a concrete value, the index IS used.
>
> I use PostgreSQL 8.0.3 on Mac OS X and the JDBC driver 8.0-312 JDBC 3.
>
> After a lot of other things, I tried using a 7.4 driver and with
> this, the index is used in both cases.
>
> Why can this happen? Is there a setting I might have not seen?
> Something I do wrong?
>
> cug
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
>
>

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Guido Neitzer 2005-09-12 13:22:11 Re: Prepared statement not using index
Previous Message Richard Huxton 2005-09-12 10:51:17 Re: Slow update