pg.ddx.io pgsql-performance@postgresql.org mailing list archivehelp / color / mirror / Atom feed
From: Sam Mason <sam@samason.me.uk>
To: pgsql-performance@postgresql.org
Subject: Re: tricky query
Date: Tue, 28 Jun 2005 16:42:42 +0100
Message-ID: <20050628154242.GS62747@colo.samason.me.uk> (raw)
In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3415C2BEC@Herge.rcsinc.local>
References: <6EE64EF3AB31D5448D0007DD34EEB3415C2BEC@Herge.rcsinc.local>
Merlin Moncure wrote:
>I've already worked out a query using generate_series (not scalable) and
>pl/pgsql. An SQL only solution would be preferred, am I missing
>something obvious?
I would be tempted to join the table to itself like:
SELECT id+1
FROM foo
WHERE id > 0
AND i NOT IN (SELECT id-1 FROM foo)
LIMIT 1;
Seems to work for me. Not sure if that's good enough for you, but
it may help.
Sam
view thread (19+ messages) latest in thread
Message-ID: <20050628154242.GS62747@colo.samason.me.uk> Permalink: ../20050628154242.GS62747@colo.samason.me.uk/ Also on: postgresql.org/message-id/20050628154242.GS62747@colo.samason.me.uk ·
reply
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: sam@samason.me.uk Subject: Re: tricky query In-Reply-To: <20050628154242.GS62747@colo.samason.me.uk> * 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