X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id A6F9B9DC9A5 for ; Fri, 20 Jan 2006 05:14:16 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 33845-09 for ; Fri, 20 Jan 2006 05:14:17 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.205]) by postgresql.org (Postfix) with ESMTP id 50A3E9DC8DA for ; Fri, 20 Jan 2006 05:14:13 -0400 (AST) Received: by zproxy.gmail.com with SMTP id 13so421506nzn for ; Fri, 20 Jan 2006 01:14:15 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type; b=KJ0pMTVBL+dR3h2ZLIp4X0pLk/Ka1j3jKWnnr2X+xJwcSCA3K3dBvvtRaApDEmeiP4zjhoaVo2kYgiw12FoZxwvHH5QBG+3dcxjXvI8YtsrpsrAoGTvR/GHF+z19xIS1IJwqoOLFmayLBDw7kLj7XCm2bK+oFvyq8+1rBcftoUk= Received: by 10.37.2.65 with SMTP id e65mr1265924nzi; Fri, 20 Jan 2006 01:14:15 -0800 (PST) Received: by 10.36.148.6 with HTTP; Fri, 20 Jan 2006 01:14:15 -0800 (PST) Message-ID: <3a3a16930601200114p27ccb3fdn750286898f39c405@mail.gmail.com> Date: Fri, 20 Jan 2006 18:14:15 +0900 From: James Russell To: pgsql-performance@postgresql.org Subject: Retaining execution plans between connections? MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_2395_31688086.1137748455547" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.643 required=5 tests=[HTML_00_10=0.642, HTML_MESSAGE=0.001] X-Spam-Score: 0.643 X-Spam-Level: X-Archive-Number: 200601/337 X-Sequence-Number: 16815 ------=_Part_2395_31688086.1137748455547 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi there, I am running a website where each page connects to the DB to retrieve and write information. Each page load uses a separate connection (rather than just sharing one as is the common case) because I use a lot of transactions= . I am looking to speed up performance, and since each page executes a static set of queries where only the parameters change, I was hoping to take advantage of stored procedures since I read that PostgreSQL's caches the execution plans used inside stored procedures. However, the documentation states that this execution plan caching is done on a per-connection basis. If each page uses a separate connection, I can get no performance benefit between pages. In other words, there's no benefit to me in putting a one-shot query that i= s basically the same for every page (e.g. "SELECT * FROM users WHERE user_name=3D''") inside a stored proc, since the generated execut= ion plan will be thrown away once the connection is dropped. Has anyone found a way around this limitation? As I said, I can't share the DB connection between pages (unless someone knows of a way to do this and still retain a level of separation between pages that use the same DB connection). Many thanks, James ------=_Part_2395_31688086.1137748455547 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi there,

I am running a website where each page connects to the DB to retrieve and write information. Each page load uses a separate connection (rather than just sharing one as is the common case) because I use a lot of transactions.

I am looking to speed up performance, and since each page executes a static set of queries where only the parameters change, I was hoping to take advantage of stored procedures since I read that PostgreSQL's caches the execution plans used inside stored procedures.

However, the documentation states that this execution plan caching is done on a per-connection basis. If each page uses a separate connection, I can get no performance benefit between pages.

In other words, there's no benefit to me in putting a one-shot query that is basically the same for every page (e.g. "SELECT * FROM users WHERE user_name=3D'<username>'") inside a stored proc, since the generated execution plan will be thrown away once the connection is dropped.

Has anyone found a way around this limitation? As I said, I can't share the DB connection between pages (unless someone knows of a way to do this and still retain a level of separation between pages that use the same DB connection).

Many thanks,

James
------=_Part_2395_31688086.1137748455547--