From: Tom Lane <tgl@sss.pgh.pa.us>
To: cgg007@yahoo.com
Cc: pgsql-sql@postgresql.org
Subject: Re: A Costly function + LIMIT
Date: Fri, 13 Dec 2002 13:20:49 -0500
Message-ID: <6048.1039803649@sss.pgh.pa.us> (raw)
In-Reply-To: <20021213181435.31771.qmail@web13804.mail.yahoo.com>
References: <20021213181435.31771.qmail@web13804.mail.yahoo.com>
Chris Gamache <cgg007@yahoo.com> writes:
> It runs "widget" on 10000 records. The damage would be negligible if it could
> run on the 100...
So do the function calculation outside the UNION/ORDER BY.
SELECT name, address, city, state, zip, widget(name, address, city, state,
zip)
FROM
((SELECT * FROM eastern_usa
ORDER BY state, city, zip, name
LIMIT 5000
UNION ALL
SELECT * FROM western_usa
ORDER BY state, city, zip, name
LIMIT 5000)
ORDER BY 4, 3, 5, 1 LIMIT 100 OFFSET 0) ss;
You might have to fool with the parenthesization a little to get it
to parse ...
regards, tom lane
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-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, cgg007@yahoo.com
Subject: Re: A Costly function + LIMIT
In-Reply-To: <6048.1039803649@sss.pgh.pa.us>
* 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