postgresql/contrib/pgstattuple
Tom Lane 282d2a03dd HOT updates. When we update a tuple without changing any of its indexed
columns, and the new version can be stored on the same heap page, we no longer
generate extra index entries for the new version.  Instead, index searches
follow the HOT-chain links to ensure they find the correct tuple version.

In addition, this patch introduces the ability to "prune" dead tuples on a
per-page basis, without having to do a complete VACUUM pass to recover space.
VACUUM is still needed to clean up dead index entries, however.

Pavan Deolasee, with help from a bunch of other people.
2007-09-20 17:56:33 +00:00
..
Makefile Fix PGXS conventions so that extensions can be built against Postgres 2007-06-26 22:05:04 +00:00
README.pgstattuple Add CVS comment for recent commit: 2007-05-17 21:43:19 +00:00
README.pgstattuple.euc_jp The functions bt_metap, bt_page_stats and bt_page_items had moved 2007-06-07 09:56:25 +00:00
pgstatindex.c Restrict pgstattuple functions to superusers. (This might be too strict, 2007-08-26 23:59:50 +00:00
pgstattuple.c HOT updates. When we update a tuple without changing any of its indexed 2007-09-20 17:56:33 +00:00
pgstattuple.sql.in Restrict pgstattuple functions to superusers. (This might be too strict, 2007-08-26 23:59:50 +00:00
uninstall_pgstattuple.sql Restrict pgstattuple functions to superusers. (This might be too strict, 2007-08-26 23:59:50 +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.9 2007/06/07 09:56:25 mha Exp $

pgstattuple README		2002/08/22 石井達夫

1. サポートされている関数

   pgstattuple
   -----------
   pgstattupleはUPDATEやDELETEで作られたリレーションのゴミ領域の大きさを
   リレーション自体の物理的な大きさに対するパーセンテージで返却します.つ
   まり返却値が大きければそれだけゴミも多いのでvacuumをかける必
   要があるという判断の助けになるわけです.これ以外にもいろいろな情報
   が返ります.
   pgstattuple() は、リレーションの長さや、タプルの"ゴミ領域"の割合などの
   情報を返却します。これらの情報は、vacuum が必要かどうか、ユーザが判断
   するのに役立つでしょう。例えば以下のような形になります:

       test=> \x
       Expanded display is on.
       test=> SELECT * FROM pgstattuple('pg_catalog.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の比率

   pg_relpages
   -----------
   pg_relpages() はリレーションのページ数を返却します.

   pgstatindex
   -----------
   pgstatindex() はインデックスに関する情報を返却します:

       test=> \x
       Expanded display is on.
       test=> SELECT * FROM pgstatindex('pg_cast_oid_index');
       -[ RECORD 1 ]------+------
       version            | 2
       tree_level         | 0
       index_size         | 8192
       root_block_no      | 1
       internal_pages     | 0
       leaf_pages         | 1
       empty_pages        | 0
       deleted_pages      | 0
       avg_leaf_density   | 50.27
       leaf_fragmentation | 0


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リリース