From: Tom Lane <tgl@sss.pgh.pa.us>
To: Ron <ronljohnsonjr@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Autovacuum on Partitioned Tables
Date: Tue, 01 Nov 2022 00:05:14 -0400
Message-ID: <1071326.1667275514@sss.pgh.pa.us> (raw)
In-Reply-To: <ecf63c8a-8eca-3152-9c62-3574cb7a2098@gmail.com>
References: <CAEuohQp_iK8jKceQ1BUKZWtzhz4F=utke1WcYqK31ZAV4FV-Og@mail.gmail.com>
<ecf63c8a-8eca-3152-9c62-3574cb7a2098@gmail.com>
Ron <ronljohnsonjr@gmail.com> writes:
> On 10/31/22 17:26, Ryan Ruenroeng wrote:
>> I have a table with 50+ million rows that gets data added to/wiped from it
>> every 90 days. We are planning to break this table into a few thousand
>> partitions.
> 1. That's a lot of partitions. Older (like v12) query optimizers don't do a
> great job handle that many partitions.
Newer ones don't either, if you are incautious enough to issue a query
that touches all/most of the partitions --- or even just that the
planner cannot prove doesn't touch all/most of the partitions. So
that sort of setup hinges critically on having very stylized queries
that you've vetted in advance. We'll probably continue to make
incremental improvements in how well things work with lots of
partitions, but I don't foresee it ever becoming a cost-free thing.
TBH, if you've got 50m rows, I'm not sure you need partitions at all.
You sure as heck do not need "a few thousand" of them.
You should be basing your partitioning design on predictable maintenance
operations that will match your partition boundaries. For example,
if your business requirement is to keep five years' worth of records
and you want to drop the oldest month's records in bulk once a month,
then partitioning by month would be pretty helpful to make those drops
cheap. That would lead to 60 active partitions which is entirely
reasonable.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, ronljohnsonjr@gmail.com
Subject: Re: Autovacuum on Partitioned Tables
In-Reply-To: <1071326.1667275514@sss.pgh.pa.us>
References: <CAEuohQp_iK8jKceQ1BUKZWtzhz4F=utke1WcYqK31ZAV4FV-Og@mail.gmail.com> <ecf63c8a-8eca-3152-9c62-3574cb7a2098@gmail.com> <1071326.1667275514@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox