Commit dab42382 authored by Bruce Momjian's avatar Bruce Momjian

Add index information to /contrib/pgstattuple:

This is an extension of pgstattuple to query information from indexes.
It supports btree, hash and gist. Gin is not supported. It scans only
index pages and does not read corresponding heap tuples. Therefore,
'dead_tuple' means the number of tuples with LP_DELETE flag.

Also, I added an experimental feature for btree indexes. It checks
fragmentation factor of indexes. If an leaf has the right link on the
next adjacent page in the file, it is assumed to be continuous (not
fragmented). It will help us to decide when to REINDEX.

ITAGAKI Takahiro
parent 591e90a4
......@@ -2,8 +2,8 @@ pgstattuple README 2002/08/29 Tatsuo Ishii
1. What is pgstattuple?
pgstattuple returns the table length, percentage of the "dead"
tuples of a table and other info. This may help users to determine
pgstattuple returns the relation length, percentage of the "dead"
tuples of a relation and other info. This may help users to determine
whether vacuum is necessary or not. Here is an example session:
test=# \x
......@@ -23,7 +23,7 @@ free_percent | 1.95
Here are explanations for each column:
table_len -- physical table length in bytes
table_len -- physical relation length in bytes
tuple_count -- number of live tuples
tuple_len -- total tuples length in bytes
tuple_percent -- live tuples in %
......@@ -40,7 +40,7 @@ free_percent -- free space in %
3. Using pgstattuple
pgstattuple may be called as a table function and is
pgstattuple may be called as a relation function and is
defined as follows:
CREATE OR REPLACE FUNCTION pgstattuple(text) RETURNS pgstattuple_type
......@@ -51,14 +51,20 @@ free_percent -- free space in %
AS 'MODULE_PATHNAME', 'pgstattuplebyid'
LANGUAGE C STRICT;
The argument is the table name (optionally it may be qualified)
or the OID of the table. Note that pgstattuple only returns
The argument is the relation name (optionally it may be qualified)
or the OID of the relation. Note that pgstattuple only returns
one row.
4. Notes
pgstattuple acquires only a read lock on the table. So concurrent
pgstattuple acquires only a read lock on the relation. So concurrent
update may affect the result.
pgstattuple judges a tuple is "dead" if HeapTupleSatisfiesNow()
returns false.
5. History
2006/06/28
Extended to work against indexes.
$PostgreSQL: pgsql/contrib/pgstattuple/README.pgstattuple.euc_jp,v 1.6 2006/02/27 16:09:49 petere Exp $
$PostgreSQL: pgsql/contrib/pgstattuple/README.pgstattuple.euc_jp,v 1.7 2006/07/06 02:18:07 momjian Exp $
pgstattuple README 2002/08/22 石井達夫
1. pgstattupleとは
pgstattupleは,UPDATEやDELETEで作られたテーブルのゴミ領域の大きさを,
テーブル自体の物理的な大きさに対するパーセンテージで返却します.つ
pgstattupleは,UPDATEやDELETEで作られたリレーションのゴミ領域の大きさを,
リレーション自体の物理的な大きさに対するパーセンテージで返却します.つ
まり,返却値が大きければ,それだけゴミも多いので,vacuumをかける必
要があるという判断の助けになるわけです.これ以外にもいろいろな情報
が返ります.
......@@ -26,7 +26,7 @@ free_percent | 1.95
各項目の説明です.
table_len -- テーブルの物理的な大きさ(バイト)
table_len -- リレーションの物理的な大きさ(バイト)
tuple_count -- タプル数
tuple_len -- タプル長の合計(バイト)
tuple_percent -- タプルの割合.table_lenに対するtuple_lenの比率.
......@@ -56,12 +56,12 @@ free_percent --
AS 'MODULE_PATHNAME', 'pgstattuple'
LANGUAGE C STRICT;
第一引数: テーブル
第一引数: リレーション
関数の戻りはpgstattuple_type型です.
pgstattupleはテーブルにAccessShareLockしかかけないので,
pgstattuple を実行中に該当テーブルに更新や削除が発生すると,正しく
pgstattupleはリレーションにAccessShareLockしかかけないので,
pgstattuple を実行中に該当リレーションに更新や削除が発生すると,正しく
ない結果を返す可能性があります.
pgstattupleがタプルを「ゴミ」と判断する基準は,
......@@ -75,6 +75,10 @@ free_percent --
5. 改訂履歴
2006/06/28
インデックスに対しても動作するように拡張。
2002/09/04
SRF変更に伴い,Tom Lane が修正インターフェイスの修正を行った.
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment