Documentation converted to reST
I had to drop the Japanese doc, but I'd be happy to restore it in reST format.
This commit is contained in:
parent
8bd08c4f73
commit
b3a86e3fee
1
doc/.gitignore
vendored
Normal file
1
doc/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/*.html
|
16
doc/Makefile
Normal file
16
doc/Makefile
Normal file
@ -0,0 +1,16 @@
|
||||
RSTCSS = $(shell python -c 'import docutils.writers.html4css1 as m; print m.Writer.default_stylesheet_path')
|
||||
RSTOPTS = --stylesheet-path=style.css,$(RSTCSS) --initial-header-level=2
|
||||
|
||||
HTML = $(patsubst %.rst,%.html,$(wildcard *.rst))
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
all : html
|
||||
|
||||
html : $(HTML)
|
||||
|
||||
%.html: %.rst style.css
|
||||
rst2html $(RSTOPTS) $< $@
|
||||
|
||||
clean:
|
||||
rm -f $(HTML)
|
@ -1,139 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html
|
||||
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
|
||||
<head>
|
||||
<link rel="icon" type="image/png" href="http://pgfoundry.org/images/elephant-icon.png" />
|
||||
<link rel="stylesheet" type="text/css" href="style.css" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title>pg_repack: Project Home Page</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<center><img style="border: none; margin-left: auto; margin-right: auto; " src="http://pgfoundry.org/images/elephantSmall.png" height="75" width="75" />
|
||||
<hr />
|
||||
<h1>pg_repack ホームページへようこそ</h1>
|
||||
<hr />
|
||||
</center>
|
||||
|
||||
<p>このプロジェクトでは <strong>pg_repack</strong> と <strong>pg_batch</strong> の2つのツールを頒布しています。</p>
|
||||
|
||||
<p>
|
||||
<strong>pg_repack</strong> は PostgreSQL のテーブルを再編成するシェルコマンドです。
|
||||
共有ロックや排他ロックを取得しないため、再編成中であっても行の参照や更新を行うことができます。
|
||||
このモジュールは CLUSTER や VACUUM FULL コマンドのより良い代替になります。
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>pg_batch</strong> は PostgreSQL のためのSQLジョブ実行プログラムです。
|
||||
ジョブ一覧生成するスクリプトを SQL として外部から与え、その出力 SQL をジョブとしてシリアルまたはパラレルに実行します。
|
||||
VACUUM を行うスクリプトが付属しており、"より良い vacuumdb" として利用できます。
|
||||
</p>
|
||||
|
||||
<p>この pg_repack プロジェクトは <a href="http://www.postgresql.org">PostgreSQL</a> コミュニティによる <a href="http://pgfoundry.org">pgFoundry</a> の中の<a href="http://pgfoundry.org/projects/repack">プロジェクト</a>です。</p>
|
||||
<ul>
|
||||
<li><a href="http://pgfoundry.org/frs/?group_id=1000411">ダウンロード</a> : ソースコードのほか、Windows 用バイナリもダウンロードできます。</li>
|
||||
<li><a href="http://pgfoundry.org/tracker/?group_id=1000411">バグレポート</li></li>
|
||||
<li><a href="http://pgfoundry.org/mail/?group_id=1000411">メーリングリスト</a> への参加</li>
|
||||
</ul>
|
||||
<div>
|
||||
<a href="index.html">Here is an English page.</a>
|
||||
</div>
|
||||
<hr />
|
||||
|
||||
<h2>ドキュメント</h2>
|
||||
|
||||
<ul>
|
||||
<li><a href="pg_repack-ja.html">pg_repack 1.1 ドキュメント</a></li>
|
||||
<li><a href="pg_batch-ja.html">pg_batch 1.2 ドキュメント</a></li>
|
||||
</ul>
|
||||
|
||||
<h2>実行時間</h2>
|
||||
<p>
|
||||
pg_repack とclusterdb の比較に示します。
|
||||
断片化のないソートされた状態 (not fragmented) では clusterdb のほうが高速ですが、完全に断片化した状態 (fully fragmented) では pg_repack が大幅に高速です。
|
||||
一般的に、再編成は断片化が進行した状態で実施されることを考えると、pg_repack は clusterdb よりも実行時間が短いと言えます。
|
||||
</p>
|
||||
|
||||
<center>
|
||||
<div style="margin: 2em">
|
||||
<img src="result.png" />
|
||||
</div>
|
||||
|
||||
<table border="1">
|
||||
<caption>測定環境</caption>
|
||||
<tr>
|
||||
<th>大項目</th>
|
||||
<th>小項目</th>
|
||||
<th>環境</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="3">ハードウェア</td>
|
||||
<td>CPU</td>
|
||||
<td>2 × Xeon 5160 3.00GHz (Dual core)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>メモリ</td>
|
||||
<td>2GB</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>ストレージ</td>
|
||||
<td>Ultra320 SCSI, 15000rpm (220GB)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="4">ソフトウェア</td>
|
||||
<td>OS</td>
|
||||
<td>RHEL 5.2 (64bit) 2.6.18-92.el5</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>DB</td>
|
||||
<td>PostgreSQL 8.3.3</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>pg_repack</td>
|
||||
<td>1.0.0</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>clusterdb</td>
|
||||
<td>clusterdb (PostgreSQL) 8.3.3</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="2">データ</td>
|
||||
<td>スキーマ</td>
|
||||
<td><code><pre>CREATE TABLE tbl (
|
||||
id bigserial PRIMARY KEY,
|
||||
seqkey timestamp NOT NULL,
|
||||
rndkey timestamp NOT NULL,
|
||||
filler char(75) NOT NULL
|
||||
);
|
||||
CREATE INDEX idx_seq ON tbl (seqkey);
|
||||
CREATE INDEX idx_rnd ON tbl (rndkey);</pre></code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>件数</td>
|
||||
<td>1650万件 (約2GB)</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</center>
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
<p class="footer">
|
||||
Portions Copyright (c) 2008-2011, NIPPON TELEGRAPH AND TELEPHONE CORPORATION<br />
|
||||
Portions Copyright (c) 2011, Itagaki Takahiro
|
||||
</p>
|
||||
|
||||
<script type="text/javascript">
|
||||
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
|
||||
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
try {
|
||||
var pageTracker = _gat._getTracker("UA-10244036-4");
|
||||
pageTracker._trackPageview();
|
||||
} catch(err) {}</script>
|
||||
</body>
|
||||
</html>
|
140
doc/index.html
140
doc/index.html
@ -1,140 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html
|
||||
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<link rel="icon" type="image/png" href="http://pgfoundry.org/images/elephant-icon.png" />
|
||||
<link rel="stylesheet" type="text/css" href="style.css" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title>pg_repack: Project Home Page</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<center><img style="border: none; margin-left: auto; margin-right: auto; " src="http://pgfoundry.org/images/elephantSmall.png" height="75" width="75" />
|
||||
<hr />
|
||||
<h1>Welcome to the pg_repack Project Home Page</h1>
|
||||
<hr />
|
||||
</center>
|
||||
|
||||
<p>
|
||||
This project provides two tools for PostgreSQL; <strong>pg_repack</strong> and <strong>pg_batch</strong>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>pg_repack</strong> can re-organize tables on a postgres database without any locks so that you can retrieve or update rows in tables being reorganized.
|
||||
The module is developed to be a better alternative of CLUSTER and VACUUM FULL.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>pg_batch</strong> is a SQL job executor program for PostgreSQL.
|
||||
It generates job list from an external SQL script file, and execute the jobs in serial or parallel.
|
||||
It can be used as "a better vacuumdb" with the attached script to run VACUUM.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The pg_repack project is a <a href="http://www.postgresql.org">PostgreSQL</a> Community project that is a part of the <a href="http://pgfoundry.org">pgFoundry</a>.
|
||||
</p>
|
||||
<p>
|
||||
The pgFoundry page for the project is at <a href="http://pgfoundry.org/projects/repack">http://pgfoundry.org/projects/repack</a>,
|
||||
where you can find <a href="http://pgfoundry.org/frs/?group_id=1000411">downloads</a>, documentation, bug reports, mailing lists, and a whole lot more.
|
||||
</p>
|
||||
<div>
|
||||
<a href="index-ja.html">日本語のページはこちら。</a>
|
||||
</div>
|
||||
<hr />
|
||||
|
||||
<h2>Documentation</h2>
|
||||
|
||||
<ul>
|
||||
<li><a href="pg_repack.html">pg_repack 1.1 documentation</a></li>
|
||||
<li><a href="pg_batch.html">pg_batch 1.2 documentation</a></li>
|
||||
</ul>
|
||||
|
||||
<h2>Execution time</h2>
|
||||
<p>
|
||||
Here is a comparison between pg_repack and clusterdb.
|
||||
Clusterdb is faster on not fragmented conditions, but pg_repack is faster on fully fragmented conditions.
|
||||
Since reorganization is needed only if tables are fragmented, pg_repack should be faster than clusterdb.
|
||||
</p>
|
||||
|
||||
<center>
|
||||
<div style="margin: 2em">
|
||||
<img src="result.png" />
|
||||
</div>
|
||||
|
||||
<table border="1">
|
||||
<caption>Configuration</caption>
|
||||
<tr>
|
||||
<th>Category</th>
|
||||
<th>Item</th>
|
||||
<th>Details</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="3">Hardware</td>
|
||||
<td>CPU</td>
|
||||
<td>2 * Xeon 5160 3.00GHz (Dual core)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Memory</td>
|
||||
<td>2GB</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Storage</td>
|
||||
<td>Ultra320 SCSI, 15000rpm (220GB)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="4">Software</td>
|
||||
<td>OS</td>
|
||||
<td>RHEL 5.2 (64bit) 2.6.18-92.el5</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>DB</td>
|
||||
<td>PostgreSQL 8.3.3</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>pg_repack</td>
|
||||
<td>1.0.0</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>clusterdb</td>
|
||||
<td>clusterdb (PostgreSQL) 8.3.3</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="2">Data</td>
|
||||
<td>Scheme</td>
|
||||
<td><code><pre>CREATE TABLE tbl (
|
||||
id bigserial PRIMARY KEY,
|
||||
seqkey timestamp NOT NULL,
|
||||
rndkey timestamp NOT NULL,
|
||||
filler char(75) NOT NULL
|
||||
);
|
||||
CREATE INDEX idx_seq ON tbl (seqkey);
|
||||
CREATE INDEX idx_rnd ON tbl (rndkey);</pre></code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Rows</td>
|
||||
<td>16.5 M rows (2GB)</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</center>
|
||||
|
||||
<hr />
|
||||
<p class="footer">
|
||||
Portions Copyright (c) 2008-2011, NIPPON TELEGRAPH AND TELEPHONE CORPORATION<br />
|
||||
Portions Copyright (c) 2011, Itagaki Takahiro
|
||||
</p>
|
||||
|
||||
<script type="text/javascript">
|
||||
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
|
||||
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
try {
|
||||
var pageTracker = _gat._getTracker("UA-10244036-4");
|
||||
pageTracker._trackPageview();
|
||||
} catch(err) {}</script>
|
||||
</body>
|
||||
</html>
|
@ -1,354 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>pg_repack</title>
|
||||
<link rel="home" title="pg_repack " href="index.html">
|
||||
<link rel="stylesheet" TYPE="text/css" href="style.css">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1 id="pg_repack">pg_repack 1.1.7</h1>
|
||||
<div class="navigation">
|
||||
<a href="index-ja.html">Top</a> >
|
||||
<a href="pg_repack-ja.html">pg_repack</a>
|
||||
</div>
|
||||
<hr>
|
||||
|
||||
<div class="index">
|
||||
<ol>
|
||||
<li><a href="#name">名前</a></li>
|
||||
<li><a href="#synopsis">概要</a></li>
|
||||
<li><a href="#description">説明</a></li>
|
||||
<li><a href="#examples">使用例</a></li>
|
||||
<li><a href="#options">オプション</a></li>
|
||||
<li><a href="#environment">環境変数</a></li>
|
||||
<li><a href="#restrictions">使用上の注意と制約</a></li>
|
||||
<li><a href="#details">詳細</a></li>
|
||||
<li><a href="#install">インストール方法</a></li>
|
||||
<li><a href="#requirement">動作環境</a></li>
|
||||
<li><a href="#releases">更新履歴</a></li>
|
||||
<li><a href="#seealso">関連項目</a></li>
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
<h2 id="name">名前</h2>
|
||||
pg_repack -- PostgreSQLデータベース内のテーブルに対して、参照/更新処理をブロックせずに再編成を行います。
|
||||
|
||||
<h2 id="synopsis">概要</h2>
|
||||
<p>
|
||||
pg_repack [OPTIONS]
|
||||
</p>
|
||||
|
||||
<p>オプション OPTIONS には以下を指定できます。
|
||||
詳細は<a href="#options">オプション</a>を参照してください。</p>
|
||||
<ul>
|
||||
<li>固有オプション<ul>
|
||||
<li>-a, --all : 全てのデータベースに対して実行します</li>
|
||||
<li>-o [--order-by] columns [,...]</li>
|
||||
<li>-n [--no-order]</li>
|
||||
<li>-t [--table] table</li>
|
||||
<li>-T [--wait-timeout] seconds</li>
|
||||
<li>-Z [--no-analyze]</li>
|
||||
</ul></li>
|
||||
<li>接続オプション<ul>
|
||||
<li>-d, --dbname=DBNAME : 接続するデータベース</li>
|
||||
<li>-h, --host=HOSTNAME : データベースサーバホスト、またはソケットディレクトリ</li>
|
||||
<li>-p, --port=PORT : データベースサーバのポート</li>
|
||||
<li>-U, --username=USERNAME : このユーザとして接続します</li>
|
||||
<li>-w, --no-password : パスワードの入力を促しません</li>
|
||||
<li>-W, --password : パスワード入力を強制します</li>
|
||||
</ul></li>
|
||||
<li>一般オプション<ul>
|
||||
<li>-e, --echo : サーバに送信するSQLを表示します</li>
|
||||
<li>-E, --elevel=LEVEL : ログ出力レベルを設定します</li>
|
||||
<li>--help : ヘルプを表示し、終了します</li>
|
||||
<li>--version : バージョン情報を出力し、終了します</li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
|
||||
<h2 id="description">説明</h2>
|
||||
<p>pg_repack は、PostgreSQLデータベース内のテーブルを再編成(行の並び替え)するユーティリティです。
|
||||
<a href="http://www.postgresql.jp/document/current/html/app-clusterdb.html">clusterdb</a> と異なり、参照/更新処理をブロックしません。
|
||||
再編成の方式として、以下のいずれか1つを選択できます。</p>
|
||||
<ul>
|
||||
<li>オンライン CLUSTER (cluster index順に行を並び替える)</li>
|
||||
<li>ユーザの指定した順に行を並び替える</li>
|
||||
<li>オンライン VACUUM FULL (行の詰め合わせを行う)</li>
|
||||
</ul>
|
||||
<p>このユーティリティを使用するためには、以下のことに注意をしてください。</p>
|
||||
<ul>
|
||||
<li>このユーティリティは、スーパーユーザのみが実行することができます。</li>
|
||||
<li>対象のテーブルはPRIMARY KEYを持っている必要があります。</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="examples">例</h2>
|
||||
<p>testというデータベースをオンライン CLUSTER するには、下記のコマンドを実行します。</p>
|
||||
<PRE><SAMP>$ </SAMP><KBD>pg_repack test</KBD></PRE>
|
||||
<p>testという名前のデータベースのfooという1つのテーブルに対してオンライン VACUUM FULL を行うには、下記のコマンドを実行します。</p>
|
||||
<PRE><SAMP>$ </SAMP><KBD>pg_repack --no-order --table foo -d test</KBD></PRE><p>
|
||||
</p>
|
||||
|
||||
<h2 id="options">オプション</h2>
|
||||
<p>pg_repack では、下記のコマンドライン引数を指定できます。</p>
|
||||
|
||||
<h3>固有オプション</h3>
|
||||
<p>pg_repack を実行する対象と並び替えの基準を指定するパラメータです。
|
||||
何も指定されていない場合は、cluster index順にオンライン CLUSTER を行います。
|
||||
この2つを同時に指定することはできません。
|
||||
</p>
|
||||
|
||||
<dl>
|
||||
<dt>-n<br>--no-order</dt>
|
||||
<dd>オンライン VACUUM FULL の処理を行います。</dd>
|
||||
|
||||
<dt>-o columns [,...]<br>
|
||||
--order-by columns [,...]</dt>
|
||||
<dd>指定したカラムをキーにオンライン CLUSTER を行います。</dd>
|
||||
|
||||
<dt>
|
||||
-t table<br>
|
||||
--table=table
|
||||
</dt>
|
||||
<dd>オンライン CLUSTER 、または、オンライン VACUUM FULL を行うテーブルを指定します。
|
||||
このオプションが指定されていない場合は、対象となったデータベースに存在する全ての対象テーブルに対して処理を行います。
|
||||
</dd>
|
||||
|
||||
<dt>
|
||||
-T seconds<br>
|
||||
--wait-timeout=seconds
|
||||
</dt>
|
||||
<dd>
|
||||
再編成完了直前に一瞬だけ排他ロックを取得しますが、この排他ロックが取得できるまで待機する秒数を指定します。
|
||||
この秒数が経過してもロックが取得できない場合には、対象のテーブルにアクセスしている他の全てのクエリを取り消します。
|
||||
また、サーバのバージョンが 8.4 またはそれ以降の場合には、指定した秒数の2倍経過してもロックを取得できない場合には、強制的に切断します。
|
||||
デフォルトは60秒です。
|
||||
</dd>
|
||||
|
||||
<dt>-Z<br>--no-analyze</dt>
|
||||
<dd>再編成後に ANALYZE を行いません。
|
||||
このオプションが指定されていない場合は、再編成後に ANALYZE します。</dd>
|
||||
|
||||
</dl>
|
||||
|
||||
<h3>接続オプション</h3>
|
||||
<p>
|
||||
PostgreSQLに接続するためのパラメータです。
|
||||
--allと--dbnameまたは--tableを同時に指定することはできません。
|
||||
</p>
|
||||
|
||||
<dl>
|
||||
<dt>-a<br>--all</dt>
|
||||
<dd>対象となる全てのデータベースに対してオンライン CLUSTER、または、オンラインVACUUM FULLを行います。</dd>
|
||||
|
||||
<dt>
|
||||
-d DBNAME<br>
|
||||
--dbname=DBNAME
|
||||
</dt>
|
||||
<dd>オンライン CLUSTER、または、オンライン VACUUM FULL を行うデータベース名を指定します。
|
||||
データベース名が指定されておらず、-a(または--all)も指定されていない場合、
|
||||
データベース名はPGDATABASE環境変数から読み取られます。
|
||||
この変数も設定されていない場合は、接続時に指定したユーザ名が使用されます。</dd>
|
||||
|
||||
<dt>-h HOSTNAME<br>
|
||||
--host=HOSTNAME</dt>
|
||||
<dd>サーバが稼働しているマシンのホスト名を指定します。ホスト名がスラッシュから始まる場合、Unixドメインソケット用のディレクトリとして使用されます。</dd>
|
||||
|
||||
<dt>-p PORT<br>
|
||||
--port=PORT</dt>
|
||||
<dd>サーバが接続を監視するTCPポートもしくはUnixドメインソケットファイルの拡張子を指定します。</dd>
|
||||
|
||||
<dt>-U USERNAME<br>
|
||||
--username=USERNAME</dt>
|
||||
<dd>接続するユーザ名を指定します。</dd>
|
||||
|
||||
<dt>-w<br>
|
||||
--no-password</dt>
|
||||
<dd>
|
||||
パスワードの入力を促しません。
|
||||
サーバがパスワード認証を必要とし、かつ、.pgpassファイルなどの他の方法が利用できない場合、接続試行は失敗します。
|
||||
バッチジョブやパスワードを入力するユーザが存在しない場合にこのオプションは有用かもしれません。
|
||||
</dd>
|
||||
|
||||
<dt>-W<br>
|
||||
--password</dt>
|
||||
<dd>データベースに接続する前に、強制的にパスワード入力を促します。</dd>
|
||||
<dd>
|
||||
サーバがパスワード認証を要求する場合 自動的にパスワード入力を促しますので、これが重要になることはありません。
|
||||
しかし、サーバにパスワードが必要かどうかを判断するための接続試行を無駄に行います。
|
||||
こうした余計な接続試行を防ぐために -W の入力が有意となる場合もあります。
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h3>一般オプション</h3>
|
||||
<dl>
|
||||
<dt>-e<br>--echo</dt>
|
||||
<dd>サーバに送信するSQLを表示します。</dd>
|
||||
<dt>-E<br>--elevel</dt>
|
||||
<dd>ログ出力レベルを設定します。
|
||||
DEBUG, INFO, NOTICE, WARNING, ERROR, LOG, FATAL, PANIC から選択します。
|
||||
デフォルトは INFO です。</dd>
|
||||
<dt>--help</dt>
|
||||
<dd>使用方法について表示します。</dd>
|
||||
<dt>--version</dt>
|
||||
<dd>バージョン情報を表示します。</dd>
|
||||
</dl>
|
||||
|
||||
<h2 id="environment">環境変数</h2>
|
||||
<dl>
|
||||
<dt>
|
||||
PGDATABASE<br>
|
||||
PGHOST<br>
|
||||
PGPORT<br>
|
||||
PGUSER
|
||||
</dt>
|
||||
<dd>デフォルトの接続パラメータです。</dd>
|
||||
</dl>
|
||||
|
||||
<p>
|
||||
また、このユーティリティは、他のほとんどの PostgreSQL ユーティリティと同様、libpq でサポートされる環境変数を使用します。詳細については、<a href="http://www.postgresql.jp/document/current/html/libpq-envars.html">環境変数の項目</a>を参照してください。
|
||||
</p>
|
||||
|
||||
<h2 id="diagnostics">トラブルシューティング</h2>
|
||||
<p>pg_repack の実行に失敗した場合にエラーが表示されます。
|
||||
想像されるエラー原因と対処を示します。</p>
|
||||
<p>致命的なエラーで終了した場合、手動によるクリーンアップを行う必要があります。
|
||||
クリーンアップは、エラーが発生したデータベースに対して、$PGHOME/share/contrib/uninstall_pg_repack.sql を実行し、その後、$PGHOME/share/contrib/pg_repack.sql を実行します。</p>
|
||||
|
||||
<dl>
|
||||
<dt>pg_repack : repack database "template1" ... skipped</dt>
|
||||
<dd>--allオプションを指定した際に、pg_repack がインストールされていないデータベースに対して表示されます。</dd>
|
||||
<dd>pg_repack スキーマのインストールを行ってください。</dd>
|
||||
|
||||
<dt>ERROR: pg_repack is not installed</dt>
|
||||
<dd>--dbnameで指定したデータベースにpg_repack がインストールされていません。</dd>
|
||||
<dd>pg_repack のインストールを行ってください。</dd>
|
||||
|
||||
<dt>ERROR: relation "table" has no primary key</dt>
|
||||
<dd>指定したテーブルにPRIMARY KEYが存在していません。</dd>
|
||||
<dd>対象のテーブルにPRIMARY KEYの作成を行ってください。(ALTER TABLE ADD PRIMARY KEY)</dd>
|
||||
|
||||
<dt>ERROR: relation "table" has no cluster key</dt>
|
||||
<dd>指定したテーブルに CLUSTER KEYが存在していません。</dd>
|
||||
<dd>対象のテーブルに CLUSTER KEYの作成を行ってください。(ALTER TABLE CLUSTER)</dd>
|
||||
|
||||
<dt>pg_repack : query failed: ERROR: column "col" does not exist</dt>
|
||||
<dd>--order-by で指定したカラムが対象のテーブルに存在していません。</dd>
|
||||
<dd>対象のテーブルに存在するカラムを指定してください。</dd>
|
||||
|
||||
<dt>ERROR: permission denied for schema repack</dt>
|
||||
<dd>操作を行おうとした対象に権限がありません。</dd>
|
||||
<dd>スーパーユーザで操作を行ってください。</dd>
|
||||
|
||||
<dt>pg_repack : query failed: ERROR: trigger "z_repack_trigger" for relation "tbl" already exists</dt>
|
||||
<dd>操作を行おうとした対象にpg_repack が処理のために作成するトリガと同名のものが存在しています。</dd>
|
||||
<dd>トリガの改名か削除を行ってください。</dd>
|
||||
|
||||
<dt>pg_repack : trigger conflicted for tbl</dt>
|
||||
<dd>操作を行おうとした対象にpg_repack が処理のために作成するトリガより後に実行されるトリガが存在しています。</dd>
|
||||
<dd>トリガの改名か削除を行ってください。</dd>
|
||||
</dl>
|
||||
|
||||
<h2 id="restrictions">使用上の注意と制約</h2>
|
||||
<p>pg_repack を使用する際には、以下の制約があります。以下の制約に関する操作を行った場合の動作は保証されません。注意してください。</p>
|
||||
|
||||
<h3>一時テーブルへの操作</h3>
|
||||
<p>pg_repack では、一時テーブルは操作の対象外です。</p>
|
||||
|
||||
<h3>GiSTインデックスの使用</h3>
|
||||
<p>インデックス種別がGiSTとなっているインデックスがクラスタインデックスとなっている
|
||||
テーブルはpg_repack コマンドを使用して操作を行うことはできません。
|
||||
これは、GiSTインデックスのソート順序は一意ではないため、ORDER BYによる
|
||||
ソートが行えないためです。</p>
|
||||
|
||||
<h3>DDLコマンドの発行</h3>
|
||||
<p>
|
||||
pg_repack の実行中には、VACUUM と ANALYZE <STRONG>以外</STRONG> のDDL操作は行わないでください。
|
||||
多くの場合、pg_repack は失敗しロールバックされます。
|
||||
しかし、以下の操作ではデータが破損するため、非常に危険です。
|
||||
</p>
|
||||
|
||||
<dl>
|
||||
<dt>TRUNCATE</dt>
|
||||
<dd>削除した行が pg_repack 実行後には復元しています。操作結果が消失します。</dd>
|
||||
|
||||
<dt>CREATE INDEX</dt>
|
||||
<dd>スワップされない索引が残る可能性があります。データの不整合が生じます。</dd>
|
||||
|
||||
<dt>ALTER TABLE ... ADD COLUMN</dt>
|
||||
<dd>追加された値が全てNULLに置換されてしまう可能性があります。データが消失します。</dd>
|
||||
|
||||
<dt>ALTER TABLE ... ALTER COLUMN TYPE</dt>
|
||||
<dd>実行するとスキーマで定義された型と実際の格納状態に齟齬をきたします。データの不整合が生じます。</dd>
|
||||
|
||||
<dt>ALTER TABLE ... SET TABLESPACE</dt>
|
||||
<dd>pg_repack 実行後にrelfilenodeとの不整合が起こるため、対象のテーブルに対する参照/更新操作時にエラーが発生します。</dd>
|
||||
</dl>
|
||||
|
||||
<h2 id="details">詳細</h2>
|
||||
<p>pg_repack は repack スキーマに作業用テーブルを作成し、そこでデータの並び替えを行います。
|
||||
最後にシステムカタログを直接書き換えることで、元のテーブルと名前を交換しています。</p>
|
||||
|
||||
<h2 id="install">インストール方法</h2>
|
||||
<p>
|
||||
UNIX や Linux では、make を実行すると自動的に pgxs を使ってビルドできます。
|
||||
前もって PostgreSQL 開発用パッケージ (postgresql-devel 等) をインストールし、pg_config にパスを通してください。
|
||||
</p>
|
||||
<pre>$ cd pg_repack
|
||||
$ make
|
||||
$ su
|
||||
$ make install</pre>
|
||||
<p>
|
||||
Windows では Microsoft Visual C++ 2010 でビルドできます。
|
||||
msvc フォルダ内にプロジェクトファイルがあります。
|
||||
</p>
|
||||
|
||||
<p>その後、データベースに関数を登録します。</p>
|
||||
<pre>$ pg_ctl start
|
||||
$ psql -f $PGSHARE/contrib/pg_repack.sql -d your_database</pre>
|
||||
|
||||
<p>(注意: <code>CREATE EXTENSION</code> はまだサポートしていません。)</p>
|
||||
|
||||
<h2 id="requirement">動作環境</h2>
|
||||
<dl>
|
||||
<dt>PostgreSQLバージョン</dt>
|
||||
<dd>PostgreSQL 8.2, 8.3, 8.4, 9.0, 9.1, 9.2</dd>
|
||||
<dt>OS</dt>
|
||||
<dd>RHEL 5.2, Windows XP SP3</dd>
|
||||
<dt>ディスク容量</dt>
|
||||
<dd>処理対象のテーブル、インデックスサイズの2倍以上のディスク空き容量 (対象が1GBならば、さらに追加で2GB)</dd>
|
||||
</dl>
|
||||
|
||||
<h2 id="releases">更新履歴</h2>
|
||||
<ul>
|
||||
<li>1.1.7 (2011-08-07)<ul>
|
||||
<li>バグ修正: DROPされた列を持つテーブルを再編成した場合に、そのテーブルを使用するビューや関数が破損する可能性があった。</li>
|
||||
<li>PostgreSQL 9.1, 9.2dev のサポート (EXTENSION はまだ)</li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
|
||||
<h2 id="seealso">関連項目</h2>
|
||||
<a href="http://www.postgresql.jp/document/current/html/app-clusterdb.html">clusterdb</a>,
|
||||
<a href="http://www.postgresql.jp/document/current/html/app-vacuumdb.html">vacuumdb</a>
|
||||
|
||||
<hr>
|
||||
<div class="navigation">
|
||||
<a href="index-ja.html">Top</a> >
|
||||
<a href="pg_repack-ja.html">pg_repack</a>
|
||||
</div>
|
||||
<p class="footer">
|
||||
Portions Copyright (c) 2008-2011, NIPPON TELEGRAPH AND TELEPHONE CORPORATION<br>
|
||||
Portions Copyright (c) 2011, Itagaki Takahiro
|
||||
</p>
|
||||
|
||||
<script type="text/javascript">
|
||||
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
|
||||
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
try {
|
||||
var pageTracker = _gat._getTracker("UA-10244036-4");
|
||||
pageTracker._trackPageview();
|
||||
} catch(err) {}</script>
|
||||
</body>
|
||||
</html>
|
@ -1,345 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>pg_repack</title>
|
||||
<link rel="home" title="pg_repack " href="index.html">
|
||||
<link rel="stylesheet" TYPE="text/css" href="style.css">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1 id="pg_repack">pg_repack 1.1.7</h1>
|
||||
<div class="navigation">
|
||||
<a href="index.html">Top</a> >
|
||||
<a href="pg_repack.html">pg_repack</a>
|
||||
</div>
|
||||
<hr>
|
||||
|
||||
<div class="index">
|
||||
<ol>
|
||||
<li><a href="#name">Name</a></li>
|
||||
<li><a href="#synopsis">Synopsis</a></li>
|
||||
<li><a href="#description">Description</a></li>
|
||||
<li><a href="#examples">Examples</a></li>
|
||||
<li><a href="#options">Options</a></li>
|
||||
<li><a href="#environment">Environment</a></li>
|
||||
<li><a href="#restrictions">Restrictions</a></li>
|
||||
<li><a href="#details">Details</a></li>
|
||||
<li><a href="#install">Installations</a></li>
|
||||
<li><a href="#requirement">Requirements</a></li>
|
||||
<li><a href="#releases">Releases</a></li>
|
||||
<li><a href="#seealso">See Also</a></li>
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
<h2 id="name">Name</h2>
|
||||
pg_repack -- Reorganize tables in PostgreSQL databases without any locks.
|
||||
|
||||
<h2 id="synopsis">Synopsis</h2>
|
||||
<p>
|
||||
pg_repack [OPTIONS]
|
||||
</p>
|
||||
|
||||
<p>The following options can be specified in OPTIONS.
|
||||
See also "<a href="#options">Options</a>" for details.</p>
|
||||
<ul>
|
||||
<li>Reorg Options<ul>
|
||||
<li>-a, --all : reorganize all databases</li>
|
||||
<li>-o [--order-by] columns [,...]</li>
|
||||
<li>-n [--no-order]</li>
|
||||
<li>-t [--table] table</li>
|
||||
<li>-T [--wait-timeout] seconds</li>
|
||||
<li>-Z [--no-analyze]</li>
|
||||
</ul></li>
|
||||
<li>Connection Options<ul>
|
||||
<li>-d, --dbname=DBNAME : database to connect</li>
|
||||
<li>-h, --host=HOSTNAME : database server host or socket directory</li>
|
||||
<li>-p, --port=PORT : database server port</li>
|
||||
<li>-U, --username=USERNAME : user name to connect as</li>
|
||||
<li>-w, --no-password : never prompt for password</li>
|
||||
<li>-W, --password : force password prompt</li>
|
||||
</ul></li>
|
||||
<li>Generic Options<ul>
|
||||
<li>-e, --echo : echo queries</li>
|
||||
<li>-E, --elevel=LEVEL : set output message level</li>
|
||||
<li>--help : show the help, then exit</li>
|
||||
<li>--version : output version information, then exit</li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
|
||||
<h2 id="description">Description</h2>
|
||||
<p>pg_repack is an utility program to reorganize tables in PostgreSQL databases.
|
||||
Unlike <a href="http://developer.postgresql.org/pgdocs/postgres/app-clusterdb.html">clusterdb</a>, it doesn't block any selections and updates during reorganization.
|
||||
You can choose one of the following methods to reorganize.</p>
|
||||
<ul>
|
||||
<li>Online CLUSTER (ordered by cluster index)</li>
|
||||
<li>Ordered by specified columns</li>
|
||||
<li>Online VACUUM FULL (packing rows only)</li>
|
||||
</ul>
|
||||
<p>NOTICE:</p>
|
||||
<ul>
|
||||
<li>Only superusers can use the utility.</li>
|
||||
<li>Target table must have PRIMARY KEY.</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="examples">Examples</h2>
|
||||
<p>Execute the following command to perform an online CLUSTER of all tables in test database.</p>
|
||||
<PRE><SAMP>$ </SAMP><KBD>pg_repack test</KBD></PRE>
|
||||
<p>Execute the following command to perform an online VACUUM FULL to foo table in test database.</p>
|
||||
<PRE><SAMP>$ </SAMP><KBD>pg_repack --no-order --table foo -d test</KBD></PRE><p>
|
||||
</p>
|
||||
|
||||
<h2 id="options">Options</h2>
|
||||
<p>pg_repack has the following command line options:</p>
|
||||
|
||||
<h3>Reorg Options</h3>
|
||||
<p>Options to order rows.
|
||||
If not specified, pg_repack performs an online CLUSTER using cluster indexes.
|
||||
Only one option can be specified.
|
||||
|
||||
You may also specify target tables or databases.
|
||||
</p>
|
||||
|
||||
<dl>
|
||||
<dt>-n<br>--no-order</dt>
|
||||
<dd>Do online VACUUM FULL.</dd>
|
||||
|
||||
<dt>-o columns [,...]<br>
|
||||
--order-by=columns [,...]</dt>
|
||||
<dd>Do online CLUSTER ordered by specified columns.</dd>
|
||||
|
||||
<dt>
|
||||
-t table<br>
|
||||
--table=table
|
||||
</dt>
|
||||
<dd>Reorganize table only. If you don't specify this option, all tables in specified databases are reorganized.</dd>
|
||||
|
||||
<dt>
|
||||
-T seconds<br>
|
||||
--wait-timeout=seconds
|
||||
</dt>
|
||||
<dd>
|
||||
pg_repack needs to take an exclusive lock at the end of the reorganization.
|
||||
This setting controls how long it wait for acquiring the lock in seconds.
|
||||
If the lock cannot be taken even after the duration, pg_repack forces to cancel conflicted queries.
|
||||
Also, if the server version is 8.4 or newer, pg_repack forces to disconnect conflicted backends after twice time passed.
|
||||
The default is 60 seconds.
|
||||
</dd>
|
||||
|
||||
<dt>-Z<br>--no-analyze</dt>
|
||||
<dd>Disable ANALYZE after the reorganization.
|
||||
If not specified, run ANALYZE after the reorganization.</dd>
|
||||
|
||||
</dl>
|
||||
|
||||
<h3>Connection Options</h3>
|
||||
<p>
|
||||
Options to connect to servers.
|
||||
You cannot use --all and --dbname or --table together.
|
||||
</p>
|
||||
|
||||
<dl>
|
||||
<dt>-a<br>--all</dt>
|
||||
<dd>Reorganize all databases.</dd>
|
||||
|
||||
<dt>
|
||||
-d dbname<br>
|
||||
--dbname dbname
|
||||
</dt>
|
||||
<dd>Specifies the name of the database to be reorganized. If this is not specified and -a (or --all) is not used, the database name is read from the environment variable PGDATABASE. If that is not set, the user name specified for the connection is used. </dd>
|
||||
|
||||
<dt>-h host<br>
|
||||
--host host</dt>
|
||||
<dd>Specifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for the Unix domain socket. </dd>
|
||||
|
||||
<dt>-p port<br>
|
||||
--port port</dt>
|
||||
<dd>Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections.</dd>
|
||||
|
||||
<dt>-U username<br>
|
||||
--username username</dt>
|
||||
<dd>User name to connect as. </dd>
|
||||
|
||||
<dt>-w<br>
|
||||
--no-password</dt>
|
||||
<dd>
|
||||
Never issue a password prompt.
|
||||
If the server requires password authentication and a password is not available by other means such as a .pgpass file, the connection attempt will fail.
|
||||
This option can be useful in batch jobs and scripts where no user is present to enter a password.
|
||||
</dd>
|
||||
|
||||
<dt>-W<br>
|
||||
--password</dt>
|
||||
<dd>Force the program to prompt for a password before connecting to a database.</dd>
|
||||
<dd>This option is never essential, since the program will automatically prompt for a password if the server demands password authentication. However, pg_repack will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing -W to avoid the extra connection attempt. </dd>
|
||||
</dl>
|
||||
|
||||
<h3>Generic Options</h3>
|
||||
<dl>
|
||||
<dt>-e<br>--echo</dt>
|
||||
<dd>Echo commands sent to server.</dd>
|
||||
<dt>-E<br>--elevel</dt>
|
||||
<dd>Choose the output message level from DEBUG, INFO, NOTICE, WARNING, ERROR, LOG, FATAL, and PANIC.
|
||||
The default is INFO.</dd>
|
||||
<dt>--help</dt>
|
||||
<dd>Show usage of the program.</dd>
|
||||
<dt>--version</dt>
|
||||
<dd>Show the version number of the program.</dd>
|
||||
</dl>
|
||||
|
||||
<h2 id="environment">Environment</h2>
|
||||
<dl>
|
||||
<dt>
|
||||
PGDATABASE<br>
|
||||
PGHOST<br>
|
||||
PGPORT<br>
|
||||
PGUSER
|
||||
</dt>
|
||||
<dd>Default connection parameters</dd>
|
||||
</dl>
|
||||
<p>This utility, like most other PostgreSQL utilities, also uses the environment variables supported by libpq (see <a href="http://developer.postgresql.org/pgdocs/postgres/libpq-envars.html">Environment Variables</a>).</p>
|
||||
|
||||
<h2 id="diagnostics">Diagnostics</h2>
|
||||
<p>Error messages are reported when pg_repack fails.
|
||||
The following list shows the cause of errors.</p>
|
||||
<p>You need to cleanup by hand after fatal errors.
|
||||
To cleanup, execute $PGHOME/share/contrib/uninstall_pg_repack.sql to the database where the error occured and then execute $PGHOME/share/contrib/pg_repack.sql. (Do uninstall and reinstall.)</p>
|
||||
|
||||
<dl>
|
||||
<dt>pg_repack : repack database "template1" ... skipped</dt>
|
||||
<dd>pg_repack is not installed in the database when --all option is specified.</dd>
|
||||
<dd>Do register pg_repack to the database.</dd>
|
||||
|
||||
<dt>ERROR: pg_repack is not installed</dt>
|
||||
<dd>pg_repack is not installed in the database specified by --dbname.</dd>
|
||||
<dd>Do register pg_repack to the database.</dd>
|
||||
|
||||
<dt>ERROR: relation "table" has no primary key</dt>
|
||||
<dd>The target table doesn't have PRIMARY KEY.</dd>
|
||||
<dd>Define PRIMARY KEY to the table. (ALTER TABLE ADD PRIMARY KEY)</dd>
|
||||
|
||||
<dt>ERROR: relation "table" has no cluster key</dt>
|
||||
<dd>The target table doesn't have CLUSTER KEY.</dd>
|
||||
<dd>Define CLUSTER KEY to the table. (ALTER TABLE CLUSTER)</dd>
|
||||
|
||||
<dt>pg_repack : query failed: ERROR: column "col" does not exist</dt>
|
||||
<dd>The target table doesn't have columns specified by --order-by option.</dd>
|
||||
<dd>Specify existing columns.</dd>
|
||||
|
||||
<dt>ERROR: permission denied for schema repack</dt>
|
||||
<dd>Permission error.</dd>
|
||||
<dd>pg_repack must be executed by superusers.</dd>
|
||||
|
||||
<dt>pg_repack : query failed: ERROR: trigger "z_repack_trigger" for relation "tbl" already exists</dt>
|
||||
<dd>The target table already has a trigger named "z_repack_trigger".</dd>
|
||||
<dd>Delete or rename the trigger.</dd>
|
||||
|
||||
<dt>pg_repack : trigger conflicted for tbl</dt>
|
||||
<dd>The target table already has a trigger which follows by "z_repack_trigger" in alphabetical order.</dd>
|
||||
<dd>Delete or rename the trigger.</dd>
|
||||
</dl>
|
||||
|
||||
<h2 id="restrictions">Restrictions</h2>
|
||||
<p>pg_repack has the following restrictions.
|
||||
Be careful to avoid data corruptions.</p>
|
||||
|
||||
<h3>Temp tables</h3>
|
||||
<p>pg_repack cannot reorganize temp tables.</p>
|
||||
|
||||
<h3>GiST indexes</h3>
|
||||
<p>pg_repack cannot reorganize tables using GiST indexes.</p>
|
||||
|
||||
<h3>DDL commands</h3>
|
||||
<p>You cannot do DDL commands <strong>except</strong> VACUUM and ANALYZE during pg_repack.
|
||||
In many cases pg_repack will fail and rollback collectly, but there are some cases which may result in data-corruption .</p>
|
||||
|
||||
<dl>
|
||||
<dt>TRUNCATE</dt>
|
||||
<dd>TRUNCATE is lost. Deleted rows still exist after pg_repack.</dd>
|
||||
|
||||
<dt>CREATE INDEX</dt>
|
||||
<dd>It causes index corruptions.</dd>
|
||||
|
||||
<dt>ALTER TABLE ... ADD COLUMN</dt>
|
||||
<dd>It causes lost of data. Newly added columns are initialized with NULLs.</dd>
|
||||
|
||||
<dt>ALTER TABLE ... ALTER COLUMN TYPE</dt>
|
||||
<dd>It causes data corruptions.</dd>
|
||||
|
||||
<dt>ALTER TABLE ... SET TABLESPACE</dt>
|
||||
<dd>It causes data corruptions by wrong relfilenode.</dd>
|
||||
</dl>
|
||||
|
||||
<h2 id="details">Details</h2>
|
||||
<p>pg_repack creates a work table in the repack schema and sorts the rows in this table.
|
||||
Then, it updates the system catalogs directly to swap the work table and the original one.</p>
|
||||
|
||||
<h2 id="install">Installations</h2>
|
||||
<p>
|
||||
pg_repack can be built with "make" on UNIX or Linux.
|
||||
pgxs build framework is used automatically.
|
||||
Before building, you might need to install postgres packages for developer (postgresql-devel, etc.)
|
||||
and add <code>pg_config</code> to your $PATH.
|
||||
</p>
|
||||
<pre>$ cd pg_repack
|
||||
$ make
|
||||
$ su
|
||||
$ make install</pre>
|
||||
<p>
|
||||
You can also use Microsoft Visual C++ 2010 to build the program on Windows.
|
||||
There are project files in the msvc folder.
|
||||
</p>
|
||||
|
||||
<p>Start PostgreSQL and execute the script to register functions to your database.</p>
|
||||
<pre>$ pg_ctl start
|
||||
$ psql -f $PGSHARE/contrib/pg_repack.sql -d your_database</pre>
|
||||
|
||||
<p>(NOTE: <code>CREATE EXTENSION</code> is not supported yet.)</p>
|
||||
|
||||
<h2 id="requirement">Requirements</h2>
|
||||
<dl>
|
||||
<dt>PostgreSQL versions</dt>
|
||||
<dd>PostgreSQL 8.2, 8.3, 8.4, 9.0, 9.1, 9.2</dd>
|
||||
<dt>OS</dt><dd>RHEL 5.2, Windows XP SP3</dd>
|
||||
<dt>Disks</dt><dd>Requires free disk space twice as large as the target
|
||||
table(s) and indexes. For example, if the total size of the tables and
|
||||
indexes to be reorganized is 1GB, an additional 2GB of disk space is
|
||||
required.</dd>
|
||||
</dl>
|
||||
|
||||
<h2 id="releases">Releases</h2>
|
||||
<ul>
|
||||
<li>1.1.7 (2011-08-07)<ul>
|
||||
<li>Bugfix: VIEWs and FUNCTIONs could be corrupted that used a reorganized table which has a dropped column.</li>
|
||||
<li>Supports PostgreSQL 9.1 and 9.2dev. (but EXTENSION is not yet)</li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
|
||||
<h2 id="seealso">See Also</h2>
|
||||
<a href="http://developer.postgresql.org/pgdocs/postgres/app-clusterdb.html">clusterdb</a>,
|
||||
<a href="http://developer.postgresql.org/pgdocs/postgres/app-vacuumdb.html">vacuumdb</a>
|
||||
|
||||
<hr>
|
||||
<div class="navigation">
|
||||
<a href="index.html">Top</a> >
|
||||
<a href="pg_repack.html">pg_repack</a>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p class="footer">
|
||||
Portions Copyright (c) 2008-2011, NIPPON TELEGRAPH AND TELEPHONE CORPORATION<br>
|
||||
Portions Copyright (c) 2011, Itagaki Takahiro
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
|
||||
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
try {
|
||||
var pageTracker = _gat._getTracker("UA-10244036-4");
|
||||
pageTracker._trackPageview();
|
||||
} catch(err) {}</script>
|
||||
</body>
|
||||
</html>
|
355
doc/pg_repack.rst
Normal file
355
doc/pg_repack.rst
Normal file
@ -0,0 +1,355 @@
|
||||
pg_repack -- Reorganize tables in PostgreSQL databases without any locks
|
||||
========================================================================
|
||||
|
||||
.. contents::
|
||||
:depth: 1
|
||||
:backlinks: none
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
::
|
||||
|
||||
pg_repack [OPTION]... [DBNAME]
|
||||
|
||||
The following options can be specified in ``OPTIONS``. See also Options_ for
|
||||
details.
|
||||
|
||||
Options:
|
||||
-a, --all repack all databases
|
||||
-n, --no-order do vacuum full instead of cluster
|
||||
-o, --order-by=COLUMNS order by columns instead of cluster keys
|
||||
-t, --table=TABLE repack specific table only
|
||||
-T, --wait-timeout=SECS timeout to cancel other backends on conflict
|
||||
-Z, --no-analyze don't analyze at end
|
||||
|
||||
Connection options:
|
||||
-d, --dbname=DBNAME database to connect
|
||||
-h, --host=HOSTNAME database server host or socket directory
|
||||
-p, --port=PORT database server port
|
||||
-U, --username=USERNAME user name to connect as
|
||||
-w, --no-password never prompt for password
|
||||
-W, --password force password prompt
|
||||
|
||||
Generic options:
|
||||
-e, --echo echo queries
|
||||
-E, --elevel=LEVEL set output message level
|
||||
--help show this help, then exit
|
||||
--version output version information, then exit
|
||||
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
pg_repack is an utility program to reorganize tables in PostgreSQL databases.
|
||||
Unlike clusterdb_, it doesn't block any selections and updates during
|
||||
reorganization.
|
||||
|
||||
pg_repack is a fork of the previous pg_reorg_ project. It was founded to
|
||||
gather the bug fixes and new development ideas that the slow pace of
|
||||
development of pg_reorg was struggling to satisfy.
|
||||
|
||||
You can choose one of the following methods to reorganize:
|
||||
|
||||
* Online CLUSTER (ordered by cluster index)
|
||||
* Ordered by specified columns
|
||||
* Online VACUUM FULL (packing rows only)
|
||||
|
||||
NOTICE:
|
||||
|
||||
* Only superusers can use the utility.
|
||||
* Target table must have PRIMARY KEY.
|
||||
|
||||
.. _clusterdb: http://www.postgresql.org/docs/current/static/app-clusterdb.html
|
||||
.. _pg_reorg: http://reorg.projects.pgfoundry.org/
|
||||
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
Execute the following command to perform an online CLUSTER of all tables in
|
||||
test database::
|
||||
|
||||
$ pg_repack test
|
||||
|
||||
Execute the following command to perform an online VACUUM FULL to foo table in
|
||||
test database::
|
||||
|
||||
$ pg_repack --no-order --table foo -d test
|
||||
|
||||
|
||||
Options
|
||||
-------
|
||||
|
||||
pg_repack has the following command line options:
|
||||
|
||||
Reorg Options
|
||||
^^^^^^^^^^^^^
|
||||
|
||||
Options to order rows. If not specified, pg_repack performs an online CLUSTER
|
||||
using cluster indexes. Only one option can be specified. You may also specify
|
||||
target tables or databases.
|
||||
|
||||
``-n``, ``--no-order``
|
||||
Do online VACUUM FULL.
|
||||
|
||||
``-o COLUMNS [,...]``, ``--order-by=COLUMNS [,...]``
|
||||
Do online CLUSTER ordered by specified columns.
|
||||
|
||||
``-t TABLE``, ``--table=TABLE``
|
||||
Reorganize table only. If you don't specify this option, all tables in
|
||||
specified databases are reorganized.
|
||||
|
||||
``-T SECS``, ``--wait-timeout=SECS``
|
||||
pg_repack needs to take an exclusive lock at the end of the
|
||||
reorganization. This setting controls how long it wait for acquiring the
|
||||
lock in seconds. If the lock cannot be taken even after the duration,
|
||||
pg_repack forces to cancel conflicted queries. Also, if the server version
|
||||
is 8.4 or newer, pg_repack forces to disconnect conflicted backends after
|
||||
twice time passed. The default is 60 seconds.
|
||||
|
||||
``-Z``, ``--no-analyze``
|
||||
Disable ANALYZE after the reorganization. If not specified, run ANALYZE
|
||||
after the reorganization.
|
||||
|
||||
Connection Options
|
||||
^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Options to connect to servers. You cannot use ``--all`` and ``--dbname`` or
|
||||
``--table`` together.
|
||||
|
||||
``-a``, ``--all``
|
||||
Reorganize all databases.
|
||||
|
||||
``-d DBNAME``, ``--dbname=DBNAME``
|
||||
Specifies the name of the database to be reorganized. If this is not
|
||||
specified and ``-a`` (or ``--all``) is not used, the database name is read
|
||||
from the environment variable PGDATABASE. If that is not set, the user
|
||||
name specified for the connection is used.
|
||||
|
||||
``-h HOSTNAME``, ``--host=HOSTNAME``
|
||||
Specifies the host name of the machine on which the server is running. If
|
||||
the value begins with a slash, it is used as the directory for the Unix
|
||||
domain socket.
|
||||
|
||||
``-p PORT``, ``--port=PORT``
|
||||
Specifies the TCP port or local Unix domain socket file extension on which
|
||||
the server is listening for connections.
|
||||
|
||||
``-U USERNAME``, ``--username=USERNAME``
|
||||
User name to connect as.
|
||||
|
||||
``-w``, ``--no-password``
|
||||
Never issue a password prompt. If the server requires password
|
||||
authentication and a password is not available by other means such as a
|
||||
.pgpass file, the connection attempt will fail. This option can be useful
|
||||
in batch jobs and scripts where no user is present to enter a password.
|
||||
|
||||
``-W``, ``--password``
|
||||
Force the program to prompt for a password before connecting to a
|
||||
database.
|
||||
|
||||
This option is never essential, since the program will automatically
|
||||
prompt for a password if the server demands password authentication.
|
||||
However, pg_repack will waste a connection attempt finding out that the
|
||||
server wants a password. In some cases it is worth typing ``-W`` to avoid
|
||||
the extra connection attempt.
|
||||
|
||||
|
||||
Generic Options
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
``-e``, ``--echo``
|
||||
Echo commands sent to server.
|
||||
|
||||
``-E LEVEL``, ``--elevel=LEVEL``
|
||||
Choose the output message level from ``DEBUG``, ``INFO``, ``NOTICE``,
|
||||
``WARNING``, ``ERROR``, ``LOG``, ``FATAL``, and ``PANIC``. The default is
|
||||
``INFO``.
|
||||
|
||||
``--help``
|
||||
Show usage of the program.
|
||||
|
||||
``--version``
|
||||
Show the version number of the program.
|
||||
|
||||
|
||||
Environment
|
||||
-----------
|
||||
|
||||
``PGDATABASE``, ``PGHOST``, ``PGPORT``, ``PGUSER``
|
||||
Default connection parameters
|
||||
|
||||
This utility, like most other PostgreSQL utilities, also uses the
|
||||
environment variables supported by libpq (see `Environment Variables`__).
|
||||
|
||||
.. __: http://www.postgresql.org/docs/current/static/libpq-envars.html
|
||||
|
||||
|
||||
Diagnostics
|
||||
-----------
|
||||
|
||||
Error messages are reported when pg_repack fails. The following list shows the
|
||||
cause of errors.
|
||||
|
||||
You need to cleanup by hand after fatal errors. To cleanup, execute
|
||||
``$PGHOME/share/contrib/uninstall_pg_repack.sql`` to the database where the
|
||||
error occured and then execute ``$PGHOME/share/contrib/pg_repack.sql``. (Do
|
||||
uninstall and reinstall.)
|
||||
|
||||
pg_repack: repack database "template1" ... skipped
|
||||
pg_repack is not installed in the database when ``--all`` option is
|
||||
specified.
|
||||
|
||||
Do register pg_repack to the database.
|
||||
|
||||
ERROR: pg_repack is not installed
|
||||
pg_repack is not installed in the database specified by ``--dbname``.
|
||||
|
||||
Do register pg_repack to the database.
|
||||
|
||||
ERROR: relation "table" has no primary key
|
||||
The target table doesn't have PRIMARY KEY.
|
||||
|
||||
Define PRIMARY KEY to the table. (ALTER TABLE ADD PRIMARY KEY)
|
||||
|
||||
ERROR: relation "table" has no cluster key
|
||||
The target table doesn't have CLUSTER KEY.
|
||||
|
||||
Define CLUSTER KEY to the table. (ALTER TABLE CLUSTER)
|
||||
|
||||
pg_repack: query failed: ERROR: column "col" does not exist
|
||||
The target table doesn't have columns specified by ``--order-by`` option.
|
||||
|
||||
Specify existing columns.
|
||||
|
||||
ERROR: permission denied for schema repack
|
||||
Permission error.
|
||||
|
||||
pg_repack must be executed by superusers.
|
||||
|
||||
pg_repack: query failed: ERROR: trigger "z_repack_trigger" for relation "tbl" already exists
|
||||
The target table already has a trigger named ``z_repack_trigger``.
|
||||
|
||||
Delete or rename the trigger.
|
||||
|
||||
pg_repack: trigger conflicted for tbl
|
||||
The target table already has a trigger which follows by
|
||||
``z_repack_trigger`` in alphabetical order.
|
||||
|
||||
Delete or rename the trigger.
|
||||
|
||||
|
||||
Restrictions
|
||||
------------
|
||||
|
||||
pg_repack has the following restrictions. Be careful to avoid data
|
||||
corruptions.
|
||||
|
||||
Temp tables
|
||||
^^^^^^^^^^^
|
||||
|
||||
pg_repack cannot reorganize temp tables.
|
||||
|
||||
GiST indexes
|
||||
^^^^^^^^^^^^
|
||||
|
||||
pg_repack cannot reorganize tables using GiST indexes.
|
||||
|
||||
DDL commands
|
||||
^^^^^^^^^^^^
|
||||
|
||||
You cannot do DDL commands **except** VACUUM and ANALYZE during pg_repack. In many
|
||||
cases pg_repack will fail and rollback collectly, but there are some cases
|
||||
which may result in data-corruption .
|
||||
|
||||
TRUNCATE
|
||||
TRUNCATE is lost. Deleted rows still exist after pg_repack.
|
||||
|
||||
CREATE INDEX
|
||||
It causes index corruptions.
|
||||
|
||||
ALTER TABLE ... ADD COLUMN
|
||||
It causes lost of data. Newly added columns are initialized with NULLs.
|
||||
|
||||
ALTER TABLE ... ALTER COLUMN TYPE
|
||||
It causes data corruptions.
|
||||
|
||||
ALTER TABLE ... SET TABLESPACE
|
||||
It causes data corruptions by wrong relfilenode.
|
||||
|
||||
|
||||
Details
|
||||
-------
|
||||
|
||||
pg_repack creates a work table in the repack schema and sorts the rows in this
|
||||
table. Then, it updates the system catalogs directly to swap the work table
|
||||
and the original one.
|
||||
|
||||
|
||||
Installations
|
||||
-------------
|
||||
|
||||
pg_repack can be built with "make" on UNIX or Linux. pgxs build framework is
|
||||
used automatically. Before building, you might need to install postgres
|
||||
packages for developer (postgresql-devel, etc.) and add ``pg_config`` to your
|
||||
``$PATH``. ::
|
||||
|
||||
$ cd pg_repack
|
||||
$ make
|
||||
$ su
|
||||
$ make install
|
||||
|
||||
You can also use Microsoft Visual C++ 2010 to build the program on Windows.
|
||||
There are project files in the ``msvc`` folder.
|
||||
|
||||
Start PostgreSQL and execute the script to register functions to your
|
||||
database::
|
||||
|
||||
$ pg_ctl start
|
||||
$ psql -c "CREATE EXTENSION pg_repack" -d your_database
|
||||
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
PostgreSQL versions
|
||||
PostgreSQL 8.2, 8.3, 8.4, 9.0, 9.1, 9.2
|
||||
|
||||
OS
|
||||
RHEL 5.2, Windows XP SP3
|
||||
|
||||
Disks
|
||||
Requires free disk space twice as large as the target table(s) and
|
||||
indexes. For example, if the total size of the tables and indexes to be
|
||||
reorganized is 1GB, an additional 2GB of disk space is required.
|
||||
|
||||
|
||||
Releases
|
||||
--------
|
||||
|
||||
* pg_repack 1.1.8
|
||||
|
||||
* Added support for PostgreSQL 9.2.
|
||||
* Added support for CREATE EXTENSION on PostgreSQL 9.1 and following.
|
||||
* Give user feedback while waiting for transactions to finish (pg_reorg
|
||||
issue #5).
|
||||
* Bugfix: Allow running on newly promoted streaming replication slaves
|
||||
(pg_reorg issue #1).
|
||||
* Bugfix: Properly escape column names (pg_reorg issue #6).
|
||||
* Bugfix: Avoid recreating invalid indexes, or choosing them as key
|
||||
(pg_reorg issue #9).
|
||||
|
||||
* pg_reorg 1.1.7 (2011-08-07)
|
||||
|
||||
* Bugfix: VIEWs and FUNCTIONs could be corrupted that used a reorganized
|
||||
table which has a dropped column.
|
||||
* Supports PostgreSQL 9.1 and 9.2dev. (but EXTENSION is not yet)
|
||||
|
||||
|
||||
See Also
|
||||
--------
|
||||
|
||||
* `clusterdb <http://www.postgresql.org/docs/current/static/app-clusterdb.html>`__
|
||||
* `vacuumdb <http://www.postgresql.org/docs/current/static/app-vacuumdb.html>`__
|
||||
|
@ -11,11 +11,6 @@
|
||||
color: #202020;
|
||||
}
|
||||
|
||||
/* give the rule a bit of extra space (above and below), since its being used to divide
|
||||
sections on some pages (project summary) */
|
||||
HR { margin: 5px 0px 5px 0px }
|
||||
|
||||
|
||||
h2, h3, h4, h5, h6 {
|
||||
color: Black;
|
||||
background: none;
|
||||
@ -43,28 +38,7 @@ li {
|
||||
line-height: 1.4em;
|
||||
}
|
||||
|
||||
table {
|
||||
background: #f9f9f9;
|
||||
border: 1px solid #aaa;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
th, td {
|
||||
border: 1px solid #aaa;
|
||||
padding: 0.2em;
|
||||
}
|
||||
|
||||
thead th {
|
||||
background: #f2f2f2;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
tbody th {
|
||||
background: #f2f2f2;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
div.index {
|
||||
div.contents {
|
||||
float:right;
|
||||
border:thin solid black;
|
||||
background-color: white;
|
||||
@ -73,13 +47,7 @@ div.index {
|
||||
padding-left: 1em;
|
||||
padding-right: 1em;
|
||||
margin-left: 0.5em;
|
||||
margin-top: 2.5em !important;
|
||||
}
|
||||
|
||||
p.footer {
|
||||
text-align: right;
|
||||
font-size: small;
|
||||
}
|
||||
|
||||
span.param {
|
||||
color: #0000cd;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user