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 1lUWZi-0008PM-4a for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Apr 2021 15:28:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lUWZh-0004yW-3i for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Apr 2021 15:28:05 +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 1lUWZg-0004yP-TL for pgsql-hackers@lists.postgresql.org; Thu, 08 Apr 2021 15:28:04 +0000 Received: from new1-smtp.messagingengine.com ([66.111.4.221]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lUWZe-0006o6-PM for pgsql-hackers@lists.postgresql.org; Thu, 08 Apr 2021 15:28:04 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailnew.nyi.internal (Postfix) with ESMTP id 3896C580978; Thu, 8 Apr 2021 11:28:01 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Thu, 08 Apr 2021 11:28:01 -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=0NiXYewJ8uIeUlydIfRg7mUGJbR5znQL3GLeqKz/vX0=; b=m7G56h7Y zqOsbNiQ8pTmoy4SYt6T9BIhcHSUDj/78o7klK22FdDTRFajPMoE44ofOeQ3QOnX oVIcRbL9J+kUYVvCa4j2EOCQy5R+s+OwUVEuKauZFeFbgmXplshtnFYRKNBITDhZ SW99+/8F1EhnroD6ZpPW92r1mowDU8zRrcfZD/0yVJqcn03VNN8sx+diAIkXFSE3 +/Uy1QHSqCIZULIq3b73gQdbnZOX9PzvWLofpaH2DLNmPybjdGJObS5QRu4Yrdbu U3c6L8sjzWVnUQ8Vqo3XdMT7qntHXUoheU0xUNkOrmIJaUysSIY/DeS4JvlPS+z8 E1a3/fKKRmfOiQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudejledgledtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfggtggugfgjfgesthekredttderudenucfhrhhomheptehlvhgr rhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh eqnecuggftrfgrthhtvghrnhepueffhfejieeuueffgedvudekgeeltdeviedvieeufeei ieevgfetheeufeethedvnecukfhppeduledtrdelhedrudelrdelheenucevlhhushhtvg hrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhvhhgvrhhrvgesrghl vhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Received: from perhan.alvh.no-ip.org (unknown [190.95.19.95]) by mail.messagingengine.com (Postfix) with ESMTPA id 0D0C9108005F; Thu, 8 Apr 2021 11:28:00 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 8E4092A0FC3; Thu, 8 Apr 2021 11:27:57 -0400 (-04) Date: Thu, 8 Apr 2021 11:27:57 -0400 From: Alvaro Herrera To: Tomas Vondra Cc: yuzuko , David Steele , Kyotaro Horiguchi , Justin Pryzby , Daniel Gustafsson , Amit Langote , Masahiko Sawada , Laurenz Albe , PostgreSQL Hackers , Greg Stark Subject: Re: Autovacuum on partitioned table (autoanalyze) Message-ID: <20210408152757.GA2691@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <9ea106b4-22fc-fac5-2451-e876572284aa@enterprisedb.com> 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-08, Tomas Vondra wrote: > On 4/8/21 5:22 AM, Alvaro Herrera wrote: > > However, I just noticed there is a huge problem, which is that the new > > code in relation_needs_vacanalyze() is doing find_all_inheritors(), and > > we don't necessarily have a snapshot that lets us do that. While adding > > a snapshot acquisition at that spot is a very easy fix, I hesitate to > > fix it that way, because the whole idea there seems quite wasteful: we > > have to look up, open and lock every single partition, on every single > > autovacuum iteration through the database. That seems bad. I'm > > inclined to think that a better idea may be to store reltuples for the > > partitioned table in pg_class.reltuples, instead of having to add up the > > reltuples of each partition. I haven't checked if this is likely to > > break anything. > > How would that value get updated, for the parent? Same as for any other relation: ANALYZE would set it, after it's done scanning the table. We would to make sure that nothing resets it to empty, though, and that it doesn't cause issues elsewhere. (The patch I sent contains the minimal change to make it work, but of course that's missing having other pieces of code maintain it.) > > (Also, a minor buglet: if we do ANALYZE (col1), then ANALYZE (col2) a > > partition, then we repeatedly propagate the counts to the parent table, > > so we would cause the parent to be analyzed more times than it should. > > Sounds like we should not send the ancestor list when a column list is > > given to manual analyze. I haven't verified this, however.) > > Are you sure? I haven't tried, but shouldn't this be prevented by only > sending the delta between the current and last reported value? I did try, and yes it behaves as you say. -- Álvaro Herrera Valdivia, Chile Bob [Floyd] used to say that he was planning to get a Ph.D. by the "green stamp method," namely by saving envelopes addressed to him as 'Dr. Floyd'. After collecting 500 such letters, he mused, a university somewhere in Arizona would probably grant him a degree. (Don Knuth)