LoginSignup
0
0

More than 1 year has passed since last update.

Amazon Aurora for PostgreSQLでpg_hint_planを有効化する

Posted at

環境

  • Amazon Aurora for PostgreSQL 13.4

多分、AuroraではないRDSでも手順は同じだと思います。

psqlでの操作

(1) pg_hint_planが有効化されているか確認します。

postgres=> select * from pg_extension;
  oid  |      extname       | extowner | extnamespace | extrelocatable | extversion | extconfig | extcondition 
-------+--------------------+----------+--------------+----------------+------------+-----------+--------------
 14346 | plpgsql            |       10 |           11 | f              | 1.0        |           | 
 78506 | pg_stat_statements |       10 |         2200 | t              | 1.8        |           | 
(2 rows)

pg_hint_planが有効化されていないことが分かります。

(2) pg_hint_planを有効化します。

postgres=> CREATE EXTENSION pg_hint_plan;
CREATE EXTENSION

(3) pg_hint_planが有効化されているか再確認します。

postgres=> select * from pg_extension;
  oid  |      extname       | extowner | extnamespace | extrelocatable | extversion |   extconfig   | extcondition 
-------+--------------------+----------+--------------+----------------+------------+---------------+--------------
 14346 | plpgsql            |       10 |           11 | f              | 1.0        |               | 
 78506 | pg_stat_statements |       10 |         2200 | t              | 1.8        |               | 
 86217 | pg_hint_plan       |       10 |        86216 | f              | 1.3.7      | {86220,86218} | {"",""}
(3 rows)

pg_hint_planが有効化されていることが分かります。

パラメータグループの作成

(1) AWSマネジメントコンソールで[RDS]-[パラメータグループ]

(2) [パラメータグループの作成]をクリック
スクリーンショット 2022-01-04 16.58.57.png

(3) [パラメータグループファミリー]で[aurora-postgresql13]を選択、[タイプ]で[DB Parameter Group]を選択、[グループ名]と[説明]は適当に入力して[作成]をクリック
スクリーンショット 2022-01-04 16.37.43.png

(4) パラメータグループの一覧から、先ほど作成したパラメータグループをクリック

(5) [パラメータの編集]をクリック

(6) 各パラメータを次のように設定→[変更の保存]をクリック

名前
pg_hint_plan.debug_print on
pg_hint_plan.enable_hint 1
pg_hint_plan.enable_hint_table 1
pg_hint_plan.message_level debug5
pg_hint_plan.parse_messages debug5
shared_preload_libraries pg_stat_statements,pg_hint_plan

pg_stat_statements,pg_hint_plan の部分は、カンマの前後に空白をあけるとエラーになります。

(7) データベース一覧から対象のデータベースを選択→[変更]をクリック

[リージョン別クラスター]ではなく[ライターインスタンス]・[リーダーインスタンス]を選択する

(8) [追加設定]-[DBパラメータグループ]に作成したパラメータグループを指定→[続行]をクリック
スクリーンショット 2022-01-04 17.01.29.png

(9) [変更のスケジューリング]で[すぐに適用]を選択→[DBインスタンスを変更]をクリック

(10) 選択したインスタンスのステータスが[変更中]になる→[利用可能]になったらOK

パラメータグループの作成

前項の(1)〜(10)をもう一度行う。ただし、下記の点は変更する。

(2) [タイプ]で[DB Cluster Parameter Group]を選択する。[グループ名]・[説明]も適当に変更する。

(7) [リージョン別クラスター]を選択して[変更]

(8) 先ほど作成したクラスター用のパラメータグループを指定する。

参考にした記事

PostgreSQLの拡張機能の有効化(オンプレ/AWS RDS

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0