X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 191D4539F6 for ; Tue, 26 Apr 2005 02:42:00 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 79386-01 for ; Tue, 26 Apr 2005 05:41:55 +0000 (GMT) Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) by svr1.postgresql.org (Postfix) with ESMTP id 0B084538C0 for ; Tue, 26 Apr 2005 02:41:53 -0300 (ADT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id 0923C30E89; Tue, 26 Apr 2005 07:40:27 +0200 (MET DST) From: Ron Mayer X-Newsgroups: pgsql.performance Subject: Re: half the query time in an unnecessary(?) sort? Date: Mon, 25 Apr 2005 22:45:57 -0700 Organization: Hub.Org Networking Services Lines: 24 Message-ID: <426DD595.1040608@cheapcomplexdevices.com> References: <426D4FA1.1050000@cheapcomplexdevices.com> <200504251511.41949.josh@agliodbs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@news.hub.org To: Josh Berkus User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en In-Reply-To: <200504251511.41949.josh@agliodbs.com> To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Archive-Number: 200504/688 X-Sequence-Number: 12085 Josh Berkus wrote: [quoted out of order] >Ron, > > Looking at your analyze, though, I think it's not the sort that's taking the > time as it is that the full sorted entity_id column won't fit in work_mem. > Try increasing it? Yup, that indeed fixed this particular query since neither table was particularly large. > It still has to sort because the clustering isn't guarenteed to be 100%. I guess I was contemplating whether or not there are some conditions where it could be 100% (perhaps combined with Hannu's read only table speculation). > However, such sorts should be very quick as they have little work to do. True, so long as the table can fit in work-mem. For much larger tables IMHO it'd be nice to be able to simply do a seq-scan on them if there were some way of knowing that they were sorted.