Re: LIMIT Optimization - Mailing list pgsql-sql

From Bruce Momjian
Subject Re: LIMIT Optimization
Date
Msg-id 200201251732.g0PHWrd27513@candle.pha.pa.us
Whole thread Raw
In response to LIMIT Optimization  ("alexandre paes :: aldeia digital" <alepaes@aldeiadigital.com.br>)
Responses Re: LIMIT Optimization  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: LIMIT Optimization  (Oleg Bartunov <oleg@sai.msu.su>)
List pgsql-sql
alexandre paes :: aldeia digital wrote:
> Hi,
> 
> DB2, Sql Server and Oracle have a smart optimization sql-clause (DB2
> example):
> 
> SELECT * FROM <table> WHERE <cond> ORDER BY <order> OPTMIZATION FOR n ROWS
> 
> The [OPTMIZATION FOR] clause turns the query fast by optimize the first "n"
> rows.
> If the query returns more than "n" rows, the query is slowest if compared
> with a normal
> query, but it does not have the limitation of PostgreSQL's LIMIT clause.
> 
> I think that clause performs the search twice: one for optimize and other if
> the # of rows
> is great then "n".
> 
> It's possible to include this in future releases of PostgreSQL ????

So it forces our LIMIT optimization, without limiting the number of rows
returned.  That seems to be of questionable value.  The only value I can
see for it is for CURSOR queries but I don't think we can start
returning rows from even a cursor until the entire query is done
executing.

--  Bruce Momjian                        |  http://candle.pha.pa.us pgman@candle.pha.pa.us               |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


pgsql-sql by date:

Previous
From: Arve Fahlvik
Date:
Subject: Complex column ref.
Next
From: Tom Lane
Date:
Subject: Re: LIMIT Optimization