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 1optlm-0000JZ-DK for pgsql-general@arkaria.postgresql.org; Tue, 01 Nov 2022 16:05:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1optll-0004IL-3R for pgsql-general@arkaria.postgresql.org; Tue, 01 Nov 2022 16:05:41 +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 1optlk-0004IC-JE for pgsql-general@lists.postgresql.org; Tue, 01 Nov 2022 16:05:40 +0000 Received: from mail-oa1-x2c.google.com ([2001:4860:4864:20::2c]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1optlg-0005ms-0X for pgsql-general@lists.postgresql.org; Tue, 01 Nov 2022 16:05:40 +0000 Received: by mail-oa1-x2c.google.com with SMTP id 586e51a60fabf-1322d768ba7so17290202fac.5 for ; Tue, 01 Nov 2022 09:05:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to; bh=jT6/roNyh3meefo+doDpVjwrdMhQT3hbSMNb+WI9Iz0=; b=kKxZkMEXVJ4sdNducPXBwwC6d0h0/OrRNl1771OUIdAfe8ZI8MszU2+27fAZKa0wio mrREEzVRTtWY0fyLz4L0aSHVLnWXQz4B9HFL2z4d0SFBYOrcYKO/sz0f2Vfw3Ovd8wDv y51va8FMrD5KkN/uFiXLus3NXdl02CcfYwZ447y2MrqnOAY6fa3vBcUyfzYXwm/I7wMP ITVkZBZunFZM8wYM5p3fBqfX6X6pLH+CLiW7XBmQWoaL2Z1gUUo0n5OcxrgB1NzM8Qbb vrNibOYwtyU+Ace5sH0YWj8xkk3lapD7JPHd79PPfUL5RIUhpYbgK+Bv+8ye5u59xuYZ hpYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=jT6/roNyh3meefo+doDpVjwrdMhQT3hbSMNb+WI9Iz0=; b=41/qV0e8JQKM/rkGZaAzzcN6v1EnboBJMCmxmmmpr/bHZ24g6Mlwb+4JuVkjdXzCGR neVTDto5tFc2u8VANkRETUwBHVzf2QV09dvItWeU7kNBCNH9wVMe7FWrbZ0cSOQOAyeD 8XM0oWY3mrHtHEMv59GtrT+GNLHe218yDdwvuNNHXRCQvSDpkuiR1LjsNwoq+6C/1ZCZ dv0xU+RJrepFR7Iw4YyZofV7zD71IiZBjI4con6H7sii3SYcJgbmlA/KWtLQGicIaI76 HKesb/nlSVZp4MDH5GYE+CQBZasQwOhof21pfMtssLMMuxjf5RbyCwoWrFU74R6muHw1 h/Yw== X-Gm-Message-State: ACrzQf3MWcOYYTiJBC7fPiFdPK2rdyk5jv5cO2UnGfk1xF5ihqr0R/pf 8VK+xw8XIaXYA2KOog5e3zdkkLCcHI4= X-Google-Smtp-Source: AMsMyM4cgLt0zyUWPCvuob0CRRt+r26BONhBD4mRWGRgjbG/fMEiLx+1lwtvDxr4yeYrdQRZbQLR3A== X-Received: by 2002:a05:6871:58a:b0:13b:6698:6da9 with SMTP id u10-20020a056871058a00b0013b66986da9mr21530612oan.23.1667318733502; Tue, 01 Nov 2022 09:05:33 -0700 (PDT) Received: from [192.168.88.10] (ip68-11-68-85.no.no.cox.net. [68.11.68.85]) by smtp.googlemail.com with ESMTPSA id g93-20020a9d2de6000000b00666fdab9da7sm3920900otb.78.2022.11.01.09.05.31 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Nov 2022 09:05:32 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------n0G0x8fDrbYeXyQc9cu0fNn6" Message-ID: <50d1b1cd-2198-09f6-cd76-0ed4e207bf13@gmail.com> Date: Tue, 1 Nov 2022 11:05:30 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: Autovacuum on Partitioned Tables Content-Language: en-US To: pgsql-general@lists.postgresql.org References: <1071326.1667275514@sss.pgh.pa.us> <0780cad9-0317-ef27-5b18-fa4f16087e7b@gmail.com> From: Ron In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------n0G0x8fDrbYeXyQc9cu0fNn6 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 11/1/22 10:11, Ryan Ruenroeng wrote:T > Thanks all for your responses. We have a couple of tables. Each with > 50-70mil rows currently, but they are expected to grow. Partitioning seems > to be a better long-term strategy, queries to these tables, using their > existing indexes, leaves them basically unusable (loooong run times). > > FYI, we are currently on PG v11.16 > > Let's assume we do go with my current proposal because it is inline with > how we are planning to drop partitions that stop seeing activity in the > future: > > [snip] from Ron's post above: > Autovacuum will handle it. > > I still have some doubts based on this: > "Tuples changed in partitions and inheritance children do not trigger > analyze on the parent table. If the parent table is empty or rarely > changed, it may never be processed by autovacuum, and the statistics for > the inheritance tree as a whole won't be collected. It is necessary to run > |ANALYZE|/ on the parent table manually in order to keep the statistics up to > date." /[Link ] > Q1: Will we at least need to call Analyze via a cron job on the parent > table to ensure that the statistics are up to date for autovacuum to catch > the tables? Tuning auto-analyze variables is supposed to obviate the need for manual vacuuming *analyzing*.  I do manual vacuuming *anayzing* anyway in a cron job. "This set of tables have had more than X amount of changes, so I'll /explictly/ analyze them." Once a week, I do bloat calculations and vacuum based on that. > From reading the documentation that a few of you have pointed me to, I'm > led to believe that the parent table is the "Partition" table. "\d" will show you exactly what you need to know. > The children tables are treated by the autovacuum as tables Child tables *are* tables. > Q2: Autovacuum will act on the partitions/children to the parent table. > *Is that a correct statement?* Parents are meta-tables.  There's nothing to vacuum or analyze. > -- > It's good to know that the query optimizer will improve with partitions on > versions 12+. Thank you. > > Best, > Ryan > > Ryan N Ruenroeng (He/His) > (717) 578-3929 > > > | RRuenroeng@gmail.com > > > > | Madison, WI > > > > > > > On Tue, Nov 1, 2022 at 2:54 AM Ron wrote: > > On 10/31/22 23:05, Tom Lane wrote: > [snip] > > TBH, if you've got 50m rows, I'm not sure you need partitions at all. > > Big rows (i.e. document storage tables with bytea or xml fields) can make > databases explode in size even with only 50M rows. > > (Yes, I know the arguments against it, but it works quite well when the > database is in a cloud instance.  Worries about backup times, at > least, are > eliminated.) > > -- > Angular momentum makes the world go 'round. > > -- Angular momentum makes the world go 'round. --------------n0G0x8fDrbYeXyQc9cu0fNn6 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 11/1/22 10:11, Ryan Ruenroeng wrote:T
Thanks=C2=A0all for your responses. We have a couple of tabl= es. Each with 50-70mil rows currently, but they are expected to grow. Partitioning seems to be a better long-term strategy, queries=C2=A0to these tables, using their existing=C2=A0indexes= , leaves them basically unusable (loooong run times).=C2=A0

FYI, we are currently on PG v11.16

Let's assume we do go with my current proposal because it is inline with how we are planning to drop partitions that stop seeing activity in the future:

[snip] from Ron's post above:
Autovacuum will handle it.

I still have some doubts based on this:
"Tuples changed in partitions and inheritance children do not trigger ana=
lyze on the parent table. If the parent table is empty or rarely changed,=
 it may never be processed by autovacuum, and the statistics for the inhe=
ritance tree as a whole won't be collected. It is necessary to run=C2=A0<=
/span>ANALYZE=C2=A0on=
 the parent table manually in order to keep the statistics up to date."=C2=
=A0[Link]
Q1: Will we at least =
need to call Analyze via a cron=C2=A0job on the parent table to ensure th=
at the statistics are up to date for autovacuum to catch the tables?

Tuning auto-analyze variables is supposed to obviate the need for manual vacuuming analyzing.=C2=A0 I do manual= vacuuming anayzing anyway in a cron job. "This set of tables have had more than X amount of changes, so I'll explictly analyze them."

Once a week, I do bloat calculations and vacuum based on that.

From reading the documentation that a few=
 of you have pointed me to, I'm led to believe that the parent table is t=
he "Partition" table.

"\d" will show you exactly what you need to know.

 The children tables are treated by the a=
utovacuum as tables

Child tables are tables.

Q2: Autovacuum will act on the partitions=
/children to the parent table. Is that a correct statement?=

Parents are meta-tables.=C2=A0 There's nothing to vacuum or analyze.<= br>
--
It's good to know that the query optimizer will improve with partitions on versions 12+. Thank you.=C2=A0

Best,
Ryan

Ryan N Ruenroeng (He/His)
= = (717) 578-3929
|=C2=A0RRuenroeng@gmail.com
=
| = = Madison, WI<= /td>


On Tue, Nov 1, 2022 at 2:54= AM Ron <ronl= johnsonjr@gmail.com> wrote:
= On 10/31/22 23:05, Tom Lane wrote:
[snip]
> TBH, if you've got 50m rows, I'm not sure you need partitions at all.

Big rows (i.e. document storage tables with bytea or xml fields) can make
databases explode in size even with only 50M rows.

(Yes, I know the arguments against it, but it works quite well when the
database is in a cloud instance.=C2=A0 Worries about backup tim= es, at least, are
eliminated.)

--
Angular momentum makes the world go 'round.



--
Angular momentum makes the world go 'round.
--------------n0G0x8fDrbYeXyQc9cu0fNn6--