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 1lUyjU-0005IV-Ge for pgsql-hackers@arkaria.postgresql.org; Fri, 09 Apr 2021 21:32: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 1lUyjT-0006Jp-Fe for pgsql-hackers@arkaria.postgresql.org; Fri, 09 Apr 2021 21:32:03 +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 1lUyjT-0006IK-8Q for pgsql-hackers@lists.postgresql.org; Fri, 09 Apr 2021 21:32:03 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lUyjR-0004k2-3S for pgsql-hackers@lists.postgresql.org; Fri, 09 Apr 2021 21:32:02 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id D6E335C009D; Fri, 9 Apr 2021 17:31:59 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Fri, 09 Apr 2021 17:31:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=1QeiVSjcEGduPVYofxgrWozWzvk0EygJ8SqgAtJsfJE=; b=hWagiDsm jOMQTpGhUCFoIXKogRskGKSaZtGJqXmmpXDNwv6KQJIa62F5u1CZEn8GB2ZUAkr7 lX5rv3cq23Khcj/lbQCWq4gyhfA+kPrdNZBuXnaPHnu9ueHBmRs1xtir+GFYYOmP wk8DHhOfdqopTjNquCFW2eSRxieYn5WC6XC68z0RPBdTwto7iDzDJI207zzG5HmV rTvouIVB5GP8V2cujpEHfyoAT0kg0y/ttVD0R73jithLspOsY0iBnkRl1pjGJIt6 BcSXmaA9UQe2kHtkQuJZUyjobrGIZdpwNeQo1LNdTH55l3/LVncUPHGyHwla9eLe 5p7mO0vz5zIc5A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudekuddgudeiiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvuffkgggtugfgjggfsehtkeertddtredunecuhfhrohhmpeetlhhv rghrohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorh hgqeenucggtffrrghtthgvrhhnpeeufffhjeeiueeuffegvddukeegledtveeivdeiueef ieeivefgteehueefteehvdenucfkphepudeltddrleehrdduledrleehnecuvehluhhsth gvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhhvghrrhgvsegr lhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Received: from perhan.alvh.no-ip.org (unknown [190.95.19.95]) by mail.messagingengine.com (Postfix) with ESMTPA id B734A108005C; Fri, 9 Apr 2021 17:31:58 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 759D32A0EDC; Fri, 9 Apr 2021 17:31:55 -0400 (-04) Date: Fri, 9 Apr 2021 17:31:55 -0400 From: Alvaro Herrera To: Robert Haas Cc: Tom Lane , Zhihong Yu , PostgreSQL Developers , Yuzuko Subject: Re: pgsql: autovacuum: handle analyze for partitioned tables Message-ID: <20210409213155.GA23912@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2021-Apr-09, Robert Haas wrote: > Does this need to worry about new partitions getting attached to a > partitioned table, or old ones getting detached? (Maybe it does > already, not sure.) Good question. It does not. I suppose you could just let that happen automatically -- I mean, next time the partitioned table is analyzed, it'll scan all attached partitions. But if no tuples are modified afterwards in existing partitions (a common scenario), and the newly attached partition contains lots of rows, then only future rows in the newly attached partition would affect the stats of the partitioned table, and it could be a long time before that causes an analyze on the partitioned table to occur. Maybe a way to attack this is to send a the "anl_ancestors" message to the collector on attach and detach, adding a new flag ("is attach/detach"), which indicates to add not only "changes_since_analyze - changes_since_analyze_reported", but also "n_live_tuples". -- Álvaro Herrera 39°49'30"S 73°17'W Essentially, you're proposing Kevlar shoes as a solution for the problem that you want to walk around carrying a loaded gun aimed at your foot. (Tom Lane)