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 7B887329E64 for ; Wed, 22 Sep 2004 22:44:08 +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 46404-04 for ; Wed, 22 Sep 2004 21:44:00 +0000 (GMT) Received: from hotmail.com (bay9-dav21.bay9.hotmail.com [64.4.46.125]) by svr1.postgresql.org (Postfix) with ESMTP id 91B6D329E17 for ; Wed, 22 Sep 2004 22:44:01 +0100 (BST) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Wed, 22 Sep 2004 14:44:00 -0700 Received: from 67.81.98.198 by bay9-dav21.bay9.hotmail.com with DAV; Wed, 22 Sep 2004 21:43:12 +0000 X-Originating-IP: [67.81.98.198] X-Originating-Email: [awerman@hotmail.com] X-Sender: awerman@hotmail.com From: "Aaron Werman" To: "Scott Kirkwood" , References: Subject: Re: Caching of Queries Date: Wed, 22 Sep 2004 17:43:16 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 Message-ID: X-OriginalArrivalTime: 22 Sep 2004 21:44:00.0666 (UTC) FILETIME=[457BEFA0:01C4A0ED] 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/272 X-Sequence-Number: 8400 There is a difference between MySQL and Oracle here. Oracle, to reduce parse/planner costs, hashes statements to see if it can match an existing optimizer plan. This is optional and there are a few flavors that range from a characher to characyter match through parse tree matches through replacing of literals in the statements with parameters. This dramatically improves performance in almost all high transaction rate systems. MySQL stores a statement with its results. This is optional and when a client allows this type of processing, the SQL is hashed and matched to the statement - and the stored *result* is returned. The point is that a lot of systems do lots of static queries, such as a pick list on a web page - but if the data changes the prior result is returned. This (plus a stable jdbc driver) was the reason MySQL did well in the eWeek database comparison. /Aaron ----- Original Message ----- From: "Scott Kirkwood" To: Sent: Wednesday, September 22, 2004 3:50 PM Subject: [PERFORM] Caching of Queries > 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? > > ---------------------------(end of broadcast)--------------------------- > TIP 7: don't forget to increase your free space map settings >