Re: [HACKERS] Solution for LIMIT cost estimation

Chris <chrisb@nimrod.itg.telstra.com.au>

From: Chris Bitmead <chrisb@nimrod.itg.telstra.com.au>
To: Don Baccus <dhogaza@pacifier.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, chris@bitmead.com, pgsql-hackers@postgreSQL.org
Date: 2000-02-11T06:57:59Z
Lists: pgsql-hackers
Don Baccus wrote:

> But ... that doesn't mean that some folks might not want to use
> it differently.  What if LIMIT 2 were more efficient that COUNT(*)
> in order to determine if more than one row satisfies a condition?

select count(*) > 1 from a;

And if that's not efficient, why not optimise _that_, since it 
expresses directly what you want?

> But I wouldn't feel badly at all if LIMIT limited to queries
> with ORDER BY.  I think this could be done gramatically, i.e.
> 
> [query] ORDER BY

If you are going to limit it thus, it only makes sense if you
either order by a unique key or order by every single column.
Otherwise, why limit it at all? And that can't be determined
gramatically.