pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedWhich one is faster?
4+ messages / 3 participants
[nested] [flat]
* Which one is faster?
@ 2002-06-19 19:27 Wei Weng <wweng@kencast.com>
2002-06-19 20:34 ` Re: Which one is faster? Bruce Momjian <pgman@candle.pha.pa.us>
0 siblings, 1 reply; 4+ messages in thread
From: Wei Weng @ 2002-06-19 19:27 UTC (permalink / raw)
To: pgsql-sql
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?
Thanks!
--
Wei Weng
Network Software Engineer
KenCast Inc.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Which one is faster?
2002-06-19 19:27 Which one is faster? Wei Weng <wweng@kencast.com>
@ 2002-06-19 20:34 ` Bruce Momjian <pgman@candle.pha.pa.us>
2002-06-20 12:23 ` Re: Which one is faster? Jan Wieck <JanWieck@Yahoo.com>
0 siblings, 1 reply; 4+ messages in thread
From: Bruce Momjian @ 2002-06-19 20:34 UTC (permalink / raw)
To: Wei Weng <wweng@kencast.com>; +Cc: pgsql-sql
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.
--
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, Pennsylvania 19026
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Which one is faster?
2002-06-19 19:27 Which one is faster? Wei Weng <wweng@kencast.com>
2002-06-19 20:34 ` Re: Which one is faster? Bruce Momjian <pgman@candle.pha.pa.us>
@ 2002-06-20 12:23 ` Jan Wieck <JanWieck@Yahoo.com>
2002-06-20 16:10 ` Re: Which one is faster? Bruce Momjian <pgman@candle.pha.pa.us>
0 siblings, 1 reply; 4+ messages in thread
From: Jan Wieck @ 2002-06-20 12:23 UTC (permalink / raw)
To: Bruce Momjian <pgman@candle.pha.pa.us>; +Cc: Wei Weng <wweng@kencast.com>; 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 #
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Which one is faster?
2002-06-19 19:27 Which one is faster? Wei Weng <wweng@kencast.com>
2002-06-19 20:34 ` Re: Which one is faster? Bruce Momjian <pgman@candle.pha.pa.us>
2002-06-20 12:23 ` Re: Which one is faster? Jan Wieck <JanWieck@Yahoo.com>
@ 2002-06-20 16:10 ` Bruce Momjian <pgman@candle.pha.pa.us>
0 siblings, 0 replies; 4+ messages in thread
From: Bruce Momjian @ 2002-06-20 16:10 UTC (permalink / raw)
To: Jan Wieck <JanWieck@Yahoo.com>; +Cc: Wei Weng <wweng@kencast.com>; 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@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2002-06-20 16:10 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-06-19 19:27 Which one is faster? Wei Weng <wweng@kencast.com>
2002-06-19 20:34 ` Bruce Momjian <pgman@candle.pha.pa.us>
2002-06-20 12:23 ` Jan Wieck <JanWieck@Yahoo.com>
2002-06-20 16:10 ` Bruce Momjian <pgman@candle.pha.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox