X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 57173D70A7 for ; Fri, 2 Sep 2005 09:41:56 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 85961-03 for ; Fri, 2 Sep 2005 12:41:53 +0000 (GMT) Received: from mail.digitalfairway.ca (ns.digitalfairway.ca [207.164.133.170]) by svr1.postgresql.org (Postfix) with ESMTP id 4C1AFD6F9A for ; Fri, 2 Sep 2005 09:41:50 -0300 (ADT) Received: from toronto.toronto.digitalfairway.ca (unknown [192.168.100.10]) by mail.digitalfairway.ca (Postfix) with ESMTP id DE33AA05CD for ; Fri, 2 Sep 2005 08:41:52 -0400 (EDT) Received: from localhost (toronto.toronto.digitalfairway.ca [127.0.0.1]) by toronto.toronto.digitalfairway.ca (Postfix) with ESMTP id 7E9BFA3B23 for ; Fri, 2 Sep 2005 08:41:52 -0400 (EDT) Received: from toronto.toronto.digitalfairway.ca ([127.0.0.1]) by localhost (toronto.toronto.digitalfairway.ca [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 24471-04 for ; Fri, 2 Sep 2005 08:41:52 -0400 (EDT) Received: from [192.168.100.50] (unknown [192.168.100.50]) (using SSLv3 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by toronto.toronto.digitalfairway.ca (Postfix) with ESMTP id 66F8DA3852 for ; Fri, 2 Sep 2005 08:41:52 -0400 (EDT) From: Jan de Visser To: pgsql-jdbc@postgresql.org Subject: Re: Prepared statement not using an index Date: Fri, 2 Sep 2005 08:41:50 -0400 User-Agent: KMail/1.8.2 References: <1D63F6F8-331A-46E4-BF58-1D502A12AC53@pharmaline.de> <4317863E.8090001@opencloud.com> <0C0329E7-1A4B-478C-A003-5C605496FC19@pharmaline.de> In-Reply-To: <0C0329E7-1A4B-478C-A003-5C605496FC19@pharmaline.de> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200509020841.51212.jdevisser@digitalfairway.com> X-Virus-Scanned: amavisd-new at digitalfairway.ca X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.045 required=5 tests=[AWL=-0.005, FORGED_RCVD_HELO=0.05] X-Spam-Level: X-Archive-Number: 200509/12 X-Sequence-Number: 13797 On Friday 02 September 2005 01:49, Guido Neitzer wrote: > On 02.09.2005, at 0:52 Uhr, Oliver Jowett wrote: > >> 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. > > This sounds like a bug to me. If a simple substitution of the > placeholders with actual values ends with different query plan, my > understanding is, that there is something broken in the query > planner ... Well, no. The OP has a 'foo LIKE ?' in there. If his 'actual' query is=20 something like 'foo LIKE bar%', the planner is able to determine that using= =20 an index on foo would help, whereas in the parameterized form he cannot do= =20 that, since 'foo LIKE %bar' would not be helped by that index. In general, things like 'LIKE ?' will be killing performance anyway, for=20 exactly that reason. > > cug JdV!! =2D-=20 =2D------------------------------------------------------------- Jan de Visser =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 jdevisser@digitalfair= way.com =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Baruk Khazad! Khazad ai-menu! =2D-------------------------------------------------------------