pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: foggyglass@163.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #13830: pg_table_size and pg_indexes_size
Date: Wed, 23 Dec 2015 13:22:51 -0500
Message-ID: <2682.1450894971@sss.pgh.pa.us> (raw)
In-Reply-To: <20151223145546.2688.94659@wrigleys.postgresql.org>
References: <20151223145546.2688.94659@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

foggyglass@163.com writes:
> postgres=# create table b(id int);
> CREATE TABLE
> postgres=# create index b_idx on b(id);
> CREATE INDEX
> postgres=# select relname , pg_table_size(oid),pg_indexes_size(oid) 
> postgres-# from pg_class where relname in ('b','b_idx');
>  relname | pg_table_size | pg_indexes_size 
> ---------+---------------+-----------------
>  b       |             0 |            8192
>  b_idx   |          8192 |               0
> (2 rows)

Seems fine to me.  b is empty at this point, so it has size zero.
btree indexes, on the other hand, never have size zero because their
metapage is created immediately.  b_idx has no indexes attached to it,
so pg_indexes_size finds nothing to report on and returns zero for
that.

If you insert any actual data, the results change:

regression=# insert into b values(33);
INSERT 0 1
regression=#  select relname , pg_table_size(oid),pg_indexes_size(oid)  from pg_class where relname in ('b','b_idx');
 relname | pg_table_size | pg_indexes_size 
---------+---------------+-----------------
 b       |          8192 |           16384
 b_idx   |         16384 |               0
(2 rows)

which maybe looks a bit saner.

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (5+ messages)  latest in thread

Message-ID: <2682.1450894971@sss.pgh.pa.us>
Permalink:  ../2682.1450894971@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2682.1450894971@sss.pgh.pa.us

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, foggyglass@163.com
  Subject: Re: BUG #13830: pg_table_size and pg_indexes_size
  In-Reply-To: <2682.1450894971@sss.pgh.pa.us>
  References: <20151223145546.2688.94659@wrigleys.postgresql.org> <2682.1450894971@sss.pgh.pa.us>

* 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