Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id EC4F2B5DC66 for ; Mon, 26 Sep 2011 21:39:35 -0300 (ADT) 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 38223-04 for ; Tue, 27 Sep 2011 00:39:29 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 6D1C3B5DC32 for ; Mon, 26 Sep 2011 21:39:24 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p8R0dNhm007046; Mon, 26 Sep 2011 20:39:23 -0400 (EDT) To: Craig Ringer cc: Craig James , pgsql-performance@postgresql.org Subject: Re: Performance Anomaly with "col in (A, B)" vs. "col = A OR col = B" ver. 9.0.3 In-reply-to: <4E811441.6060604@ringerc.id.au> References: <9594.1317056871@sss.pgh.pa.us> <4E80B3F9.8070001@emolecules.com> <10130.1317058511@sss.pgh.pa.us> <4E811441.6060604@ringerc.id.au> Comments: In-reply-to Craig Ringer message dated "Tue, 27 Sep 2011 08:09:37 +0800" Date: Mon, 26 Sep 2011 20:39:23 -0400 Message-ID: <7045.1317083963@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.781 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-0.504, URIBL_SBL=1.623 X-Spam-Level: X-Archive-Number: 201109/376 X-Sequence-Number: 45152 Craig Ringer writes: > This has me wondering about putting together a maintenance/analysis tool > that generates and captures stats from several ANALYZE runs and compares > them to see if they're reasonably consistent. It then re-runs with > higher targets as a one-off, again to see if the stats agree, before > restoring the targets to defaults. The tool could crunch comparisons of > the resulting stats and warn about tables or columns where the default > stats targets aren't sufficient. It would certainly be useful to have such a tool, but I suspect it's easier said than done. The problem is to know whether the queries on that table are particularly sensitive to having better stats. I think we've largely solved issues having to do with the quality of the histogram (eg, what fraction of the table has values falling into some range), and the remaining trouble spots have to do with predicting the frequency of specific values that are too infrequent to have made it into the most-common-values list. Enlarging the MCV list helps not so much by getting these long-tail values into the MCV list --- they probably still aren't there --- as by allowing us to tighten the upper bound on what the frequency of an unrepresented value must be. So what you have to ask is how many queries care about that. Craig James' example query in this thread is sort of a worst case, because the values it's searching for are in fact not in the table at all. regards, tom lane