Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 1289F9F9D41 for ; Thu, 4 Oct 2007 18:17:00 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 05364-05-6 for ; Thu, 4 Oct 2007 18:16:50 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from newmail.silentmedia.com (earth.silentmedia.com [216.254.19.12]) by postgresql.org (Postfix) with ESMTP id 8104D9F94C2 for ; Thu, 4 Oct 2007 18:16:53 -0300 (ADT) Received: by newmail.silentmedia.com (Postfix, from userid 99) id EEDEA35E3C5; Thu, 4 Oct 2007 14:16:49 -0700 (PDT) Received: from GRD (GRD [10.125.42.6]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by newmail.silentmedia.com (Postfix) with ESMTP id B3DE935E3C2; Thu, 4 Oct 2007 14:16:49 -0700 (PDT) Date: Thu, 4 Oct 2007 14:16:49 -0700 (PDT) From: Ben X-X-Sender: bench@localhost.localdomain To: Tom Lane cc: Simon Riggs , pgsql-performance@postgresql.org Subject: Re: quickly getting the top N rows In-Reply-To: <21101.1191531893@sss.pgh.pa.us> Message-ID: References: <20071004141411.9509fe66.wmoran@collaborativefusion.com> <3785.1191523930@sss.pgh.pa.us> <1191529385.4223.231.camel@ebony.site> <21101.1191531893@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200710/51 X-Sequence-Number: 27073 On Thu, 4 Oct 2007, Tom Lane wrote: > There's some limited smarts in there about deciding that leading columns > of an index don't matter to the sort ordering if they're constrained to > just one value by the query. But it doesn't catch the case you need, > which is that columns of an ORDER BY request are no-ops when they're > constrained to just one value. Oh, no, that explains it perfectly, because that's precisely the case I have - I dropped the columns from the ordering, but not the where clause. Thanks, now I understand the current behavior.