Re: pg_(total_)relation_size and partitioned tables

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_(total_)relation_size and partitioned tables
Date: 2017-12-18 00:29:13
Message-ID: CAB7nPqQtNv5DLD9pXMWcT2VcsJqOnRUNBKekAapYiJxV4t=tyg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Dec 17, 2017 at 11:54 PM, David Rowley
<david(dot)rowley(at)2ndquadrant(dot)com> wrote:
> I'd also vote to leave the relation_size functions alone.

Count me in that bucket as well.

> Perhaps it's worth thinking of changing pg_table_size() instead. We
> have taken measures to try and hide the fact that a table is made up
> of a bunch of partitions from the user in some cases, e.g DROP TABLE
> works without CASCADE for a partitioned table. I'm sure there are
> arguments in both directions here too though.
>
> I generally think of the difference between a relation and a table
> similarly to the difference between a tuple and a row. A relation is
> just what we use to implement tables, and there can be multiple
> relations per table (in the partitioning case), similar to how there
> can be multiple tuple versions for a single row. So that might back up
> that pg_table_size should include all relations that make up that
> table.

The barrier here is thin. What's proposed here is already doable with
a WITH RECURSIVE query. So why not just documenting this query and be
done with it instead of complicating the code? It seems to me that the
performance in calling pg_relation_size() in a cascading times fashion
would not matter much. Or one could invent an additional cascading
option which scans inheritance and/or partition chains, or simply have
a new function.
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2017-12-18 00:32:47 Re: worker_spi example BGW code GUC tweak
Previous Message Robert Haas 2017-12-18 00:26:54 Re: pg_(total_)relation_size and partitioned tables