Re: tricky query

From: Sam Mason <sam(at)samason(dot)me(dot)uk>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: tricky query
Date: 2005-06-28 15:42:42
Message-ID: 20050628154242.GS62747@colo.samason.me.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

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

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message John A Meinel 2005-06-28 15:43:25 Re: tricky query
Previous Message Karl O. Pinc 2005-06-28 15:42:32 Fwd: Re: [PERFORM] Performance analysis of plpgsql code [kop@meme.com]