pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Set pg_class.reltuples for partitioned tables
Date: Fri, 09 Apr 2021 15:53:45 +0000
Message-ID: <E1lUtS5-0001kd-2z@gemulon.postgresql.org> (raw)

Set pg_class.reltuples for partitioned tables

When commit 0827e8af70f4 added auto-analyze support for partitioned
tables, it included code to obtain reltuples for the partitioned table
as a number of catalog accesses to read pg_class.reltuples for each
partition.  That's not only very inefficient, but also problematic
because autovacuum doesn't hold any locks on any of those tables -- and
doesn't want to.  Replace that code with a read of pg_class.reltuples
for the partitioned table, and make sure ANALYZE and TRUNCATE properly
maintain that value.

I found no code that would be affected by the change of relpages from
zero to non-zero for partitioned tables, and no other code that should
be maintaining it, but if there is, hopefully it'll be an easy fix.

Per buildfarm.

Author: Álvaro Herrera <alvherre@alvh.no-ip.org>
Reviewed-by: Zhihong Yu <zyu@yugabyte.com>
Discussion: https://postgr.es/m/1823909.1617862590@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/0e69f705cc1a3df273b38c9883fb5765991e04fe

Modified Files
--------------
src/backend/commands/analyze.c      | 12 ++++++++++
src/backend/commands/tablecmds.c    | 47 ++++++++++++++++++++++++++++++++++++-
src/backend/postmaster/autovacuum.c | 39 +-----------------------------
3 files changed, 59 insertions(+), 39 deletions(-)



Message-ID: <E1lUtS5-0001kd-2z@gemulon.postgresql.org>
Permalink:  ../E1lUtS5-0001kd-2z@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1lUtS5-0001kd-2z@gemulon.postgresql.org

 · 

reply

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-committers@postgresql.org
  Cc: alvherre@alvh.no-ip.org
  Subject: Re: pgsql: Set pg_class.reltuples for partitioned tables
  In-Reply-To: <E1lUtS5-0001kd-2z@gemulon.postgresql.org>
  References: <E1lUtS5-0001kd-2z@gemulon.postgresql.org>

* 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