pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
To: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
To: Michael Paquier <michael.paquier@gmail.com>
To: David Rowley <david.rowley@2ndquadrant.com>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Pg Hackers <pgsql-hackers@postgresql.org>
Subject: Re: pg_(total_)relation_size and partitioned tables
Date: Thu, 28 Dec 2017 14:03:11 -0500
Message-ID: <d5323242-b571-9317-1e5b-ee5fd96c2f4a@2ndquadrant.com> (raw)
In-Reply-To: <1a78dea4-36b7-afb7-b3f3-1b4ff319fbb4@lab.ntt.co.jp>
References: <495cec7e-f8d9-7e13-4807-90dbf4eec4ea@lab.ntt.co.jp>
	<CA+TgmobG69Nf4E+VKcojXZQa9FRsbr7Dd+NORJRFMh5Umer98w@mail.gmail.com>
	<CAKJS1f9Rev615s4k7JhUsqwu-3CjR0xB2F0qpZ5fvQe+mxke0w@mail.gmail.com>
	<CAB7nPqQtNv5DLD9pXMWcT2VcsJqOnRUNBKekAapYiJxV4t=tyg@mail.gmail.com>
	<CAB7nPqTKy7HRpUM0_vMjGPkM6h6pR86Aegsw+MTmzxWr3-D-tg@mail.gmail.com>
	<1a78dea4-36b7-afb7-b3f3-1b4ff319fbb4@lab.ntt.co.jp>

On 12/18/17 00:17, Amit Langote wrote:
> I agree with the Robert's point which both David and Michael seem to agree
> with that we shouldn't really be changing what pg_relation_size() is doing
> under the covers.  And I guess the same for pg_table_size(), too.  Both of
> those functions and their siblings work with relations that possess
> on-disk structures and have associated relations (TOAST, indexes) that in
> turn possess on-disk structures.  It seems quite clearly documented as
> such.  Partitioned tables are different in that they neither possess
> on-disk structures nor have any relations (TOAST, indexes) associated
> directly with them.  Instead, they have partitions that are the relations
> that aforementioned dbsize.c functions are familiar with.

Here is another idea.  If we had a function

pg_partition_root(regclass) returns regclass

(returning itself for non-partitioned relations), then users can easily
construct queries to get the results they want in different shapes, e.g.,

select pg_partition_root(c.oid), c.relname, pg_table_size(c.oid)
  from pg_class c
  order by 1

select pg_partition_root(c.oid), sum(pg_table_size(c.oid))
  from pg_class c
  group by 1

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services




view thread (25+ messages)  latest in thread

Message-ID: <d5323242-b571-9317-1e5b-ee5fd96c2f4a@2ndquadrant.com>
Permalink:  ../d5323242-b571-9317-1e5b-ee5fd96c2f4a@2ndquadrant.com/
Also on:    postgresql.org/message-id/d5323242-b571-9317-1e5b-ee5fd96c2f4a@2ndquadrant.com

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: peter.eisentraut@2ndquadrant.com, Langote_Amit_f8@lab.ntt.co.jp, michael.paquier@gmail.com, david.rowley@2ndquadrant.com, robertmhaas@gmail.com
  Subject: Re: pg_(total_)relation_size and partitioned tables
  In-Reply-To: <d5323242-b571-9317-1e5b-ee5fd96c2f4a@2ndquadrant.com>

* 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