X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3FE38329D27 for ; Wed, 22 Sep 2004 20:51:06 +0100 (BST) 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 11914-03 for ; Wed, 22 Sep 2004 19:50:59 +0000 (GMT) Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.197]) by svr1.postgresql.org (Postfix) with ESMTP id 8FF9E329D18 for ; Wed, 22 Sep 2004 20:50:59 +0100 (BST) Received: by mproxy.gmail.com with SMTP id 79so2078554rnk for ; Wed, 22 Sep 2004 12:50:45 -0700 (PDT) Received: by 10.38.74.50 with SMTP id w50mr4242256rna; Wed, 22 Sep 2004 12:50:26 -0700 (PDT) Received: by 10.38.73.17 with HTTP; Wed, 22 Sep 2004 12:50:26 -0700 (PDT) Message-ID: Date: Wed, 22 Sep 2004 16:50:26 -0300 From: Scott Kirkwood Reply-To: Scott Kirkwood To: pgsql-performance@postgresql.org Subject: Caching of Queries Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200409/221 X-Sequence-Number: 8349 I couldn't find anything in the docs or in the mailing list on this, but it is something that Oracle appears to do as does MySQL. The idea, I believe, is to do a quick (hash) string lookup of the query and if it's exactly the same as another query that has been done recently to re-use the old parse tree. It should save the time of doing the parsing of the SQL and looking up the object in the system tables. It should probably go through the planner again because values passed as parameters may have changed. Although, for extra points it could look at the previous query plan as a hint. On the surface it looks like an easy enhancement, but what do I know? I suppose it would benefit mostly those programs that use a lot of PQexecParams() with simple queries where a greater percentage of the time is spent parsing the SQL rather than building the execute plan. What do you think?