Re: Prepared statement not using an index

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Guido Neitzer <guido(dot)neitzer(at)pharmaline(dot)de>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Prepared statement not using an index
Date: 2005-09-01 22:52:46
Message-ID: 4317863E.8090001@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message gurkan 2005-09-01 23:32:18
Previous Message Dave Held 2005-09-01 22:17:54 Re: JDBC 8.0-310 + Crystal Reports 10 == Not Implemented