Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aWSZu-0007As-8K for pgsql-docs@arkaria.postgresql.org; Thu, 18 Feb 2016 17:41:22 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aWSZt-0005ec-RE for pgsql-docs@arkaria.postgresql.org; Thu, 18 Feb 2016 17:41:21 +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 1aWSZW-00047O-Ky; Thu, 18 Feb 2016 17:40:58 +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 1aWSZR-0003i8-9x; Thu, 18 Feb 2016 17:40:58 +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 u1IHemDt031926; Thu, 18 Feb 2016 12:40:48 -0500 From: Tom Lane To: =?UTF-8?B?5aSn5aGa5oay5Y+4?= cc: pgsql-docs@postgresql.org, pgsql-hackers@postgresql.org Subject: Re: The number of bytes is stored in index_size of pgstatindex() ? In-reply-to: <56C5B2C7.7010604@nttcom.co.jp> References: <56C5B2C7.7010604@nttcom.co.jp> Comments: In-reply-to =?UTF-8?B?5aSn5aGa5oay5Y+4?= message dated "Thu, 18 Feb 2016 21:02:15 +0900" Date: Thu, 18 Feb 2016 12:40:48 -0500 Message-ID: <31925.1455817248@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-docs Precedence: bulk Sender: pgsql-docs-owner@postgresql.org =?UTF-8?B?5aSn5aGa5oay5Y+4?= writes: > It seems that description of index_size that is returned by pgstatindex() is wrong. > The document says "Total number of pages in index". > But it looks like the number of bytes is stored in index_size. Hmm, you're right, because what the code does is values[j++] = psprintf(INT64_FORMAT, (indexStat.root_pages + indexStat.leaf_pages + indexStat.internal_pages + indexStat.deleted_pages + indexStat.empty_pages) * BLCKSZ); so the result is clearly measured in bytes not pages. I was going to just change the docs to say "Total index size in bytes", but then I noticed that this number is not that either: it does not count the metapage and therefore is BLCKSZ less than the true file size. As an example: regression=# select * from pgstatindex('tenk1_unique1'); version | tree_level | index_size | root_block_no | internal_pages | leaf_pages | empty_pages | deleted_pages | avg_leaf_density | leaf_fragmentation ---------+------------+------------+---------------+----------------+----------- -+-------------+---------------+------------------+-------------------- 2 | 1 | 237568 | 3 | 0 | 28 | 0 | 0 | 87.91 | 0 (1 row) regression=# select relfilenode from pg_class where relname = 'tenk1_unique1'; relfilenode ------------- 27449 (1 row) $ ls -l 27449 -rw-------. 1 postgres postgres 245760 Feb 17 18:58 27449 I think this is a bug and we ought to fix the code to include the metapage in the reported index_size. Thoughts? regards, tom lane -- Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-docs