X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id B017CD1B518 for ; Tue, 21 Oct 2003 15:03:10 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 81926-03 for ; Tue, 21 Oct 2003 12:02:39 -0300 (ADT) Received: from localhost.localdomain (unknown [65.217.53.66]) by svr1.postgresql.org (Postfix) with ESMTP id 9A496D1B4F8 for ; Tue, 21 Oct 2003 12:02:38 -0300 (ADT) Received: from thorn.mmrd.com (thorn.mmrd.com [172.25.10.100]) by localhost.localdomain (8.12.8/8.12.8) with ESMTP id h9LE1uqd016680; Tue, 21 Oct 2003 10:01:56 -0400 Received: from gnvex001.mmrd.com (gnvex001.mmrd.com [192.168.3.55]) by thorn.mmrd.com (8.11.6/8.11.6) with ESMTP id h9LF2QZ21011; Tue, 21 Oct 2003 11:02:26 -0400 Received: from camel.mmrd.com ([172.25.5.213]) by gnvex001.mmrd.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id TD8AYXX3; Tue, 21 Oct 2003 11:02:24 -0400 Subject: Re: SRFs ... no performance penalty? From: Robert Treat To: Josh Berkus Cc: pgsql-performance@postgresql.org In-Reply-To: <200310201755.12713.josh@agliodbs.com> References: <200310201755.12713.josh@agliodbs.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 21 Oct 2003 11:02:25 -0400 Message-Id: <1066748545.2069.7085.camel@camel> Mime-Version: 1.0 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/529 X-Sequence-Number: 4277 On Mon, 2003-10-20 at 20:55, Josh Berkus wrote: > Folks, > > I'm working on the demo session for our upcoming presentation at PHPCon. > > As a side issue, we ended up comparing 3 versions of the same search screen: > > 1) All in PHP with views; > 2) Using a function to build a query and count results but executing that > query directly and sorting, paging in PHP; > 3) Using a Set Returning function to handle row-returning, sorting, and > paging. > > All three methods were executing a series moderately complex query against a > medium-sized data set (only about 20,000 rows but it's on a laptop). The > postgresql.conf was tuned like a webserver; e.g. low sort_mem, high > max_connections. > > So far, on the average of several searches, we have: > > 1) 0.19687 seconds > 2) 0.20667 seconds > 3) 0.20594 seconds > Is this measuring time in the back-end or total time of script execution? > In our tests, using any kind of PL/pgSQL function seems to carry a 0.01 second > penalty over using PHP to build the search query. I'm not sure if this is > comparitive time for string-parsing or something else; the 0.01 seems to be > consistent regardless of scale. > > The difference between using a PL/pgSQL function as a query-builder only (the > 7.2.x method) and using SRFs was small enough not to be significant. > > -- > -Josh Berkus > Aglio Database Solutions > San Francisco > > > ---------------------------(end of broadcast)--------------------------- > TIP 8: explain analyze is your friend Robert Treat -- Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL