Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 3A576133798E for ; Thu, 11 Nov 2010 15:16:11 -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 01796-06 for ; Thu, 11 Nov 2010 19:16:04 +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 A6CF31336971 for ; Thu, 11 Nov 2010 15:16:03 -0400 (AST) Received: from Courts-MTA by gw.wicourts.gov with Novell_GroupWise; Thu, 11 Nov 2010 13:16:02 -0600 Message-Id: <4CDBEC8B02000025000375CF@gw.wicourts.gov> X-Mailer: Novell GroupWise Internet Agent 8.0.1 Date: Thu, 11 Nov 2010 13:15:55 -0600 From: "Kevin Grittner" To: "Robert Haas" , "Tom Lane" Cc: "pgsql-performance@postgresql.org" , "Mladen Gogala" 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> <4CDACBBF020000250003755B@gw.wicourts.gov> <4CDB7BAA.7020506@vmsinfo.com> <4CDBB0A40200002500037571@gw.wicourts.gov> <18450.1289499783@sss.pgh.pa.us><18450.1289499783@sss.pgh.pa.us> <19088.1289501929@sss.pgh.pa.us> In-Reply-To: <19088.1289501929@sss.pgh.pa.us> 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/162 X-Sequence-Number: 41186 Tom Lane wrote: > BTW ... on reflection it seems that this would *not* solve the > use-case Kevin described at the start of this thread. What he's > got AIUI is some large tables whose recent entries are well- > cached, and a lot of queries that tend to hit that well-cached > portion, plus a few queries that hit the whole table and so see > largely-not-cached behavior. We can't represent that very well > with a caching knob at the table level. Either a high or a low > setting will be wrong for one set of queries or the other. Exactly right. > The most practical solution for his case still seems to be to > twiddle some GUC or other locally in the maintenance scripts that > do the full-table-scan queries. Yes, that works fine. The thread spun off in this speculative direction because I started thinking about whether there was any reasonable way for PostgreSQL to automatically handle such things without someone having to notice the problem and do the per-script tuning. I don't know whether any of the ideas thus spawned are worth the effort -- it's not a situation I find myself in all that often. I guess it could be considered an "ease of use" feature. > Unfortunately we don't have an equivalent of per-session SET (much > less SET LOCAL) for per-relation attributes. Not sure if we want > to go there. Besides the "fully-scanned object size relative to relation size costing adjustment" idea, the only one which seemed to be likely to be useful for this sort of issue was the "costing factors by user ID" idea -- the interactive queries hitting the well-cached portion of the tables are run through a read-only user ID, while the weekly maintenance scripts (obviously) are not. With the settings I initially had assigned to the cluster the maintenance scripts would never have seen this issue; it was tuning to resolve end-user complaints of slowness in the interactive queries which set up the conditions for failure, and if I'd had per-user settings, I probably would have (and definitely *should* have) used them. FWIW, I can certainly see the potential of some other ideas which came up on the thread; what might have seemed like antipathy toward them was more of an attempt to point out that they would not have helped at all with the problem which started this thread. -Kevin