From: Greg Stark <gsstark@mit.edu>
To: PFC <lists@boutiquenumerique.com>
Cc: Oleg Bartunov <oleg@sai.msu.su>
Cc: alex@neteconomist.com, "Greg Stark" <gsstark@mit.edu>
Cc: Merlin Moncure <merlin.moncure@rcsonline.com>
Cc: Andrei Bintintan <klodoma@ar-sd.net>
Cc: pgsql-performance@postgresql.org
Subject: Re: [SQL] OFFSET impact on Performance???
Date: 27 Jan 2005 13:33:33 -0500
Message-ID: <87d5vqwwle.fsf@stark.xeocode.com> (raw)
In-Reply-To: <opsk9sr1qoth1vuj@musicbox>
References: <6EE64EF3AB31D5448D0007DD34EEB3412A75CB@Herge.rcsinc.local>
<87brbiah0f.fsf@stark.xeocode.com>
<opsk7nngxwth1vuj@musicbox>
<33c6269f0501261035bc87695@mail.gmail.com>
<opsk8a28tcth1vuj@musicbox>
<33c6269f05012620427c1ccc40@mail.gmail.com>
<opsk89szusth1vuj@musicbox>
<Pine.GSO.4.62.0501271332200.6701@ra.sai.msu.su>
<opsk9cicntth1vuj@musicbox>
<Pine.GSO.4.62.0501271415370.6701@ra.sai.msu.su>
<opsk9iwzf2th1vuj@musicbox>
<Pine.GSO.4.62.0501271642280.6701@ra.sai.msu.su>
<opsk9sr1qoth1vuj@musicbox>
PFC <lists@boutiquenumerique.com> writes:
> intset(x) seems to be like array[x] ?
> Actually what I want is the opposite.
What you want is called UNNEST. It didn't get done in time for 8.0. But if
what you have is an array of integers the int_array_enum() function I quoted
in the other post is basically that.
> Note that int_agg_final_array() crashes my postgres, see my message in
> psql/general
You don't really need the int_array_aggregate function any more. You can write
your own aggregate using the new array operators:
test=> create or replace function array_push (anyarray, anyelement) returns anyarray as 'select $1 || $2' language sql immutable strict;
CREATE FUNCTION
test=> create aggregate array_aggregate (basetype=anyelement, sfunc=array_push, stype=anyarray, initcond = '{}');
CREATE AGGREGATE
Of course it's about 50x slower than the C implementation though:
test=> select icount(array_aggregate (foo_id)) from foo;
icount
--------
15127
(1 row)
Time: 688.419 ms
test=> select icount(int_array_aggregate (foo_id)) from foo;
icount
--------
15127
(1 row)
Time: 13.680 ms
(And no, that's not a caching artifact; the whole table is cached for both
trials)
--
greg
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: gsstark@mit.edu, lists@boutiquenumerique.com, oleg@sai.msu.su, merlin.moncure@rcsonline.com, klodoma@ar-sd.net
Subject: Re: [SQL] OFFSET impact on Performance???
In-Reply-To: <87d5vqwwle.fsf@stark.xeocode.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