Re: Prepared statement not using an index - Mailing list pgsql-jdbc

From Oliver Jowett
Subject Re: Prepared statement not using an index
Date
Msg-id 4317863E.8090001@opencloud.com
Whole thread Raw
In response to Prepared statement not using an index  (Guido Neitzer <guido.neitzer@pharmaline.de>)
Responses Re: Prepared statement not using an index  (Guido Neitzer <guido.neitzer@pharmaline.de>)
List pgsql-jdbc
Guido Neitzer wrote:

> I have an interesting problem with the JDBC drivers. When I use a
> select like this: [...]

> the existing index on the plz column is not used.
>
> When I the same select with a concrete value, the index IS used.

You should probably ask this on the pgsql-performance list.

> 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.

The 8.0 drivers pass parameters individually to the backend (analogous
to using PREPARE/EXECUTE), while the 7.4 drivers do textual substitution
into the query text. This can result in different query plans as you've
discovered.

-O

pgsql-jdbc by date:

Previous
From: "Dave Held"
Date:
Subject: Re: JDBC 8.0-310 + Crystal Reports 10 == Not Implemented
Next
From: gurkan@resolution.com
Date:
Subject: ...