Re: tricky query - Mailing list pgsql-performance

From Sam Mason
Subject Re: tricky query
Date
Msg-id 20050628154242.GS62747@colo.samason.me.uk
Whole thread Raw
In response to tricky query  ("Merlin Moncure" <merlin.moncure@rcsonline.com>)
List 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

pgsql-performance by date:

Previous
From: John A Meinel
Date:
Subject: Re: tricky query
Next
From: John A Meinel
Date:
Subject: Re: tricky query