From: Tom Lane <tgl@sss.pgh.pa.us>
To: 大塚憲司 <otsuka.kenji@nttcom.co.jp>
Cc: pgsql-docs@postgresql.org
Cc: pgsql-hackers@postgresql.org
Subject: Re: The number of bytes is stored in index_size of pgstatindex() ?
Date: Thu, 18 Feb 2016 12:40:48 -0500
Message-ID: <31925.1455817248@sss.pgh.pa.us> (raw)
In-Reply-To: <56C5B2C7.7010604@nttcom.co.jp>
References: <56C5B2C7.7010604@nttcom.co.jp>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-docs>
=?UTF-8?B?5aSn5aGa5oay5Y+4?= <otsuka.kenji@nttcom.co.jp> 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
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 using the --to and --cc options:
reply via email
To: pgsql-docs@postgresql.org
Cc: tgl@sss.pgh.pa.us, otsuka.kenji@nttcom.co.jp, pgsql-hackers@postgresql.org
Subject: Re: The number of bytes is stored in index_size of pgstatindex() ?
In-Reply-To: <31925.1455817248@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