mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-04 00:02:52 -05:00 
			
		
		
		
	from contrib/pgstattuple to pageinspect. We've already fixed English documentation, but Japanese version does not catch up. ITAGAKI Takahiro
		
			
				
	
	
		
			130 lines
		
	
	
		
			3.9 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			130 lines
		
	
	
		
			3.9 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
$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リリース
 |