From: Richard Huxton <dev@archonet.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
To: Josh Berkus <josh@agliodbs.com>
Cc: chester c young <chestercyoung@yahoo.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: rownum
Date: Fri, 14 Feb 2003 10:10:15 +0000
Message-ID: <200302141010.15271.dev@archonet.com> (raw)
In-Reply-To: <4353.1045200034@sss.pgh.pa.us>
References: <20030214043800.99417.qmail@web12707.mail.yahoo.com>
<200302132056.20122.josh@agliodbs.com>
<4353.1045200034@sss.pgh.pa.us>
On Friday 14 Feb 2003 5:20 am, Tom Lane wrote:
>
> select nextval('rownum'), * from (select ... order by ...) sub;
>
> The overhead of using a sequence for this is pretty annoying. It would
> be a simple matter to write a C function that emits sequential values
> without any database access (see pg_stat_get_backend_idset() for some
> inspiration). But you'd still need the subselect to avoid getting
> re-sorted. AFAICS any rownum() function that doesn't behave like that
> is a flat violation of the SQL standard...
Could you not build a wrapper function something like:
SELECT with_rownum('SELECT ...');
Where the function returns SETOF RECORD or similar - just fetch rows from the
select and prepend a pg_rownum column?
--
Richard Huxton
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: dev@archonet.com, tgl@sss.pgh.pa.us, josh@agliodbs.com, chestercyoung@yahoo.com
Subject: Re: rownum
In-Reply-To: <200302141010.15271.dev@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