Re: Quota query with decent performance? - Mailing list pgsql-sql

From Bruno Wolff III
Subject Re: Quota query with decent performance?
Date
Msg-id 20031118125642.GC30809@wolff.to
Whole thread Raw
In response to Re: Quota query with decent performance?  (Troels Arvin <troels@arvin.dk>)
List pgsql-sql
On Mon, Nov 17, 2003 at 23:55:53 +0100, Troels Arvin <troels@arvin.dk> wrote:
> On Tue, 11 Nov 2003 18:49:31 -0500, Chester Kustarz wrote:
> 
> [... discussion of top-n query (where n=3) ...]
> 
> > select *
> > from person
> > where age <=
> > (select age from person order by age limit 1 offset 2);
> 
> It fails when the cardinality of person is less than 3 (returns empty
> set). My solution is this, which is not as beautiful any more:

Used that way the subselect value will be null if there are no matching
rows. This should allow you to do something like:

select *
from person
where not isfalse (age <=
(select age from person order by age limit 1 offset 2));


pgsql-sql by date:

Previous
From: Michele Bendazzoli
Date:
Subject: Re: Multicolum index and primary key
Next
From: Troels Arvin
Date:
Subject: Re: Quota query with decent performance?