pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliver Jowett <oliver@opencloud.com>
To: Guido Neitzer <guido.neitzer@pharmaline.de>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Prepared statement not using an index
Date: Fri, 02 Sep 2005 10:52:46 +1200
Message-ID: <4317863E.8090001@opencloud.com> (raw)
In-Reply-To: <1D63F6F8-331A-46E4-BF58-1D502A12AC53@pharmaline.de>
References: <1D63F6F8-331A-46E4-BF58-1D502A12AC53@pharmaline.de>

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



view thread (5+ messages)  latest in thread

Message-ID: <4317863E.8090001@opencloud.com>
Permalink:  ../4317863E.8090001@opencloud.com/
Also on:    postgresql.org/message-id/4317863E.8090001@opencloud.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: oliver@opencloud.com, guido.neitzer@pharmaline.de
  Subject: Re: Prepared statement not using an index
  In-Reply-To: <4317863E.8090001@opencloud.com>
  References: <1D63F6F8-331A-46E4-BF58-1D502A12AC53@pharmaline.de> <4317863E.8090001@opencloud.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox