Re: [HACKERS] What about LIMIT in SELECT ?

From: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
To: taral(at)mail(dot)utexas(dot)edu (Taral)
Cc: lockhart(at)alumni(dot)caltech(dot)edu, jwieck(at)debis(dot)com, eric(at)linux-hw(dot)com, jeff(at)remapcorp(dot)com, hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] What about LIMIT in SELECT ?
Date: 1998-10-14 18:01:49
Message-ID: 199810141801.OAA29496@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs pgsql-hackers

[Charset iso-8859-1 unsupported, filtering to ASCII...]
> > Thomas is correct on this. Vadim has run some tests, and with our
> > optimized psort() code, the in-memory sort is often faster than using
> > the index to get the tuple, because you are jumping all over the drive.
> > I don't remember, but obviously there is a break-even point where
> > getting X rows using the index on a table of Y rows is faster , but
> > getting X+1 rows on a table of Y rows is faster getting all the rows
> > sequentailly, and doing the sort.
> >
> > You would have to pick only certain queries(no joins, index matches
> > ORDER BY), take the number of rows requested, and the number of rows
> > selected, and figure out if it is faster to use the index, or a
> > sequential scan and do the ORDER BY yourself.
>
> Since a sort loads the data into memory anyway, how about speeding up the
> sort by using the index? Or does that take up too much memory? (approx 40%
> more than the data alone, I think)

Not sure you can do that. The index points to heap tuples/tids, and
though there are tids in the rows, you can't access them as tids in
memory.

--
Bruce Momjian | http://www.op.net/~candle
maillist(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-docs by date

  From Date Subject
Next Message Bruce Momjian 1998-10-14 18:27:05 Re: [HACKERS] What about LIMIT in SELECT ?
Previous Message Jan Wieck 1998-10-14 17:57:27 Re: [HACKERS] What about LIMIT in SELECT ?

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas G. Lockhart 1998-10-14 18:13:48 Re: [DOCS] Re: [HACKERS] Alternative to LIMIT in SELECT ?
Previous Message Thomas G. Lockhart 1998-10-14 17:59:41 Re: [HACKERS] PostgreSQL v6.4 BETA2 ...