From: Merlin Moncure <mmoncure@gmail.com>
To: Matthew Wakeling <matthew@flymine.org>
Cc: pgsql-performance@postgresql.org
Subject: Re: plpgsql arrays
Date: Fri, 3 Apr 2009 11:02:13 -0400
Message-ID: <b42b73150904030802q1b3685br8db7740569e31aea@mail.gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.00.0904031420470.21772@aragorn.flymine.org>
References: <alpine.DEB.2.00.0904031420470.21772@aragorn.flymine.org>
On Fri, Apr 3, 2009 at 9:32 AM, Matthew Wakeling <matthew@flymine.org> wrote:
> genes = '{}';
> next_new = 1;
> FOR loc IN SELECT location.* FROM location, gene WHERE location.subjectid =
> gene.id ORDER BY objectid, intermine_start, intermine_end LOOP
> genes[next_new] = loc;
> IF (next_new % 10000 = 0) THEN
> RAISE NOTICE 'Scanned % gene locations', next_new;
> END IF;
> next_new = next_new + 1;
> END LOOP;
> genes_size = coalesce(array_upper(genes, 1), 0);
> RAISE NOTICE 'Scanned % gene locations', genes_size;
>
> For 200,000 rows it takes 40 minutes.
>
> So, is there a way to dump the results of a query into an array quickly in
> plpgsql, or alternatively is there a way to read two results streams
> simultaneously?
try this:
select array(SELECT location.* FROM location, gene WHERE
location.subjectid = gene.id ORDER BY objectid, intermine_start,
intermine_end)) into genes;
merlin
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: mmoncure@gmail.com, matthew@flymine.org
Subject: Re: plpgsql arrays
In-Reply-To: <b42b73150904030802q1b3685br8db7740569e31aea@mail.gmail.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