Re: ANALYZE on partitioned tables vs on individual partitions - Mailing list pgsql-general

From Christophe Pettus
Subject Re: ANALYZE on partitioned tables vs on individual partitions
Date
Msg-id D8A15A79-9FCF-4855-AB1E-BD6088065CCC@thebuild.com
Whole thread Raw
In response to ANALYZE on partitioned tables vs on individual partitions  (Michael Harris <harmic@gmail.com>)
Responses Re: ANALYZE on partitioned tables vs on individual partitions
List pgsql-general

> On Aug 6, 2024, at 21:13, Michael Harris <harmic@gmail.com> wrote:
>
>   1. What is the consequence of not having good statistics on partitioned table level, if you do have good statistics
onthe partition level? 

The child partitions are just tables, and all of the same issues that can arise from bad statistics on a table can
ariseon them: specifically, bad query plans.  (There are also some consequences to leaving a table unvacuumed, even an
append-onlytable.)  The root table in declarative partitioning has no rows, so there really is no such thing as
"statisticsat the partition level." 

>   2. Which planning operations rely on partitioned table level statistics?

Just about every query uses the information that ANALYZE gathers in some way.  If the query can't be executed in any
otherconceivable way than a sequential scan, or if it is a simple lookup on a unique column, the statistics will not
contributeto the plan, but essentially every other plan will use them in one way or another. 

Child partitions should be autovacuumed and autoanalyzed just like any other table; they are not prohibited from
autovacuumin any way by default.  It's probably a good idea to investigate why they are not being picked up by
autovacuum. If they are created by a bulk load process, it's not a bad idea to do a VACUUM ANALYZE on them once the
bulkload is complete. 


pgsql-general by date:

Previous
From: Muhammad Ikram
Date:
Subject: Re: Streaming replication issue post upgrade from version 11 to 14 on windows 2016 Server
Next
From: David Rowley
Date:
Subject: Re: ANALYZE on partitioned tables vs on individual partitions