Received: from dsh.de (firewall-user@neptun.sns-felb.debis.de [53.122.101.2]) by hub.org (8.8.8/8.8.8) with ESMTP id NAA16391 for ; Wed, 14 Oct 1998 13:51:31 -0400 (EDT) (envelope-from wieck@sapserv.debis.de) Received: by dsh.de; id TAA03418; Wed, 14 Oct 1998 19:50:18 +0200 (MET DST) Received: from dshmail.dsh.de(53.47.15.3) by neptun.dsh.de via smap (3.2) id xma003369; Wed, 14 Oct 98 19:49:51 +0200 Received: from mail1.hh1.dsh.de (mail1.hh1.dsh.de [53.47.9.5]) by dshmail.dsh.de (8.8.7/8.8.7) with ESMTP id TAA16746; Wed, 14 Oct 1998 19:47:14 +0200 (MET DST) Received: from mars.SAPserv.Hamburg.dsh.de (root@mail5.hh1.dsh.de [53.2.168.17]) by mail1.hh1.dsh.de (8.8.7/8.8.7) with SMTP id TAA23570; Wed, 14 Oct 1998 19:49:32 +0200 Received: from orion.SAPserv.Hamburg.dsh.de by mars.SAPserv.Hamburg.dsh.de with smtp for <> id m0zTSdF-000B5AC; Wed, 14 Oct 98 17:14 MET DST Received: by orion.SAPserv.Hamburg.dsh.de for lockhart@alumni.caltech.edu id m0zTVAt-000EBRC; Wed, 14 Oct 98 19:57 MET DST Message-Id: From: jwieck@debis.com (Jan Wieck) Subject: Re: [HACKERS] What about LIMIT in SELECT ? To: maillist@candle.pha.pa.us (Bruce Momjian) Date: Wed, 14 Oct 1998 19:57:27 +0200 (MET DST) Cc: lockhart@alumni.caltech.edu, jwieck@debis.com, eric@linux-hw.com, jeff@remapcorp.com, hackers@postgreSQL.org Reply-To: jwieck@debis.com (Jan Wieck) In-Reply-To: <199810141721.NAA28746@candle.pha.pa.us> from "Bruce Momjian" at Oct 14, 98 01:21:15 pm X-Mailer: ELM [version 2.4 PL25] Content-Type: text > But, you are correct that certain cases where in index is already being > used on a query, you could just skip the sort IF you used the index to > get the rows from the base table. Especially in the case where SELECT ... WHERE key > 'val' ORDER BY key; creates a Sort->IndexScan plan. The index scan already jumps around on the disc to collect the sorts input and the sort finally returns exactly the same output (if the used index is only on key). And this is the case for large tables. The planner first decides to use an index scan due to the WHERE clause and later it notices the ORDER BY clause and creates a sort over the scan. I'm actually hacking around on it to see what happens if I suppress the sort node in some cases. Jan -- #======================================================================# # It's easier to get forgiveness for being wrong than for being right. # # Let's break this rule - forgive me. # #======================================== jwieck@debis.com (Jan Wieck) #