postgresql/contrib/pgstattuple
Bruce Momjian dab42382f4 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
2006-07-06 02:18:07 +00:00
..
Makefile contrib uninstall scripts 2006-02-27 12:54:39 +00:00
README.pgstattuple Add index information to /contrib/pgstattuple: 2006-07-06 02:18:07 +00:00
README.pgstattuple.euc_jp Add index information to /contrib/pgstattuple: 2006-07-06 02:18:07 +00:00
pgstattuple.c Add index information to /contrib/pgstattuple: 2006-07-06 02:18:07 +00:00
pgstattuple.sql.in Clean up CREATE FUNCTION syntax usage in contrib and elsewhere, in 2006-02-27 16:09:50 +00:00
uninstall_pgstattuple.sql contrib uninstall scripts 2006-02-27 12:54:39 +00:00

README.pgstattuple.euc_jp

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

$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で作られたリレーションのゴミ領域の大きさを
   リレーション自体の物理的な大きさに対するパーセンテージで返却します.つ
   まり返却値が大きければそれだけゴミも多いのでvacuumをかける必
   要があるという判断の助けになるわけです.これ以外にもいろいろな情報
   が返ります.

test=# \x
Expanded display is on.
test=# select * from pgstattuple('pg_proc');
-[ RECORD 1 ]------+-------
table_len          | 458752
tuple_count        | 1470
tuple_len          | 438896
tuple_percent      | 95.67
dead_tuple_count   | 11
dead_tuple_len     | 3157
dead_tuple_percent | 0.69
free_space         | 8932
free_percent       | 1.95

各項目の説明です.

table_len		-- リレーションの物理的な大きさ(バイト)
tuple_count		-- タプル数
tuple_len		-- タプル長の合計(バイト)
tuple_percent		-- タプルの割合table_lenに対するtuple_lenの比率
dead_tuple_len		-- デッドタプル数
dead_tuple_percent	-- デッドタプルの割合table_lenに対するtuple_lenの比率
free_space		-- 再利用可能な領域(バイト)
free_percent		-- 再利用可能な領域table_lenに対するfree_spaceの比率

2. pgstattupleのインストール

   PostgreSQLが/usr/local/pgsqlにインストール済でありtestデータベー
   スにpgstattupleをインストールする場合の手順を示します

    $ make
    $ make install

    ユーザ定義関数を登録します.

    $ psql -e -f /usr/local/pgsql/share/contrib/pgstattuple.sql test


3. pgstattupleの使い方

   pgstattupleの呼び出し形式は以下です

   CREATE OR REPLACE FUNCTION pgstattuple(text) RETURNS pgstattuple_type
     AS 'MODULE_PATHNAME', 'pgstattuple'
     LANGUAGE C STRICT;

   第一引数: リレーション名

   関数の戻りはpgstattuple_type型です

   pgstattupleはリレーションにAccessShareLockしかかけないので
   pgstattuple を実行中に該当リレーションに更新や削除が発生すると,正しく
   ない結果を返す可能性があります.

   pgstattupleがタプルを「ゴミ」と判断する基準は
   HeapTupleSatisfiesNow()が偽を返したときです.

4. pgstattupleのライセンス条件について

   pgstattuple.cの冒頭に書いてある通りですまたpgstattuple は完全に無保
   証ですpgstattuple を使用したことによって生じるいかなる結果に関して
   も責任を負いません.

5. 改訂履歴

   2006/06/28

	インデックスに対しても動作するように拡張。

   2002/09/04

	SRF変更に伴いTom Lane	が修正インターフェイスの修正を行った.
	そのことをこのREADMEにも反映

   2002/08/23

	SRF(Set Returning Function)を使って7.3用に書き換え.

   2001/12/20 Tom Laneによる修正

   	Fix pgstattuple to acquire a read lock on the target table.  This
	prevents embarassments such as having the table dropped or truncated
	partway through the scan.  Also, fix free space calculation to include
	pages that currently contain no tuples.

   2001/10/01 PostgreSQL 7.2 用contrib moduleに登録

   2001/08/30 pgstattuple バージョン 0.1リリース