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 1pICZ4-00059I-SV for pgsql-hackers@arkaria.postgresql.org; Wed, 18 Jan 2023 17:49:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pICZ3-0007WU-8A for pgsql-hackers@arkaria.postgresql.org; Wed, 18 Jan 2023 17:49:33 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pICZ2-0007WK-RB for pgsql-hackers@lists.postgresql.org; Wed, 18 Jan 2023 17:49:32 +0000 Received: from mail-il1-x131.google.com ([2607:f8b0:4864:20::131]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pICYz-0001JE-BR for pgsql-hackers@postgresql.org; Wed, 18 Jan 2023 17:49:31 +0000 Received: by mail-il1-x131.google.com with SMTP id g2so17404289ila.4 for ; Wed, 18 Jan 2023 09:49:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20210112.gappssmtp.com; s=20210112; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=dS2Uxp+6pZExpkvdI2niie/CCgw7THC82sjlxed+XM8=; b=fbTDuX7cqRdSxgugZlSz7fHQj8ECJ+uWc88K8kK3x1b8R40LH4JAgqyaIPUHb0MsZ9 tEkY8QJyE2hb/ZEHWrLCBl11HN3EEHZUFyjLmW0Q6lBmjzSsUNPAABJrcvJTvLkXNCrw tUg80bzZw6tBxL1DgzKY9h2yS7otwLSCWKEsjY7UW0jYp+N4Qz6N28cJxx3m+YQCSmYa 5H/n7HLweNlMtL7UMfWZzzl0o5BRZJpwMyojBOXlZ7pIHDS8cPzFSc6rS9H6plRwzBA/ XJauLJkeaRasm+xp9bTgCKw3s586V9TMudk9Xn69bnrYYVd5SclBfZTTy/mtMKy7dWAh 5Krw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=dS2Uxp+6pZExpkvdI2niie/CCgw7THC82sjlxed+XM8=; b=BFEI33gbWREu7n8hv27kYig0Exbjr11qBma+l3+L4sSMvU0BSyMTbMYIkJslsI9EIY PqKSg8IKncLwN/Xyq2+87ae+XRFZ740qDqtEe8cPuSJxAZ7Xanf+uBlHPtlc2RmocfXE nhsopdeWSfOfTBbZy7ZM9ozaUPhQyRfnNq8JINr6A421KNct9l90KL/q2CDe7q30ACLH QEndDH6DkcLQEPVvDWLbOVBWmCMFG6w+db6KCQAmCEP4H2V4A5IWgjTqpl2CVkz/a/rL C/kTnngUKiGxTcElLmgiPb99bW3bJMuApx0/QsRDbCBVqEDPVQq60BF7lJpkEh9b3ApZ 8LiQ== X-Gm-Message-State: AFqh2kqfs5X9IymCudTF1ZyS8XPN4PSZzvIthtPL1jmp/jV7om4Wnade cRvruKAu2KGwdun6J15BQlOiXA== X-Google-Smtp-Source: AMrXdXtgRreYenm2hThow+S/mz/luCBgPUKravMLyv6pKkK+P69edKje7y2frsA0Gc28Ao4fzo9LGQ== X-Received: by 2002:a05:6e02:13ec:b0:30d:7f76:83be with SMTP id w12-20020a056e0213ec00b0030d7f7683bemr20326409ilj.8.1674064168613; Wed, 18 Jan 2023 09:49:28 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id u11-20020a92d1cb000000b0030c1ec638desm10172488ilg.14.2023.01.18.09.49.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 09:49:28 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 81BCC800ED9; Wed, 18 Jan 2023 11:49:19 -0600 (CST) Date: Wed, 18 Jan 2023 11:49:19 -0600 From: Justin Pryzby To: Laurenz Albe Cc: Bruce Momjian , Nathan Bossart , Tomas Vondra , Robert Haas , =?iso-8859-1?Q?=C1lvaro?= Herrera , yuzuko , pgsql-hackers@postgresql.org Subject: Re: document the need to analyze partitioned tables Message-ID: <20230118174919.GA9837@telsasoft.com> References: <19c248d9-3687-9e0f-0b1a-2adad1de6fbe@enterprisedb.com> <20220315230011.GZ28503@telsasoft.com> <88903179-5ce2-3d4d-af43-7830372bdcb6@enterprisedb.com> <1fd81ddc7710a154834030133c6fea41e55c8efb.camel@cybertec.at> <20230112232747.GA2111950@nathanxps13> <20230117210050.GX9837@telsasoft.com> 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.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Jan 18, 2023 at 10:15:18AM +0100, Laurenz Albe wrote: > On Tue, 2023-01-17 at 16:16 -0500, Bruce Momjian wrote: > > On Tue, Jan 17, 2023 at 03:00:50PM -0600, Justin Pryzby wrote: > > > Maybe (all?) the clarification the docs need is to say: > > > "Partitioned tables are not *themselves* processed by autovacuum." > > > > Yes, I think the lack of autovacuum needs to be specifically mentioned > > since most people assume autovacuum handles _all_ statistics updating. That's what 61fa6ca79 aimed to do. Laurenz is suggesting further clarification. > > Can someone summarize how bad it is we have no statistics on partitioned > > tables?  It sounds bad to me. > > Andrey Lepikhov had an example earlier in this thread[1]. It doesn't take > an exotic query. > > Attached is a new version of my patch that tries to improve the wording. I tweaked this a bit to end up with: > - Partitioned tables are not processed by autovacuum. Statistics > - should be collected by running a manual ANALYZE when it is > + The leaf partitions of a partitioned table are normal tables and are processed > + by autovacuum; however, autovacuum does not process the partitioned table itself. > + This is no problem as far as VACUUM is concerned, since > + there's no need to vacuum the empty, partitioned table. But, as mentioned in > + , it also means that autovacuum won't > + run ANALYZE on the partitioned table. > + Although statistics are automatically gathered on its leaf partitions, some queries also need > + statistics on the partitioned table to run optimally. You should collect statistics by > + running a manual ANALYZE when the partitioned table is > first populated, and again whenever the distribution of data in its > partitions changes significantly. > "partitions are normal tables" was techically wrong, as partitions can also be partitioned. -- Justin