インストール¶
このセクションはpg_hint_planのインストール方法について説明します。
Building binary module¶
ソースツリーの先頭で make を実行し、適切なユーザで make install を実行してください。環境変数 PATH は、PostgreSQLのバイナリを指すように適切に設定する必要があります。
$ tar xzvf pg_hint_plan-1.x.x.tar.gz
$ cd pg_hint_plan-1.x.x
$ make
$ su
$ make install
Installing from a binary package¶
On Debian and Ubuntu pg_hint_plan is available as a binary package from the
pgdg (PostgreSQL Global Development Group) repository. Assuming you've
already added the repository to apt sources, installing the package is as
simple as:
sudo apt install postgresql-<postgres version>-pg-hint-plan
Please visit https://www.postgresql.org/download/linux/ if you need help at adding the repository.
pg_hint_planのロード¶
pg_hint_plan は基本的にCREATE EXTENSIONを必要としません。単純にLOADコマンドで有効化できます。もちろん、postgresql.confのshared_preload_libraries を設定することで全体にロード することもできます。また、特定のユーザに対し自動的にロードするためのALTER USER SET/ALTER DATABASE SETに興味があるかもしれません。
postgres=# LOAD 'pg_hint_plan';
LOAD
ヒントテーブルを使用する場合は、CREATE EXTENSION を実行しSET pg_hint_plan.enable_hint_table TO onを実行してください。