Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 97DDE6331C5 for ; Fri, 23 Apr 2010 19:54:12 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 15667-10 for ; Fri, 23 Apr 2010 22:53:55 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id E0FC8632FED for ; Fri, 23 Apr 2010 19:54:01 -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 o3NMrYg3018894; Fri, 23 Apr 2010 18:53:35 -0400 (EDT) To: Robert Haas cc: =?ISO-8859-1?Q?C=E9dric_Villemain?= , Vlad Arkhipov , pgsql-performance@postgresql.org Subject: Re: Optimization idea In-reply-to: References: <4BD0161A.4010908@dc.baikal.ru> <4BD0430C.1050308@2ndquadrant.com> <4BD10805.9060004@dc.baikal.ru> Comments: In-reply-to Robert Haas message dated "Fri, 23 Apr 2010 18:06:26 -0400" Date: Fri, 23 Apr 2010 18:53:34 -0400 Message-ID: <18893.1272063214@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.106 tagged_above=-10 required=5 tests=AWL=-0.196, BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201004/306 X-Sequence-Number: 38556 Robert Haas writes: > Hmm. We currently have a heuristic that we don't record a value as an > MCV unless it's more frequent than the average frequency. When the > number of MCVs is substantially smaller than the number of distinct > values in the table this is probably a good heuristic, since it > prevents us from bothering with the recording of some values that are > probably only marginally more interesting than other values we don't > have space to record. But if ndistinct is less than the stats target > we could in theory record every value we find in the MCVs table and > leave the histogram empty. Which, in fact, is exactly what we do. Cf analyze.c lines 2414ff (as of CVS HEAD). The heuristic you mention only gets applied after we determine that a complete MCV list won't fit. regards, tom lane