Re: Which one is faster?

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

Jan Wieck wrote:
> 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.

Oh, I thought the portal had to be materialized before returning a row.
Thanks.

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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Alla 2002-06-20 17:15:53 rowtype and ecpg
Previous Message Manfred Koizar 2002-06-20 15:01:13 Re: slow DELETE queries