Upgrade to Pro — share decks privately, control downloads, hide ads and more …

使いこなそうGUC

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.

 使いこなそうGUC

Avatar for ISHIDA Akio

ISHIDA Akio

August 26, 2009
Tweet

More Decks by ISHIDA Akio

Other Decks in Programming

Transcript

  1. GUC • Grand Unified Configuration(ソースの中にしか出てこない 言葉かもしれない) • PostgreSQLの設定はどうやって変更する? • postgresql.confを書き換えたり

    • SETコマンドとか • いつ反映される? • 再起動? • リロード? • 参考: • src/include/misc/guc.h
  2. とりあえずSELECT * FROM pg_settings; • 8.3.7での実行例 • 以降、context列とsource列の説明です => SELECT

    * FROM pg_settings; -[ RECORD 1 ]------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- ---------------- name | add_missing_from setting | off unit | <Null> category | Version and Platform Compatibility / Previous PostgreSQL Versions short_desc | Automatically adds missing table references to FROM clauses. extra_desc | <Null> context | user vartype | bool source | default min_val | <Null> max_val | <Null> ...
  3. context(1) • いつ変更が反映されるのか • internal • 内部的な設定値。変更不可(server_version等) • postmaster •

    postmaster起動時 • postgresql.conf又はコマンドラインオプション • sighup • kill -HUP(pg_ctl reload等)で読み込む
  4. context(2) • backend • バックエンド起動時(=接続時)のパラメータ • なので接続毎に異なる値を持つ • クライアントの環境変数や接続文字列 •

    superuser • スーパーユーザがsetコマンドで変更可能 • user • どのユーザでもsetコマンドで変更可能
  5. source(1) • 現在の値はどこで設定されたものか • default • environment variable • postmasterの環境変数

    • PGDATESTYLE,PGPORT,PGCLIENTENCODING • 普通使いません • configuration file • postgresql.conf
  6. source(2) • command line • postmasterのコマンドライン引数 • postgres -D data

    --add_missing_from=on • pg_ctl start -D data -o “--add_missing_from=on” • database • ALTER DATABASE dbname SET foo to bar; • user • ALTER USER username SET foo to bar;
  7. 8.4のpg_settings • vartypeにenumが追加された • sourcefile, sourcelineが追加された =# SELECT * from

    pg_settings where name = 'log_statement'; -[ RECORD 1 ]----------------------------------- name | log_statement setting | none unit | <Null> category | Reporting and Logging / What to Log short_desc | Sets the type of statements logged. extra_desc | <Null> context | superuser vartype | enum source | default min_val | <Null> max_val | <Null> enumvals | {none,ddl,mod,all} boot_val | none reset_val | none sourcefile | /usr/home/ishida/pgsql/8.4.0/data/postgresql.conf sourceline | 500