Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f0XVI-0005y1-5T for pgsql-hackers@arkaria.postgresql.org; Mon, 26 Mar 2018 19:10:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f0XVG-0004D2-7N for pgsql-hackers@arkaria.postgresql.org; Mon, 26 Mar 2018 19:09:58 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f0XVF-0004Cs-Sq for pgsql-hackers@lists.postgresql.org; Mon, 26 Mar 2018 19:09:58 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1f0XVB-00057S-Ks for pgsql-hackers@postgresql.org; Mon, 26 Mar 2018 19:09:57 +0000 Received: by mail-wm0-x244.google.com with SMTP id x82so17391152wmg.1 for ; Mon, 26 Mar 2018 12:09:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=BdZhfK66UlIUef869qzM6GPGX0GeeJ0OAxTGbleQTS8=; b=iGdrMug7nA+0gygY+MDaXkPYIIt8Qs1maKRuTyRFxNnqkW9SoBO5zORd+icHLpZ7v2 VpL7VSbLXHDFUIa+KNg6Ed2Cu75MRUTxhZ+xT4q+DYKvL0eMHeCnZYwoizopc7mbimJt uoYui15PUbeU0aP8YdRr1+XMP8Ti3dVdFkrtnnwfy+HzJYS8puAxxK/vJmJtfRtJ32XA nG0MaYL7BS6Roq+UzX24DPKXyBY/56XSEQrrsMC9ecYwlTqpE+TjCmK+CsEvTXM+qcMT e9syhIH/0rJTyK4QU4AT0iD4xCLt7INDPlS5tzmG51tu3yiaUI84RNs1w73iLJn1Mm3i ByXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=BdZhfK66UlIUef869qzM6GPGX0GeeJ0OAxTGbleQTS8=; b=IpMVi1EOYuZt04PsF81+vqIlp0+ZP73BG1vhCDgTnSu35M9y51U5TRlnfZp+N6h3+j HGNx7mcgEihrtznPqpitZm/KdkX4idZvRIIC/BvB4boKAdVWVBsTpSOOO89fA9spQDRN i+3My+yklIDevxrbcg1CDsqcw85fRPgP2QdjYmJfj+MGeSdGXjyVfkuX4Ex+M0yWDcK5 VdCrM8ADhr0omEr37jfxHN+EPYe2EXPeCXX2oWORarng/Dhsf3sN/cSdNt7dVYHBDSCU U1CPKrprde4/HYWfEiWJkfL3CY9k8fdVqCzL3b7p4cKOkO8seVLjjCH8ZpuqyHbxFHuk ZmXw== X-Gm-Message-State: AElRT7E4mybAldh9gT2GqkUB5wVsyBVGO83R0iG8fc9NLAJpMgxaiRNv ZNq6e69eOX6coqmDA/XiRmsYScdGFia2lQBiZcEMceNDv5HcPS1kTpud1AkLWb6nYtJ4wWtaIKk zAjUCPz9HiUGhcd2V9kHwFz9stMEdzzqHwwD9vOfLM08tDLF/oYUxUn2XHKXJWW5IgWgvC9ZLiv dH3CmUG0MN X-Google-Smtp-Source: AG47ELtavo0oxh/78VHMScuQAte1zcbxOIdQesMnzS+TRy4ObyI+sK9mZixJkG0U8bkMtIwbL9eoaQ== X-Received: by 10.28.184.8 with SMTP id i8mr17942510wmf.52.1522091392316; Mon, 26 Mar 2018 12:09:52 -0700 (PDT) Received: from [10.137.2.19] (ip-78-102-97-226.net.upcbroadband.cz. [78.102.97.226]) by smtp.gmail.com with ESMTPSA id b40sm267281wrb.88.2018.03.26.12.09.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Mar 2018 12:09:51 -0700 (PDT) Subject: Re: [HACKERS] PATCH: multivariate histograms and MCV lists To: Dean Rasheed Cc: Alvaro Herrera , Andres Freund , Thomas Munro , Mark Dilger , Adrien Nayrat , Pg Hackers References: <20180310171906.gd6vyz6hnou2n3h7@alvherre.pgsql> <850c3b6b-2641-496c-4efc-500c720f7260@2ndquadrant.com> <387341b0-e4bb-e27d-8c68-afaef8189c15@2ndquadrant.com> From: Tomas Vondra Message-ID: <66f652d0-030a-2f53-df85-effb272a5919@2ndquadrant.com> Date: Mon, 26 Mar 2018 21:09:47 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 03/26/2018 06:21 PM, Dean Rasheed wrote: > On 26 March 2018 at 14:08, Tomas Vondra wrote: >> On 03/26/2018 12:31 PM, Dean Rasheed wrote: >>> A wider concern I have is that I think this function is trying to be >>> too clever by only resetting selected stats. IMO it should just reset >>> all stats unconditionally when the column type changes, which would >>> be consistent with what we do for regular stats. >>> >> The argument a year ago was that it's more plausible that the semantics >> remains the same. I think the question is how the type change affects >> precision - had the type change in the opposite direction (int to real) >> there would be no problem, because both ndistinct and dependencies would >> produce the same statistics. >> >> In my experience people are far more likely to change data types in a >> way that preserves precision, so I think the current behavior is OK. > > Hmm, I don't really buy that argument. Altering a column's type > allows the data in it to be rewritten in arbitrary ways, and I don't > think we should presume that the statistics will still be valid just > because the user *probably* won't do something that changes the data > much. > Maybe, I can only really speak about my experience, and in those cases it's usually "the column is an INT and I need a FLOAT". But you're right it's not guaranteed to be like that, perhaps the right thing to do is resetting the stats. Another reason to do that might be consistency - resetting just some of the stats might be surprising for users. And we're are already resetting per-column stats on that column, so the users running ANALYZE anyway. BTW in my response I claimed this: > > The other reason is that when reducing precision, it generally > enforces the dependency (you can't violate functional dependencies or > break grouping by merging values). So you will have stale stats with > weaker dependencies, but it's still better than not having any.> That's actually bogus. For example for functional dependencies, it's important on which side of the dependency we reduce precision. With (a->b) dependency, reducing precision of "b" does indeed strengthen it, but reducing precision of "a" does weaken it. So I take that back. So, I'm not particularly opposed to just resetting extended stats referencing the altered column. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services