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

Re: tricky query

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Merlin Moncure <merlin(dot)moncure(at)rcsonline(dot)com>
Cc: John A Meinel <john(at)arbash-meinel(dot)com>,Postgresql Performance <pgsql-performance(at)postgresql(dot)org>,elein <elein(at)varlena(dot)com>
Subject: Re: tricky query
Date: 2005-06-28 19:31:23
Message-ID: 20050628193123.GA12571@wolff.to (view raw or flat)
Thread:
Lists: pgsql-performance
On Tue, Jun 28, 2005 at 12:02:09 -0400,
  Merlin Moncure <merlin(dot)moncure(at)rcsonline(dot)com> wrote:
> 
> Confirmed.  Hats off to you, the above some really wicked querying.
> IIRC I posted the same question several months ago with no response and
> had given up on it.  I think your solution (smallest X1 not in X) is a
> good candidate for general bits, so I'm passing this to varlena for
> review :)
> 
> SELECT t1.id+1 as id_new FROM id_test t1
>     WHERE NOT EXISTS
>         (SELECT t2.id FROM id_test t2 WHERE t2.id = t1.id+1)
>     ORDER BY t1.id LIMIT 1;

You need to rework this to check to see if row '1' is missing. The
above returns the start of the first gap after the first row that
isn't missing.

In response to

pgsql-performance by date

Next:From: Cosimo StrepponeDate: 2005-06-28 19:33:03
Subject: Re: tricky query
Previous:From: Jean-Max ReymondDate: 2005-06-28 18:47:27
Subject: Re: perl garbage collector

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