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 92B71D7CF5 for ; Fri, 26 Aug 2005 20:31:12 -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 23093-09 for ; Fri, 26 Aug 2005 23:31:11 +0000 (GMT) Received: from linda-4.paradise.net.nz (bm-4a.paradise.net.nz [202.0.58.23]) by svr1.postgresql.org (Postfix) with ESMTP id 05398D7CD9 for ; Fri, 26 Aug 2005 20:31:10 -0300 (ADT) Received: from smtp-1.paradise.net.nz (smtp-1a.paradise.net.nz [202.0.32.194]) by linda-4.paradise.net.nz (Paradise.net.nz) with ESMTP id <0ILU00KG2RWEZ8@linda-4.paradise.net.nz> for pgsql-performance@postgresql.org; Sat, 27 Aug 2005 11:29:02 +1200 (NZST) Received: from [192.168.1.11] (218-101-14-104.paradise.net.nz [218.101.14.104]) by smtp-1.paradise.net.nz (Postfix) with ESMTP id 5F34E82B87; Sat, 27 Aug 2005 11:29:02 +1200 (NZST) Date: Sat, 27 Aug 2005 11:29:01 +1200 From: Mark Kirkwood Subject: Re: Limit + group + join In-reply-to: <9501.1125071193@sss.pgh.pa.us> To: Tom Lane Cc: Tobias Brox , pgsql-performance@postgresql.org Message-id: <430FA5BD.2070407@paradise.net.nz> MIME-version: 1.0 Content-type: text/plain; format=flowed; charset=ISO-8859-1 Content-transfer-encoding: 7bit X-Accept-Language: en-us, en User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050726) References: <20050826002709.GK10328@tobias.lan> <430E85ED.60109@paradise.net.nz> <9501.1125071193@sss.pgh.pa.us> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.147 required=5 tests=[AWL=0.147] X-Spam-Level: X-Archive-Number: 200508/462 X-Sequence-Number: 14209 Tom Lane wrote: > 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 > Right on - 8.0.3 (I might look at how CVS tip handles this, could be interesting). > 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. That doesn't explain why the nested loop is being kicked tho', or have I missed something obvious? - it's been known to happen :-)... Cheers Mark