Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lT87L-0005hT-Uo for pgsql-hackers@arkaria.postgresql.org; Sun, 04 Apr 2021 19:09:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lT87J-0003c9-S6 for pgsql-hackers@arkaria.postgresql.org; Sun, 04 Apr 2021 19:09:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lT87J-0003c2-H4 for pgsql-hackers@lists.postgresql.org; Sun, 04 Apr 2021 19:09:01 +0000 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lT87F-00028d-Ie for pgsql-hackers@lists.postgresql.org; Sun, 04 Apr 2021 19:09:00 +0000 Received: by mail-ej1-x635.google.com with SMTP id hq27so14150107ejc.9 for ; Sun, 04 Apr 2021 12:08:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb-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=e3gwEQhoz86BfOZ/Xjs5eI6qknXi2WKD3rzFvDNd1S8=; b=nNDX42aIiyhZFZULDwN78InNSvBbsH8rq6egvDfJ+uXEK1zj8Sdc+rlDCamn8sKcTn 6P65ZPUxcR7xDGqcgQdLNNPV1pJckpGka84GtUJGQoQe17zgo3RbdDREP7AWbRyXewTl iLIaMgxgARifoHuy7uOsUfgl8wzF1ZrUDwL5sJxC90KphZQaGxs0CxexKB+CWV/+oThx kxtoH9W4i7OpUQPaKP74DgRN6k0huUOcg+kw6eTivPI4sEyAyGhi++q7/rbFU6hfUbeI 13hpc6qAryvXAm4v9LHdfv4mmommA5MZXfj/snU+sUQYiOJsqrgyaEGK4TtxhesxaklZ 8cag== 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=e3gwEQhoz86BfOZ/Xjs5eI6qknXi2WKD3rzFvDNd1S8=; b=Ej3GPeKYcQFTuaILNf62BWfEHcq+KwvwFWedJxTru6f4bGm4OyEkru9c7zBCBAnK/d t1RvGF1I5t4SsaWIN40T0EilhByU9GiO/EMnCk2iHSgdWUoVoQEtqVqsKt+KXCqvHPUB PPNCo6vVzS29GQgXaujCFwwOn5FIa98AVoHmFVRHUVhHQ26Ws32JZylkWq1+lFT40Rof EvmWTuOxl5R26o/qhQJoifLPGQfwmU/fHbK1aoo6aBIdeIlHy/p4XM8mvqYHGuxSbrbM mK0pME7dR6PJQQDabHoFEuymXG9a9++jMNNn4MugbVTY0lksjYnrILebq5ctqswEz3lP XBHA== X-Gm-Message-State: AOAM530CfzJQSOju5O4vxKsfX+3rUrUUNJc5fYu16CgweUx5ZSRgyu1l GiDGliZw3G4wjqjDHKRTyHa+mhwDXYkmwGSR6wYxSwqE/ZDkaDdMI1DQwLSgRT2XyXROyca2eh9 65EZS2oAK4BZ/mLTVYcb0L2Sc764KNDdEFgDx2nStj33dVRbQ944NJQRJxXdEoX52seDf1RdZpc D8vemdK3pMM6ehITAvm2INEGgbQNgqyJpTC8ehve0kRWbmbFJEZudn X-Google-Smtp-Source: ABdhPJyFE5zfa68i6qyP3eb5Rt6wfAShtx8pOpRLVjLcHRd/cPayvKoW6h8gpUl47g3DP84OdtJOpA== X-Received: by 2002:a17:906:400b:: with SMTP id v11mr24832843ejj.194.1617563335393; Sun, 04 Apr 2021 12:08:55 -0700 (PDT) Received: from [10.137.0.20] (ip-86-49-253-127.net.upcbroadband.cz. [86.49.253.127]) by smtp.gmail.com with ESMTPSA id y2sm7094474ejf.30.2021.04.04.12.08.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 04 Apr 2021 12:08:54 -0700 (PDT) Subject: Re: Autovacuum on partitioned table (autoanalyze) To: Alvaro Herrera , yuzuko Cc: David Steele , Kyotaro Horiguchi , Justin Pryzby , Daniel Gustafsson , Amit Langote , Masahiko Sawada , Laurenz Albe , PostgreSQL Hackers , Greg Stark References: <20210403194234.GA18917@alvherre.pgsql> From: Tomas Vondra Message-ID: <73dc10a0-cc6a-5d12-7f0f-e7410fa76d9c@enterprisedb.com> Date: Sun, 4 Apr 2021 21:08:51 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20210403194234.GA18917@alvherre.pgsql> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 4/3/21 9:42 PM, Alvaro Herrera wrote: > Thanks for the quick rework. I like this design much better and I think > this is pretty close to committable. Here's a rebased copy with some > small cleanups (most notably, avoid calling pgstat_propagate_changes > when the partition doesn't have a tabstat entry; also, free the lists > that are allocated in a couple of places). > > I didn't actually verify that it works. > Yeah, this approach seems much simpler, I think. That being said, I think there's a couple issues: 1) I still don't understand why inheritance and declarative partitioning are treated differently. Seems unnecessary nad surprising, but maybe there's a good reason? 2) pgstat_recv_tabstat Should it really reset changes_since_analyze_reported in both branches? AFAICS if the "found" branch does this tabentry->changes_since_analyze_reported = 0; that means we lose the counter any time tabstats are received, no? That'd be wrong, because we'd propagate the changes repeatedly. 3) pgstat_recv_analyze Shouldn't it propagate the counters before resetting them? I understand that for the just-analyzed relation we can't do better, but why not to propagate the counters to parents? (Not necessarily from this place in the stat collector, maybe the analyze process should do that.) 4) pgstat_recv_reportedchanges I think this needs to be more careful when updating the value - the stats collector might have received other messages modifying those counters (including e.g. PGSTAT_MTYPE_ANALYZE with a reset), so maybe we can get into situation with (changes_since_analyze_reported > changes_since_analyze) if we just blindly increment the value. I'd bet would lead to funny stuff. So maybe this should be careful to never exceed this? regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company