Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aBo4k-0002SK-5y for pgsql-bugs@arkaria.postgresql.org; Wed, 23 Dec 2015 18:23:50 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aBo4j-0004i9-Ow for pgsql-bugs@arkaria.postgresql.org; Wed, 23 Dec 2015 18:23:49 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1aBo47-0003wo-Qi for pgsql-bugs@postgresql.org; Wed, 23 Dec 2015 18:23:11 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1aBo44-0007AB-NT for pgsql-bugs@postgresql.org; Wed, 23 Dec 2015 18:23:11 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id tBNIMpLZ002683; Wed, 23 Dec 2015 13:22:51 -0500 From: Tom Lane To: foggyglass@163.com cc: pgsql-bugs@postgresql.org Subject: Re: BUG #13830: pg_table_size and pg_indexes_size In-reply-to: <20151223145546.2688.94659@wrigleys.postgresql.org> References: <20151223145546.2688.94659@wrigleys.postgresql.org> Comments: In-reply-to foggyglass@163.com message dated "Wed, 23 Dec 2015 14:55:46 +0000" Date: Wed, 23 Dec 2015 13:22:51 -0500 Message-ID: <2682.1450894971@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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