Received: from candle.pha.pa.us (root@s5-03.ppp.op.net [209.152.195.67]) by hub.org (8.8.8/8.8.8) with ESMTP id PAA26027 for ; Wed, 14 Oct 1998 15:02:38 -0400 (EDT) (envelope-from maillist@candle.pha.pa.us) Received: (from maillist@localhost) by candle.pha.pa.us (8.9.0/8.9.0) id OAA29496; Wed, 14 Oct 1998 14:01:49 -0400 (EDT) From: Bruce Momjian Message-Id: <199810141801.OAA29496@candle.pha.pa.us> Subject: Re: [HACKERS] What about LIMIT in SELECT ? In-Reply-To: <000001bdf79b$e75d87e0$3b291f0a@taral> from Taral at "Oct 14, 1998 12:56: 0 pm" To: taral@mail.utexas.edu (Taral) Date: Wed, 14 Oct 1998 14:01:49 -0400 (EDT) Cc: lockhart@alumni.caltech.edu, jwieck@debis.com, eric@linux-hw.com, jeff@remapcorp.com, hackers@postgreSQL.org X-Mailer: ELM [version 2.4ME+ PL47 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit [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@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