X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 29751D79CA for ; Fri, 26 Aug 2005 12:47: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 21828-05 for ; Fri, 26 Aug 2005 15:46:57 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id AADCFD79BC for ; Fri, 26 Aug 2005 12:46:55 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7QFkX2B009502; Fri, 26 Aug 2005 11:46:33 -0400 (EDT) To: Mark Kirkwood Cc: Tobias Brox , pgsql-performance@postgresql.org Subject: Re: Limit + group + join In-reply-to: <430E85ED.60109@paradise.net.nz> References: <20050826002709.GK10328@tobias.lan> <430E85ED.60109@paradise.net.nz> Comments: In-reply-to Mark Kirkwood message dated "Fri, 26 Aug 2005 15:01:01 +1200" Date: Fri, 26 Aug 2005 11:46:33 -0400 Message-ID: <9501.1125071193@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] X-Spam-Level: X-Archive-Number: 200508/444 X-Sequence-Number: 14191 Mark Kirkwood writes: > What is interesting is why this plan is being rejected... Which PG version are you using exactly? That mistake looks like an artifact of the 8.0 "fuzzy plan cost" patch, which we fixed recently: http://archives.postgresql.org/pgsql-committers/2005-07/msg00474.php But Tobias wasn't happy with 7.4 either, so I'm not sure that the fuzzy cost issue explains his results. As far as the "desc" point goes, the problem is that mergejoins aren't capable of dealing with backward sort order, so a merge plan isn't considered for that case (or at least, it would have to have a sort after it, which pretty much defeats the point for a fast-start plan). I have some ideas about fixing this but it won't happen before 8.2. regards, tom lane