Skip site navigation (1) Skip section navigation (2)

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 (view raw, whole thread or download thread mbox)
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: 0001-Teach-dbsize.c-functions-about-partitioned-tables.patch
Description: text/plain (4.2 KB)

Responses

pgsql-hackers by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group