pg_(total_)relation_size and partitioned tables - Mailing list pgsql-hackers

From Amit Langote
Subject pg_(total_)relation_size and partitioned tables
Date
Msg-id 495cec7e-f8d9-7e13-4807-90dbf4eec4ea@lab.ntt.co.jp
Whole thread Raw
Responses Re: pg_(total_)relation_size and partitioned tables
List 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

pgsql-hackers by date:

Previous
From: Rushabh Lathia
Date:
Subject: incorrect error message, while dropping PROCEDURE
Next
From: Justin Pryzby
Date:
Subject: Re: [HACKERS] pg_upgrade failed with error - ERROR: column "a" inchild table must be marked NOT NULL