Re: Which one is faster?

From: Jan Wieck <JanWieck(at)Yahoo(dot)com>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Wei Weng <wweng(at)kencast(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Which one is faster?
Date: 2002-06-20 12:23:10
Message-ID: 3D11C92E.F05D0E80@Yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)Yahoo(dot)com #

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Denis 2002-06-20 13:23:53 slow DELETE queries
Previous Message Christoph Haller 2002-06-20 10:38:53 psql -E <dbname> Floating exception (coredump)