Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 0DEF82E0098 for ; Tue, 1 Apr 2008 04:54:05 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 21150-05 for ; Tue, 1 Apr 2008 04:54:02 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from pyrrha.dalibo.net (pyrrha.dalibo.net [212.85.154.72]) by developer.postgresql.org (Postfix) with ESMTP id 0F1ED2E0065 for ; Tue, 1 Apr 2008 04:54:02 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by pyrrha.dalibo.net (Postfix) with ESMTP id 4631457806D; Tue, 1 Apr 2008 09:54:00 +0200 (CEST) Received: from pyrrha.dalibo.net ([127.0.0.1]) by localhost (pyrrha.dalibo.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id giFjZoMvgqTY; Tue, 1 Apr 2008 09:54:00 +0200 (CEST) Received: by pyrrha.dalibo.net (Postfix, from userid 1011) id 1ABCC578072; Tue, 1 Apr 2008 09:54:00 +0200 (CEST) Received: from asterix.local (lan31-6-82-238-146-117.fbx.proxad.net [82.238.146.117]) by pyrrha.dalibo.net (Postfix) with ESMTP id B33A957806D; Tue, 1 Apr 2008 09:53:58 +0200 (CEST) From: =?iso-8859-1?q?C=E9dric_Villemain?= Organization: dalibo.com To: Martin Kjeldsen Subject: Re: Bad prepare performance Date: Tue, 1 Apr 2008 09:53:36 +0200 User-Agent: KMail/1.9.9 Cc: pgsql-performance@postgresql.org MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart22779001.a6z5FsEfTd"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <200804010953.42063.cedric.villemain@dalibo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200804/3 X-Sequence-Number: 29496 --nextPart22779001.a6z5FsEfTd Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi Martin, please CC the mailing-list,=20 then others can repply ;) C=E9dric Villemain (13:59 2008-03-31): > Le Monday 31 March 2008, Martin Kjeldsen a =E9crit=A0: > > I've done the same query on a 8.2.5 database. The first one is prepared > > first and the other is executed directly. > > > > I understand why the there is such a great difference between the two w= ays > > of executing the query (postgres has no way of knowing that $1 will be > > quite big and that the result is not too big). > > > > I could just avoid using prepare statements, but this is done=20 automatically > > with Perl's DBD::Pg. I know how to avoid using prepare statements (avoid > > having placeholders in the statement), but that is not the prettiest of > > work arounds.=20 >=20 > Did you saw this option : >=20 > $sth =3D $dbh->prepare("SELECT id FROM mytable WHERE val =3D ?", > { pg_server_prepare =3D> 0 }); >=20 > Then, *this* query will not be prepared by the server. This works very well. Thanks! Still I regard this as a work around and the optimal solution would be to=20 allow the prepare statement to be prepared with an max(guid) is close to $1= =20 hint or something like that.=20 I heard something about delayed prepare, where the prepared statements is=20 prepared on first use, this would solve my problem. Is this something being= =20 work on right now? Best regards Martin Kjeldsen --nextPart22779001.a6z5FsEfTd Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQBH8eoGo/dppWjpEvwRAm9RAKCwysvQUoKApqRuSMrUaG+kg81s0QCg0zPf 1+hbFxxtGzmT3XzZ9KOC8vU= =pJCx -----END PGP SIGNATURE----- --nextPart22779001.a6z5FsEfTd--