Re: Select subset of rows - Mailing list pgsql-sql

From John McKown
Subject Re: Select subset of rows
Date
Msg-id Pine.LNX.4.21.0008272255030.15401-100000@linux2.johnmckown.net
Whole thread Raw
In response to Re: Select subset of rows  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
Responses Re: Select subset of rows  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
List pgsql-sql
On Sun, 27 Aug 2000, Stephan Szabo wrote:

> 
> Of course immediately after sending the last message and logging off my
> ISP I figured out the simpler way for the third one:
> 
> begin;
> select salary into temp saltemp from employee order by salary desc 
>  limit 5;
> select name from employee where exists (select * from saltemp where
>  saltemp.salary=employee.salary);
> end;
> 
> Stephan Szabo
> sszabo@bigpanda.com
> 

I wonder if the following might be a bit faster? Or would it be slower?

select salary into temp saltemp from employee order by salary desc
limit 5;

select min(salary) as minsal into test minsal from saltemp;

select name, salary from employee, minsalwhere salary >= minsal;

I don't know the speed difference between my second select and your
subselect within an EXISTS clause might be.

Just a thought,
John



pgsql-sql by date:

Previous
From: Yury Don
Date:
Subject: Re: weird structure
Next
From: Stephan Szabo
Date:
Subject: Re: Select subset of rows