Received: from mail.utexas.edu (wb2-a.mail.utexas.edu [128.83.126.136]) by hub.org (8.8.8/8.8.8) with SMTP id NAA16782 for ; Wed, 14 Oct 1998 13:56:11 -0400 (EDT) (envelope-from taral@mail.utexas.edu) Received: (qmail 3025 invoked by uid 0); 14 Oct 1998 17:56:04 -0000 Received: from dial-42-5.ots.utexas.edu (HELO taral) (128.83.111.213) by umbs-smtp-2 with SMTP; 14 Oct 1998 17:56:04 -0000 From: "Taral" To: "Bruce Momjian" , "Thomas G. Lockhart" Cc: , , , Subject: RE: [HACKERS] What about LIMIT in SELECT ? Date: Wed, 14 Oct 1998 12:56:00 -0500 Message-ID: <000001bdf79b$e75d87e0$3b291f0a@taral> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook 8.5, Build 4.71.2173.0 In-Reply-To: <199810141721.NAA28746@candle.pha.pa.us> X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3155.0 Importance: Normal > 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) TAra