Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aC88n-0002er-Ji for pgsql-bugs@arkaria.postgresql.org; Thu, 24 Dec 2015 15:49:21 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aC88n-0000NV-5q for pgsql-bugs@arkaria.postgresql.org; Thu, 24 Dec 2015 15:49:21 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1aC62i-0006t0-S1 for pgsql-bugs@postgresql.org; Thu, 24 Dec 2015 13:34:57 +0000 Received: from m50-138.163.com ([123.125.50.138]) by makus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1aC62Z-0003la-D4 for pgsql-bugs@postgresql.org; Thu, 24 Dec 2015 13:34:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=Message-ID:Date:From:MIME-Version:Subject; bh=c/0YH Ta7WgpqqOjEXddblsVQou89S0pCdL7+sQz5i/o=; b=AkWOXHWsBWG11dqpBrU1V U+xHGAfwtQFRBX4FoUgdz1VAWWHKAmTBg6GkiJrVUE2zuimBCnhhfA/y2kc0tIT3 bsLZ3iO22G8G/RxIwMTLotK3WJV4CcySzMY3cNDWx3ezc8Ss2rwWl+YQKTxeoT8h h7idPwlnq+0i0M1whC1OIg= Received: from [192.168.1.104] (unknown [114.252.94.234]) by smtp1 (Coremail) with SMTP id C9GowACXnxNt9HtWZsMIAw--.51638S3; Thu, 24 Dec 2015 21:34:38 +0800 (CST) Message-ID: <567BF471.7090802@163.com> Date: Thu, 24 Dec 2015 21:34:41 +0800 From: huang User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Tom Lane CC: pgsql-bugs@postgresql.org Subject: Re: BUG #13830: pg_table_size and pg_indexes_size References: <20151223145546.2688.94659@wrigleys.postgresql.org> <2682.1450894971@sss.pgh.pa.us> In-Reply-To: <2682.1450894971@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID: C9GowACXnxNt9HtWZsMIAw--.51638S3 X-Coremail-Antispam: 1Uf129KBjvJXoWruFWUtFyxZryrKry3ZFWrKrg_yoW8Jr48pr nxJF93tr4jkr10kr1UA3WYqw1ruwn3Jw1fJry5Ary8AayDZr4xXF4jgFyxCFW7ZrW8tr90 gayYq3s5Xr1xAFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jmYL9UUUUU= X-Originating-IP: [114.252.94.234] X-CM-SenderInfo: 5irjw55jod22i6rwjhhfrp/1tbiJQ7a9FUL9BPkpAAAs8 X-Pg-Spam-Score: -2.0 (--) 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 Mr. Tom Lane Thank you for your explanation .:) 在 2015/12/24 2:22, Tom Lane 写道: > 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