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 7CD21545F2 for ; Tue, 8 Mar 2005 12:48:38 +0000 (GMT) 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 53320-09 for ; Tue, 8 Mar 2005 12:48:34 +0000 (GMT) Received: from anchor-post-32.mail.demon.net (anchor-post-32.mail.demon.net [194.217.242.90]) by svr1.postgresql.org (Postfix) with ESMTP id 0692752AA9 for ; Tue, 8 Mar 2005 12:48:33 +0000 (GMT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-32.mail.demon.net with esmtp (Exim 4.42) id 1D8e8Z-000Evh-8P; Tue, 08 Mar 2005 12:48:36 +0000 Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id E8DE516D47; Tue, 8 Mar 2005 12:48:32 +0000 (GMT) Message-ID: <422D9F20.2040104@archonet.com> Date: Tue, 08 Mar 2005 12:48:32 +0000 From: Richard Huxton User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: =?UTF-8?B?TWFya3VzIEJlcnRoZWF1IOKYrQ==?= Cc: "pgsql-performance@postgresql.org" Subject: Re: pl/pgsql faster than raw SQL? References: <1110284432.4905.18.camel@dicaprio.akademie1.de> In-Reply-To: <1110284432.4905.18.camel@dicaprio.akademie1.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.061 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200503/127 X-Sequence-Number: 10832 Markus Bertheau ☭ wrote: > oocms=# explain analyze select count(1) from objects where class = 'Picture'; > QUERY PLAN > ---------------------------------------------------------------------------------------------------------------- > Aggregate (cost=278.16..278.16 rows=1 width=0) (actual time=44.121..44.123 rows=1 loops=1) > -> Seq Scan on objects (cost=0.00..267.65 rows=4205 width=0) (actual time=0.030..33.325 rows=4308 loops=1) > Filter: ("class" = 'Picture'::text) > Total runtime: 44.211 ms > (записей: 4) > > oocms=# explain analyze select class_get_number_of_objects('Picture'); > QUERY PLAN > -------------------------------------------------------------------------------------- > Result (cost=0.00..0.01 rows=1 width=0) (actual time=27.019..27.022 rows=1 loops=1) > Total runtime: 27.062 ms Well, you're saving planning time with the plpgsql version, but that's not going to come to 17ms (you'd hope). The EXPLAIN will take up time itself, and it can look deeper into the SQL version. Try timing two scripts with 100 of each and see if they really differ by that much. -- Richard Huxton Archonet Ltd