Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h5VhO-0000Xj-8A for pgsql-hackers@arkaria.postgresql.org; Sun, 17 Mar 2019 13:19:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h5VhM-0004NV-Ue for pgsql-hackers@arkaria.postgresql.org; Sun, 17 Mar 2019 13:19:32 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1h5VhM-0004NO-NL for pgsql-hackers@lists.postgresql.org; Sun, 17 Mar 2019 13:19:32 +0000 Received: from mail-lj1-x22b.google.com ([2a00:1450:4864:20::22b]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h5VhJ-0004Rf-Ir for pgsql-hackers@postgresql.org; Sun, 17 Mar 2019 13:19:32 +0000 Received: by mail-lj1-x22b.google.com with SMTP id y6so3404572ljd.12 for ; Sun, 17 Mar 2019 06:19:29 -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=YRNzjhKzH1LmrZX94JeyM5BU3aE4qRsqsuCYVcPtHj4=; b=JQCOyHy9suM9tN5wFtcF0n39xqY4kqPSM50AjQ324S82pCCeLKD9GW4O+1L6A7UANx vW9dT0GWVsPc2zAnhtQg3LIeS0rpc/Ipfl3iRceVdPu2Z5i2JTWR0WLQCzTowu+q6OaG BFiEUWEvWzimzQPXgAYAl9jpRUCCmE13eM3vOnlVgewk1cy/HTXN9x9RPkcYo/3qURuH 7ee09YlR4/bYvs/UJWadtucgO5JEoElQPnxdC+EtEJYj1xnX9s0PMDlAssePu/3XeqPJ VHyaeiiWoRjMHuKtOQ698XmSI2jOQAjIPh6lFiqCYhRylbXyeYK10169Kjoi4Iqp8kSP Uaug== 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=YRNzjhKzH1LmrZX94JeyM5BU3aE4qRsqsuCYVcPtHj4=; b=nTlCKav7CKl/K1k7irusS7I56DWifQlLRbg6UsJCRnJq1TtIRgystvSY7RxvKotfEY 2i5uUfIOs8+6LNKQ9x4U9xXbgu0QKnrI8GqaV9gKvOm2MaHQH/4kND35XeCZ0SySn1/u mnU61Nv+20n1lvoo2i+Xu9uAkNiQUlxAl+9MfkiPNT/aDnejdvSkS20rQ3MXPm94GFHd 2DQe4vE0jwBBKV7zaNzsT6eFNlZGIJSUEwOGJ9gBPr/9ewer8HaDBJ0dJg9TNA0NFYdW MiWh32Em+cEZ0F4bzjF8ohDHGXuooumtOgQ2ktBp0r9VMJq2Ro56FKH4FYjonwX2iYYZ jm0g== X-Gm-Message-State: APjAAAW68DU6TrH6jvQITvMZwtpyzh/ppq7QwydMq+oNqIguMM+og8VI GxwTyErjx2+L9T2V/xh99sKQlKTMlIVBH8L7o9BvQGVvajq7T8y08zX3xJTc12kk/rcw92f+jrS /HHsnqHKq/9YnWVJ2hbERvLw9p81hwdGgft8UvFHHwf7EAnErUicbNS0O0uTnMEfsN6v2NnXMHI o+fg1DJtgHXT0/gtaC X-Google-Smtp-Source: APXvYqyszaAa1NOX+ZjxfwjdddqZzfR2hFG1GIZKwa1z5jc7YTr9sm+B7K8sCt8akri66nUlEsi+uQ== X-Received: by 2002:a2e:899a:: with SMTP id c26mr6151647lji.192.1552828767920; Sun, 17 Mar 2019 06:19:27 -0700 (PDT) Received: from [10.137.0.18] (178-78-220-132.customers.ownit.se. [178.78.220.132]) by smtp.gmail.com with ESMTPSA id z26sm563862ljz.66.2019.03.17.06.19.26 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Sun, 17 Mar 2019 06:19:27 -0700 (PDT) Subject: Re: [HACKERS] PATCH: multivariate histograms and MCV lists To: Dean Rasheed Cc: Kyotaro HORIGUCHI , David Rowley , Alvaro Herrera , Michael Paquier , Andres Freund , Thomas Munro , Bruce Momjian , Mark Dilger , PostgreSQL Hackers References: <19f76496-dcf3-ccea-dd82-26fbed57b8f5@2ndquadrant.com> <20190313.131951.178195776.horiguchi.kyotaro@lab.ntt.co.jp> <20190314.205623.235434357.horiguchi.kyotaro@lab.ntt.co.jp> <37ce47c5-e0cf-c6d3-6923-6b8cfd1cc6b1@2ndquadrant.com> From: Tomas Vondra Message-ID: <2f373a2e-b014-64b2-6e20-5c6276ed2c2e@2ndquadrant.com> Date: Sun, 17 Mar 2019 14:19:25 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 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 3/17/19 1:14 PM, Dean Rasheed wrote: > On Sat, 16 Mar 2019 at 23:44, Tomas Vondra wrote: >>> >>> 16). This regression test fails for me: >>> >>> @@ -654,11 +654,11 @@ >>> -- check change of unrelated column type does not reset the MCV statistics >>> ALTER TABLE mcv_lists ALTER COLUMN d TYPE VARCHAR(64); >>> SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = >>> 1 AND b = ''1'''); >>> estimated | actual >>> -----------+-------- >>> - 50 | 50 >>> + 11 | 50 >>> (1 row) >>> >>> Maybe that's platform-dependent, given what you said about >>> reltuples/relpages being reset. An easy workaround for this would be >>> to modify this test (and perhaps the one that follows) to just query >>> pg_statistic_ext to see if the MCV statistics have been reset. >>> >> >> Ah, sorry for not explaining this bit - the failure is expected, due to >> the reset of relpages/reltuples I mentioned. We do keep the extended >> stats, but the relsize estimate changes a bit. It surprised me a bit, >> and this test made the behavior apparent. The last patchset included a >> piece that changes that - if we decide not to change this, I think we >> can simply accept the actual output. >> > > I don't think changing the way reltuples is reset ought to be within > the scope of this patch. There might be good reasons for it being the > way it is. Perhaps open a discussion on a separate thread? > Agreed, will do. > As far as this test goes, how about just doing this: > > -- check change of unrelated column type does not reset the MCV statistics > ALTER TABLE mcv_lists ALTER COLUMN d TYPE VARCHAR(64); > SELECT stxmcv IS NOT NULL AS has_mcv > FROM pg_statistic_ext WHERE stxrelid = 'mcv_lists'::regclass; > > -- check change of column type resets the MCV statistics > ALTER TABLE mcv_lists ALTER COLUMN c TYPE numeric; > SELECT stxmcv IS NOT NULL AS has_mcv > FROM pg_statistic_ext WHERE stxrelid = 'mcv_lists'::regclass; > OK, that's probably the best thing we can do. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services