Skip site navigation (1) Skip section navigation (2)

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: (view raw, whole thread or download thread mbox)
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.


In response to

pgsql-performance by date

Next:From: John A MeinelDate: 2005-06-28 15:43:25
Subject: Re: tricky query
Previous:From: Karl O. PincDate: 2005-06-28 15:42:32
Subject: Fwd: Re: [PERFORM] Performance analysis of plpgsql code []

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group