Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aC888-0002cY-0b for pgsql-bugs@arkaria.postgresql.org; Thu, 24 Dec 2015 15:48:40 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aC887-0005vu-JH for pgsql-bugs@arkaria.postgresql.org; Thu, 24 Dec 2015 15:48:39 +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 1aC60R-0006la-Ew for pgsql-bugs@postgresql.org; Thu, 24 Dec 2015 13:32:37 +0000 Received: from m50-138.163.com ([123.125.50.138]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1aC60G-0005aB-Hw for pgsql-bugs@postgresql.org; Thu, 24 Dec 2015 13:32:34 +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=lMifV oippT5cY9gEK1GOJeDz+GQwj/JTqnZa+sFbTOo=; b=Xd4IuOyfOWHAJJ6UeKwa8 Nkkp82udkpaRoUvPkU+/ibcCtva/KbbFjPA2vmlN5l0VHEDleW+NdnZwG8wpqmAP EOb4aosAX2MwUY8WgGOwQTVPk3FKd5LSw/ZvrwHe22/zI6DvaI0ONokvUYiYByil KZqf+TZl247pn8+7F8D7AA= Received: from [192.168.1.104] (unknown [114.252.94.234]) by smtp1 (Coremail) with SMTP id C9GowACHjPnW83tWi6UIAw--.51404S3; Thu, 24 Dec 2015 21:32:07 +0800 (CST) Message-ID: <567BF3D9.5070604@163.com> Date: Thu, 24 Dec 2015 21:32:09 +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: "David G. Johnston" CC: "pgsql-bugs@postgresql.org" Subject: Re: BUG #13830: pg_table_size and pg_indexes_size References: <20151223145546.2688.94659@wrigleys.postgresql.org> In-Reply-To: Content-Type: multipart/alternative; boundary="------------060109030405070603000709" X-CM-TRANSID: C9GowACHjPnW83tWi6UIAw--.51404S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7tw48Cr18Cr43Ar1fJw43Wrg_yoW8Ww48pr s3KF9ayr15K348AryUX3WUXwn3Cwn7Gw4UGrWUury8Ar98Ary8XF4qkFy8uayfArWkCr90 qa1qqryrJw48Aw7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07j7OzsUUUUU= X-Originating-IP: [114.252.94.234] X-CM-SenderInfo: 5irjw55jod22i6rwjhhfrp/1tbioxna9FUL3kbj+gAAsL 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 This is a multi-part message in MIME format. --------------060109030405070603000709 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Mr. David , thank you for your explanation . T.T 在 2015/12/24 2:18, David G. Johnston 写道: > On Wed, Dec 23, 2015 at 7:55 AM, >wrote: > > The following bug has been logged on the website: > > Bug reference: 13830 > Logged by: T_T > Email address: foggyglass@163.com > PostgreSQL version: 9.5rc1 > Operating system: centos7 > Description: > > Hi friend, > I think there is a error about pg_table_size and > pg_indexes_size in > PostgreSQL . > This is my operation log > > [postgres@c7 bin]$./psql > psql (9.5beta2) > Type "help" for help. > > 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) > > postgres=# > > The b_idex is a index , but pg_indexes_size does not show its size > . The b > is a table , but pg_table_size does not show its size .I think the > pg_table_size show the b size , but not pg_indexes_size . > > > ​Working as documented.​ > > Table "b" has no size of its own - however its one index has a size of > 8192. > > An index is sometimes considered a "table", in this case when using > pg_table_size​, and so > ​ you get 8192 as the size of the index table (i.e., relation). Since > an index doesn't have an index of its own pg_indexes_size returns 0. > > pg_table_size on "b" returns zero since its size is zero and the > calculation excludes indexes. pg_indexes_size on "b" returns the size > of "b_idx" which is 8192. > > http://www.postgresql.org/docs/9.5/interactive/functions-admin.html > > ​ David J.​ > ​ > --------------060109030405070603000709 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit Mr. David ,
    thank you for your explanation .


T.T
在 2015/12/24 2:18, David G. Johnston 写道:
On Wed, Dec 23, 2015 at 7:55 AM, <foggyglass@163.com> wrote:
The following bug has been logged on the website:

Bug reference:      13830
Logged by:          T_T
Email address:      foggyglass@163.com
PostgreSQL version: 9.5rc1
Operating system:   centos7
Description:

Hi friend,
                I think there is  a error about pg_table_size and pg_indexes_size in
PostgreSQL .
This is my operation log

[postgres@c7 bin]$./psql
psql (9.5beta2)
Type "help" for help.

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)

postgres=#

The b_idex is a index , but pg_indexes_size does not show its size . The b
is a table , but pg_table_size does not show  its size .I think the
pg_table_size show the b size , but not pg_indexes_size .

​Working as documented.​

Table "b" has no size of its own - however its one index has a size of 8192.

An index is sometimes considered a "table", in this case when using pg_table_size​, and so
 
​ you get 8192 as the size of the index table (i.e., relation).  Since an index doesn't have an index of its own pg_indexes_size returns 0.

pg_table_size on "b" returns zero since its size is zero and the calculation excludes indexes.  pg_indexes_size on "b" returns the size of "b_idx" which is 8192.


​ David J.​
​



--------------060109030405070603000709--