From: Robert Haas <robertmhaas@gmail.com>
To: Eliot Gable <egable+pgsql-performance@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Replacing Cursors with Temporary Tables
Date: Wed, 21 Apr 2010 21:21:28 -0400
Message-ID: <g2l603c8f071004211821kdc725261pb51e4487892e8a4b@mail.gmail.com> (raw)
In-Reply-To: <n2ybf6923ed1004211316ib844d82bn7a63bd3292ca80a0@mail.gmail.com>
References: <n2ybf6923ed1004211316ib844d82bn7a63bd3292ca80a0@mail.gmail.com>
I think it's really tough to say how this is going to perform. I'd
recommend constructing a couple of simplified test cases and
benchmarking the heck out of it. One of the problems with temporary
tables is that every time you create a temporary table, it creates a
(temporary) record in pg_class; that can get to be a problem if you do
it a lot. Another is that for non-trivial queries you may need to do
a manual ANALYZE on the table to get good stats for the rest of the
query to perform well. But on the flip side, as you say, nesting and
unnesting of arrays and function calls are not free either. I am
going to hazard a SWAG that the array implementation is faster UNLESS
the lack of good stats on the contents of the arrays is hosing the
performance somewhere down the road. But that is really just a total
shot in the dark.
Another possible implementation might be to have a couple of permanent
tables where you store the results. Give each such table a "batch id"
column, and return the batch id from your stored procedure. This
would probably avoid a lot of the overhead associated with temp tables
while retaining many of the benefits.
...Robert
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-performance@postgresql.org
Cc: robertmhaas@gmail.com, egable+pgsql-performance@gmail.com
Subject: Re: Replacing Cursors with Temporary Tables
In-Reply-To: <g2l603c8f071004211821kdc725261pb51e4487892e8a4b@mail.gmail.com>
References: <n2ybf6923ed1004211316ib844d82bn7a63bd3292ca80a0@mail.gmail.com> <g2l603c8f071004211821kdc725261pb51e4487892e8a4b@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