Re: Which one is faster? - Mailing list pgsql-sql

From Jan Wieck
Subject Re: Which one is faster?
Date
Msg-id 3D11C92E.F05D0E80@Yahoo.com
Whole thread Raw
In response to Re: Which one is faster?  (Bruce Momjian <pgman@candle.pha.pa.us>)
Responses Re: Which one is faster?  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-sql
Bruce Momjian wrote:
> 
> Wei Weng wrote:
> > Between Using Limit P, S or using a cursor to start from FETCH ABSOLUTE
> > S and FETCH NEXT for P times, which one is faster?
> 
> LIMIT is faster because it doesn't need to generate all the result, in
> some cases.

Neither does using a cursor need to generate all the results first. It's
a portal, which is an executor state on hold, and FETCH is implemented
as ExecutorRun() with the number of wanted result rows as limitation.
Since LIMIT generates internally one more result row than really wanted,
I don't think LIMIT would be much faster, but it's for sure less
portable.


Jan

-- 

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#================================================== JanWieck@Yahoo.com #


pgsql-sql by date:

Previous
From: Christoph Haller
Date:
Subject: psql -E Floating exception (coredump)
Next
From: Tom Lane
Date:
Subject: Re: psql -E Floating exception (coredump)