pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: Markus Bertheau ☭ <twanger@bluetwanger.de>
Cc: pgsql-performance@postgresql.org <pgsql-performance@postgresql.org>
Subject: Re: pl/pgsql faster than raw SQL?
Date: Tue, 08 Mar 2005 12:48:32 +0000
Message-ID: <422D9F20.2040104@archonet.com> (raw)
In-Reply-To: <1110284432.4905.18.camel@dicaprio.akademie1.de>
References: <1110284432.4905.18.camel@dicaprio.akademie1.de>

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



view thread (6+ messages)  latest in thread

Message-ID: <422D9F20.2040104@archonet.com>
Permalink:  ../422D9F20.2040104@archonet.com/
Also on:    postgresql.org/message-id/422D9F20.2040104@archonet.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: dev@archonet.com, twanger@bluetwanger.de
  Subject: Re: pl/pgsql faster than raw SQL?
  In-Reply-To: <422D9F20.2040104@archonet.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox