pg_(total_)relation_size and partitioned tables

From: Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: pg_(total_)relation_size and partitioned tables
Date: 2017-12-14 05:23:59
Message-ID: 495cec7e-f8d9-7e13-4807-90dbf4eec4ea@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi.

You may have guessed from $subject that the two don't work together.

create table p (a int) partition by list (a);
create table p1 partition of p for values in (1, 2) partition by list (a);
create table p11 partition of p1 for values in (1);
create table p12 partition of p1 for values in (2);
insert into p select i % 2 + 1 from generate_series(1, 1000) i;

On HEAD:

select pg_relation_size('p');
pg_relation_size
------------------
0
(1 row)

select pg_total_relation_size('p');
pg_total_relation_size
------------------------
0
(1 row)

After applying the attached patch:

select pg_relation_size('p');
pg_relation_size
------------------
49152
(1 row)

select pg_total_relation_size('p');
pg_total_relation_size
------------------------
98304
(1 row)

The patch basically accumulates and returns the sizes of all leaf
partitions when passed a partitioned table. Will add it to next CF.

Thanks,
Amit

Attachment Content-Type Size
0001-Teach-dbsize.c-functions-about-partitioned-tables.patch text/plain 4.2 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Justin Pryzby 2017-12-14 05:49:02 Re: [HACKERS] pg_upgrade failed with error - ERROR: column "a" in child table must be marked NOT NULL
Previous Message Rushabh Lathia 2017-12-14 04:31:18 incorrect error message, while dropping PROCEDURE