Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id D74A41336B42 for ; Wed, 10 Nov 2010 18:43:55 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 13396-03 for ; Wed, 10 Nov 2010 22:43:48 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from gw.wicourts.gov (gwmta.wicourts.gov [165.219.244.99]) by mail.postgresql.org (Postfix) with ESMTP id 77A74133616B for ; Wed, 10 Nov 2010 18:43:48 -0400 (AST) Received: from Courts-MTA by gw.wicourts.gov with Novell_GroupWise; Wed, 10 Nov 2010 16:43:47 -0600 Message-Id: <4CDACBBF020000250003755B@gw.wicourts.gov> X-Mailer: Novell GroupWise Internet Agent 8.0.1 Date: Wed, 10 Nov 2010 16:43:43 -0600 From: "Kevin Grittner" To: "Robert Haas" Cc: ,"Tom Lane" Subject: Re: anti-join chosen even when slower than old plan References: <4CD9663502000025000374B1@gw.wicourts.gov> <20961.1289347680@sss.pgh.pa.us> <4CDA62C60200002500037512@gw.wicourts.gov> In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-4.21 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201011/139 X-Sequence-Number: 41163 Robert Haas wrote: > Wow. That's fascinating, and if you don't mind, I might mention > this potential problem in a future talk at some point. I don't mind at all. > For example, in your case, it would be sufficient to estimate the > amount of data that a given query is going to grovel through and > then applying some heuristic to choose values for random_page_cost > and seq_page_cost based on the ratio of that value to, I don't > know, effective_cache_size. That's where my day-dreams on the topic have been starting. > Unfortunately, to know how much data we're going to grovel > through, we need to know the plan; and to decide on the right > plan, we need to know how much data we're going to grovel through. And that's where they've been ending. The only half-sane answer I've thought of is to apply a different cost to full-table or full-index scans based on the ratio with effective cache size. A higher cost for such scans is something which I've already postulated might be worthwhile for SSI, because of the increased risk of rw-conflicts which could ultimately contribute to serialization failures -- to attempt to model, at least in some crude way, the costs associated with transaction retry. -Kevin