Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qmLeu-006n39-4K for pgsql-hackers@arkaria.postgresql.org; Fri, 29 Sep 2023 22:08:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qmLes-006RR4-PA for pgsql-hackers@arkaria.postgresql.org; Fri, 29 Sep 2023 22:08:26 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qmLes-006RQM-FB for pgsql-hackers@lists.postgresql.org; Fri, 29 Sep 2023 22:08:26 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qmLep-007Lf1-LX for pgsql-hackers@postgresql.org; Fri, 29 Sep 2023 22:08:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=momjian.us; s=2023062407; h=In-Reply-To:Content-Transfer-Encoding:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-ID:Content-Description; bh=uW0cKQvnKWn6NhTMbRIogkgLdt9AHBzfK//pSxncqr8=; b=ghb/+2RnxCqfZh2pxLg5HziTzU AkI3VaM57evLk4370C+BMntzi91rulTLkGar6DWagJ/28rvgvbbmJX/hEZRkzUG6aUDl29q8N/IHU mjApXUeIA6Xpj5+y1JqouFbtXsTB51QFCqvv8IbKInLKpQo5Kht0ymghh3jKHwODRb/Reu30ElACR zbCh1Lxdvm49j7trCd6OObeM7IvET2ldN035AYxY5MaAegTyz/prdgCTrRbMWygastVXap+Kwmv96 RreM5M4REi1cM/5JwdlUT4pfGsHLWZm3qa19iCSl2R8ih5ZdvUa9SCQ3jNyD4rXWEWnGV0dUMrY7t Ek1mdaxA==; Received: from bruce by momjian.us with local (Exim 4.96) (envelope-from ) id 1qmLej-00GYKq-1H; Fri, 29 Sep 2023 18:08:17 -0400 Date: Fri, 29 Sep 2023 18:08:17 -0400 From: Bruce Momjian To: Laurenz Albe Cc: David Rowley , Justin Pryzby , Nathan Bossart , Tomas Vondra , Robert Haas , =?utf-8?Q?=C3=81lvaro?= Herrera , yuzuko , pgsql-hackers@postgresql.org Subject: Re: document the need to analyze partitioned tables Message-ID: References: <1fd81ddc7710a154834030133c6fea41e55c8efb.camel@cybertec.at> <20230112232747.GA2111950@nathanxps13> <20230117210050.GX9837@telsasoft.com> <216da165b47db064dcaa55b15b9b6cf470a088aa.camel@cybertec.at> <596c6bea8b7768e24b093d26f15daa4ce0df566f.camel@cybertec.at> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="+dnOw6TNWEX7PNip" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <596c6bea8b7768e24b093d26f15daa4ce0df566f.camel@cybertec.at> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --+dnOw6TNWEX7PNip Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Wed, Sep 6, 2023 at 05:53:56AM +0200, Laurenz Albe wrote: > > We may have different mental models here. This relates to the part > > that I wasn't keen on in your patch, i.e: > > > > +    The partitions of a partitioned table are normal tables and get processed > > +    by autovacuum > > > > While I agree that the majority of partitions are likely to be > > relkind='r', which you might ordinarily consider a "normal table", you > > just might change your mind when you try to INSERT or UPDATE records > > that would violate the partition constraint. Some partitions might > > also be themselves partitioned tables and others might be foreign > > tables. That does not really matter much when it comes to what > > autovacuum does or does not do, but I'm not really keen to imply in > > our documents that partitions are "normal tables". > > Agreed, there are differences between partitions and normal tables. > And this is not the place in the documentation where we would like to > get into detail about the differences. > > Attached is the next version of my patch. I adjusted your patch to be shorter and clearer, patch attached. I am planning to apply this back to PG 11. -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com Only you can decide what is important to you. --+dnOw6TNWEX7PNip Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="autovacuum.diff" diff --git a/doc/src/sgml/maintenance.sgml b/doc/src/sgml/maintenance.sgml index 9cf9d030a8..70b5576037 100644 --- a/doc/src/sgml/maintenance.sgml +++ b/doc/src/sgml/maintenance.sgml @@ -861,10 +861,16 @@ analyze threshold = analyze base threshold + analyze scale factor * number of tu - Partitioned tables are not processed by autovacuum. Statistics - should be collected by running a manual ANALYZE when it is - first populated, and again whenever the distribution of data in its - partitions changes significantly. + Partitioned tables do not directly store tuples and consequently do not + require autovacuum to perform automated VACUUM. + (Autovacuum does perform VACUUM on table + partitions just like other tables.) Unfortunately, this also means + that autovacuum doesn't run ANALYZE on partitioned + tables, and this can cause suboptimal plans for queries that reference + partitioned table statistics. You can work around this problem by + manually running ANALYZE on partitioned tables + when they are first populated, and again whenever the distribution + of data in their partitions changes significantly. --+dnOw6TNWEX7PNip--