From: John A Meinel <john@arbash-meinel.com>
To: Merlin Moncure <merlin.moncure@rcsonline.com>
Cc: Postgresql Performance <pgsql-performance@postgresql.org>
Subject: Re: tricky query
Date: Tue, 28 Jun 2005 10:43:25 -0500
Message-ID: <42C1701D.5040102@arbash-meinel.com> (raw)
In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3415C2BF8@Herge.rcsinc.local>
References: <6EE64EF3AB31D5448D0007DD34EEB3415C2BF8@Herge.rcsinc.local>
Merlin Moncure wrote:
>>Not so bad. Try something like this:
>>
>>SELECT min(id+1) as id_new FROM table
>> WHERE (id+1) NOT IN (SELECT id FROM table);
>>
>>Now, this requires probably a sequential scan, but I'm not sure how
>>
>>
>you
>
>
>>can get around that.
>>Maybe if you got trickier and did some ordering and limits. The above
>>seems to give the right answer, though.
>>
>>
>
>it does, but it is still faster than generate_series(), which requires
>both a seqscan and a materialization of the function.
>
>
>
>>I don't know how big you want to scale to.
>>
>>
>
>big. :)
>
>merlin
>
>
See my follow up post, which enables an index scan. On my system with
90k rows, it takes no apparent time.
(0.000ms)
John
=:->
Attachments:
signature.asc (application/pgp-signature, 252B) download
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: john@arbash-meinel.com, merlin.moncure@rcsonline.com
Subject: Re: tricky query
In-Reply-To: <42C1701D.5040102@arbash-meinel.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