😇
PostgreSQLの設定項目についてざっと調べてみようとした
はじめに
DBにポスグレ(Cloud SQL)を使うことにしたので、パフォーマンスチューニング系の設定項目を調べてみた、という話。
設定を確認する方法
show
コマンドで現状の設定値を確認することができる。
=> show max_connections;
max_connections
-----------------
100
=> show all;
allow_system_table_mods | off | Allows modifications of the structure of system tables.
application_name | psql | Sets the application name to be reported in statistics and logs.
archive_cleanup_command | | Sets the shell command that will be executed at every restart point.
archive_command | (disabled) | Sets the shell command that will be called to archive a WAL file.
もしくはpg_settings
というテーブルを参照することでも設定値を確認できる(こっちの方が設定が反映されるタイミングなど、より詳細にわかる)
=> SELECT name,setting,context FROM pg_settings;
contextって何?
Wikiより抜粋。
When they take effect
PostgreSQL settings have different levels of flexibility for when they can be changed, usually related to internal code restrictions. The complete list of levels is:
- Postmaster: requires restart of server
- Sighup: requires a HUP of the server, either by kill -HUP (usually -1), pg_ctl reload, or SELECT pg_reload_conf();
- User: can be set within individual sessions, take effect only within that session
- Internal: set at compile time, can't be changed, mainly for reference
- Backend: settings which must be set before session start
- Superuser: can be set at runtime for the server by superusers
Most of the time you'll only use the first of these, but the second can be useful if you have a server you don't want to take down, while the user session settings can be helpful for some special situations. You can tell which type of parameter a setting is by looking at the "context" field in the pg_settings view.
設定項目
- https://qiita.com/cuzic/items/f9b846e6171a54079d77 を参考に説明。
- https://cloud.google.com/sql/docs/postgres/flags?hl=ja にCloud SQLでの設定値について書いてある
主要な設定の意味について確認しようとしたところ、Cloud SQLのドキュメントに以下の文言が...
注: 次の表のフラグの一部は Cloud SQL 用のベータ版です。これらのフラグの有効範囲は変わる可能性があります。これらのフラグにデフォルト以外の設定を使用するインスタンスは、Cloud SQL SLA の対象外になります。
つまりCloud SQLは「GCPでいい感じのデフォルト値にしているから、勝手にいじるな、いじったらSLA対象外だぞ?いいのか?」ということ?
Discussion