SlideShare une entreprise Scribd logo
1  sur  11
Télécharger pour lire hors ligne
使いこなそうGUC
GUC
●   Grand Unified Configuration(ソースの中にしか出てこない
    言葉かもしれない)
●   PostgreSQLの設定はどうやって変更する?
    ●   postgresql.confを書き換えたり
    ●   SETコマンドとか
●   いつ反映される?
    ●   再起動?
    ●   リロード?
●   参考:
    ●   src/include/misc/guc.h
とりあえず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>
    ...
context(1)
●   いつ変更が反映されるのか
●   internal
    ●   内部的な設定値。変更不可(server_version等)
●   postmaster
    ●   postmaster起動時
    ●   postgresql.conf又はコマンドラインオプション
●   sighup
    ●   kill -HUP(pg_ctl reload等)で読み込む
context(2)
●   backend
    ●   バックエンド起動時(=接続時)のパラメータ
    ●   なので接続毎に異なる値を持つ
    ●   クライアントの環境変数や接続文字列
●   superuser
    ●   スーパーユーザがsetコマンドで変更可能
●   user
    ●   どのユーザでもsetコマンドで変更可能
source(1)
●   現在の値はどこで設定されたものか
●   default
●   environment variable
    ●   postmasterの環境変数
    ●   PGDATESTYLE,PGPORT,PGCLIENTENCODING
    ●   普通使いません
●   configuration file
    ●   postgresql.conf
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;
source(3)
●   client
    ●   環境変数PGOPTIONS,PGCLIENTENCODINGや接続文字列
        等
    ●   PGOPTIONS=”-c add_missing_from=on” psql
    ●   pg_connect(“options='--add_missing_from=on'”)
●   session
    ●   SETコマンド
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
case study(1)
●   動作中のアプリのSQLのログを取りたい
    ●   contextはsuperuser
    ●   でもSETコマンドではそのセッションしか変更できない
    ●   postgresql.confを変更するのは面倒
●   ALTER DATABASE又はALTER USERを使ってみれば?
間違ったGUCの使い方
●   http://www.postgres.cz/index.php/PostgreSQL_SQL_Tricks
    #Any_other_session_variables

Contenu connexe

Tendances

[D31] PostgreSQLでスケールアウト構成を構築しよう by Yugo Nagata
[D31] PostgreSQLでスケールアウト構成を構築しよう by Yugo Nagata[D31] PostgreSQLでスケールアウト構成を構築しよう by Yugo Nagata
[D31] PostgreSQLでスケールアウト構成を構築しよう by Yugo Nagata
Insight Technology, Inc.
 

Tendances (20)

マネージドPostgreSQLの実現に向けたPostgreSQL機能向上(PostgreSQL Conference Japan 2023 発表資料)
マネージドPostgreSQLの実現に向けたPostgreSQL機能向上(PostgreSQL Conference Japan 2023 発表資料)マネージドPostgreSQLの実現に向けたPostgreSQL機能向上(PostgreSQL Conference Japan 2023 発表資料)
マネージドPostgreSQLの実現に向けたPostgreSQL機能向上(PostgreSQL Conference Japan 2023 発表資料)
 
PostgreSQLの統計情報について(第26回PostgreSQLアンカンファレンス@オンライン 発表資料)
PostgreSQLの統計情報について(第26回PostgreSQLアンカンファレンス@オンライン 発表資料)PostgreSQLの統計情報について(第26回PostgreSQLアンカンファレンス@オンライン 発表資料)
PostgreSQLの統計情報について(第26回PostgreSQLアンカンファレンス@オンライン 発表資料)
 
pg_hint_planを知る(第37回PostgreSQLアンカンファレンス@オンライン 発表資料)
pg_hint_planを知る(第37回PostgreSQLアンカンファレンス@オンライン 発表資料)pg_hint_planを知る(第37回PostgreSQLアンカンファレンス@オンライン 発表資料)
pg_hint_planを知る(第37回PostgreSQLアンカンファレンス@オンライン 発表資料)
 
PostgreSQLモニタリングの基本とNTTデータが追加したモニタリング新機能(Open Source Conference 2021 Online F...
PostgreSQLモニタリングの基本とNTTデータが追加したモニタリング新機能(Open Source Conference 2021 Online F...PostgreSQLモニタリングの基本とNTTデータが追加したモニタリング新機能(Open Source Conference 2021 Online F...
PostgreSQLモニタリングの基本とNTTデータが追加したモニタリング新機能(Open Source Conference 2021 Online F...
 
pgvectorを使ってChatGPTとPostgreSQLを連携してみよう!(PostgreSQL Conference Japan 2023 発表資料)
pgvectorを使ってChatGPTとPostgreSQLを連携してみよう!(PostgreSQL Conference Japan 2023 発表資料)pgvectorを使ってChatGPTとPostgreSQLを連携してみよう!(PostgreSQL Conference Japan 2023 発表資料)
pgvectorを使ってChatGPTとPostgreSQLを連携してみよう!(PostgreSQL Conference Japan 2023 発表資料)
 
pg_bigmで全文検索するときに気を付けたい5つのポイント(第23回PostgreSQLアンカンファレンス@オンライン 発表資料)
pg_bigmで全文検索するときに気を付けたい5つのポイント(第23回PostgreSQLアンカンファレンス@オンライン 発表資料)pg_bigmで全文検索するときに気を付けたい5つのポイント(第23回PostgreSQLアンカンファレンス@オンライン 発表資料)
pg_bigmで全文検索するときに気を付けたい5つのポイント(第23回PostgreSQLアンカンファレンス@オンライン 発表資料)
 
[D31] PostgreSQLでスケールアウト構成を構築しよう by Yugo Nagata
[D31] PostgreSQLでスケールアウト構成を構築しよう by Yugo Nagata[D31] PostgreSQLでスケールアウト構成を構築しよう by Yugo Nagata
[D31] PostgreSQLでスケールアウト構成を構築しよう by Yugo Nagata
 
Memoizeの仕組み(第41回PostgreSQLアンカンファレンス@オンライン 発表資料)
Memoizeの仕組み(第41回PostgreSQLアンカンファレンス@オンライン 発表資料)Memoizeの仕組み(第41回PostgreSQLアンカンファレンス@オンライン 発表資料)
Memoizeの仕組み(第41回PostgreSQLアンカンファレンス@オンライン 発表資料)
 
PostgreSQLのバグとの付き合い方 ~バグの調査からコミュニティへの報告、修正パッチ投稿まで~(PostgreSQL Conference Japa...
PostgreSQLのバグとの付き合い方 ~バグの調査からコミュニティへの報告、修正パッチ投稿まで~(PostgreSQL Conference Japa...PostgreSQLのバグとの付き合い方 ~バグの調査からコミュニティへの報告、修正パッチ投稿まで~(PostgreSQL Conference Japa...
PostgreSQLのバグとの付き合い方 ~バグの調査からコミュニティへの報告、修正パッチ投稿まで~(PostgreSQL Conference Japa...
 
MesonでPostgreSQLをビルドしてみよう!(第39回PostgreSQLアンカンファレンス@オンライン 発表資料)
MesonでPostgreSQLをビルドしてみよう!(第39回PostgreSQLアンカンファレンス@オンライン 発表資料)MesonでPostgreSQLをビルドしてみよう!(第39回PostgreSQLアンカンファレンス@オンライン 発表資料)
MesonでPostgreSQLをビルドしてみよう!(第39回PostgreSQLアンカンファレンス@オンライン 発表資料)
 
OSS-DB Goldへの第一歩~実践!運用管理~
OSS-DB Goldへの第一歩~実践!運用管理~OSS-DB Goldへの第一歩~実践!運用管理~
OSS-DB Goldへの第一歩~実践!運用管理~
 
祝!PostgreSQLレプリケーション10周年!徹底紹介!!
祝!PostgreSQLレプリケーション10周年!徹底紹介!!祝!PostgreSQLレプリケーション10周年!徹底紹介!!
祝!PostgreSQLレプリケーション10周年!徹底紹介!!
 
PostgreSQL14の pg_stat_statements 改善(第23回PostgreSQLアンカンファレンス@オンライン 発表資料)
PostgreSQL14の pg_stat_statements 改善(第23回PostgreSQLアンカンファレンス@オンライン 発表資料)PostgreSQL14の pg_stat_statements 改善(第23回PostgreSQLアンカンファレンス@オンライン 発表資料)
PostgreSQL14の pg_stat_statements 改善(第23回PostgreSQLアンカンファレンス@オンライン 発表資料)
 
PostgreSQL13でのpg_basebackupの改善について(第13回PostgreSQLアンカンファレンス@オンライン)
PostgreSQL13でのpg_basebackupの改善について(第13回PostgreSQLアンカンファレンス@オンライン)PostgreSQL13でのpg_basebackupの改善について(第13回PostgreSQLアンカンファレンス@オンライン)
PostgreSQL13でのpg_basebackupの改善について(第13回PostgreSQLアンカンファレンス@オンライン)
 
フックを使ったPostgreSQLの拡張機能を作ってみよう!(第33回PostgreSQLアンカンファレンス@オンライン 発表資料)
フックを使ったPostgreSQLの拡張機能を作ってみよう!(第33回PostgreSQLアンカンファレンス@オンライン 発表資料)フックを使ったPostgreSQLの拡張機能を作ってみよう!(第33回PostgreSQLアンカンファレンス@オンライン 発表資料)
フックを使ったPostgreSQLの拡張機能を作ってみよう!(第33回PostgreSQLアンカンファレンス@オンライン 発表資料)
 
PostgreSQL16でのロールに関する変更点(第41回PostgreSQLアンカンファレンス@オンライン 発表資料)
PostgreSQL16でのロールに関する変更点(第41回PostgreSQLアンカンファレンス@オンライン 発表資料)PostgreSQL16でのロールに関する変更点(第41回PostgreSQLアンカンファレンス@オンライン 発表資料)
PostgreSQL16でのロールに関する変更点(第41回PostgreSQLアンカンファレンス@オンライン 発表資料)
 
並列クエリを実行するPostgreSQLのアーキテクチャ
並列クエリを実行するPostgreSQLのアーキテクチャ並列クエリを実行するPostgreSQLのアーキテクチャ
並列クエリを実行するPostgreSQLのアーキテクチャ
 
PostgreSQL開発コミュニティに参加しよう!(PostgreSQL Conference Japan 2021 発表資料)
PostgreSQL開発コミュニティに参加しよう!(PostgreSQL Conference Japan 2021 発表資料)PostgreSQL開発コミュニティに参加しよう!(PostgreSQL Conference Japan 2021 発表資料)
PostgreSQL開発コミュニティに参加しよう!(PostgreSQL Conference Japan 2021 発表資料)
 
PostgreSQLバックアップの基本
PostgreSQLバックアップの基本PostgreSQLバックアップの基本
PostgreSQLバックアップの基本
 
PostgreSQL 13でのpg_stat_statementsの改善について(第12回PostgreSQLアンカンファレンス@オンライン 発表資料)
PostgreSQL 13でのpg_stat_statementsの改善について(第12回PostgreSQLアンカンファレンス@オンライン 発表資料)PostgreSQL 13でのpg_stat_statementsの改善について(第12回PostgreSQLアンカンファレンス@オンライン 発表資料)
PostgreSQL 13でのpg_stat_statementsの改善について(第12回PostgreSQLアンカンファレンス@オンライン 発表資料)
 

Similaire à 使いこなそうGUC

Linux Commands
Linux CommandsLinux Commands
Linux Commands
iwata
 
Ohp Seijoen H20 06 Mojiretsu
Ohp Seijoen H20 06 MojiretsuOhp Seijoen H20 06 Mojiretsu
Ohp Seijoen H20 06 Mojiretsu
sesejun
 
How To Create Custom DSLs By PHP
How To Create Custom DSLs By PHPHow To Create Custom DSLs By PHP
How To Create Custom DSLs By PHP
Atsuhiro Kubo
 
技術トレンディセミナー フレームワークとしてのTrac
技術トレンディセミナー フレームワークとしてのTrac技術トレンディセミナー フレームワークとしてのTrac
技術トレンディセミナー フレームワークとしてのTrac
terada
 
20080424 Cdb2008 Postgresql News Bartunov
20080424 Cdb2008 Postgresql News Bartunov20080424 Cdb2008 Postgresql News Bartunov
20080424 Cdb2008 Postgresql News Bartunov
Nikolay Samokhvalov
 

Similaire à 使いこなそうGUC (20)

PostgreSQLで学ぶBoyer-Moore-Horspoolアルゴリズム
PostgreSQLで学ぶBoyer-Moore-HorspoolアルゴリズムPostgreSQLで学ぶBoyer-Moore-Horspoolアルゴリズム
PostgreSQLで学ぶBoyer-Moore-Horspoolアルゴリズム
 
Ruby Postgres
Ruby PostgresRuby Postgres
Ruby Postgres
 
Linux Commands
Linux CommandsLinux Commands
Linux Commands
 
20070329 Phpconf2007 Training
20070329 Phpconf2007 Training20070329 Phpconf2007 Training
20070329 Phpconf2007 Training
 
Ohp Seijoen H20 06 Mojiretsu
Ohp Seijoen H20 06 MojiretsuOhp Seijoen H20 06 Mojiretsu
Ohp Seijoen H20 06 Mojiretsu
 
4200 Kte7.0 Training V1.0
4200 Kte7.0 Training V1.04200 Kte7.0 Training V1.0
4200 Kte7.0 Training V1.0
 
How To Create Custom DSLs By PHP
How To Create Custom DSLs By PHPHow To Create Custom DSLs By PHP
How To Create Custom DSLs By PHP
 
Nginx常见应用技术指南(Nginx Tips)
Nginx常见应用技术指南(Nginx Tips)Nginx常见应用技术指南(Nginx Tips)
Nginx常见应用技术指南(Nginx Tips)
 
Windows PowerShell V2 の新機能
Windows PowerShell V2 の新機能Windows PowerShell V2 の新機能
Windows PowerShell V2 の新機能
 
技術トレンディセミナー フレームワークとしてのTrac
技術トレンディセミナー フレームワークとしてのTrac技術トレンディセミナー フレームワークとしてのTrac
技術トレンディセミナー フレームワークとしてのTrac
 
Shibuya.abc - Gnashで遊ぼう
Shibuya.abc - Gnashで遊ぼうShibuya.abc - Gnashで遊ぼう
Shibuya.abc - Gnashで遊ぼう
 
GAE/J 開発環境でJDO入門
GAE/J 開発環境でJDO入門GAE/J 開発環境でJDO入門
GAE/J 開発環境でJDO入門
 
20080424 Cdb2008 Postgresql News Bartunov
20080424 Cdb2008 Postgresql News Bartunov20080424 Cdb2008 Postgresql News Bartunov
20080424 Cdb2008 Postgresql News Bartunov
 
20090410 Gree Opentech Main
20090410 Gree Opentech Main20090410 Gree Opentech Main
20090410 Gree Opentech Main
 
樽家昌也 (日本Rubyの会)
樽家昌也 (日本Rubyの会) 樽家昌也 (日本Rubyの会)
樽家昌也 (日本Rubyの会)
 
Grails紹介
Grails紹介Grails紹介
Grails紹介
 
MySQL Clusterで高性能システムを構築する際のポイント
MySQL Clusterで高性能システムを構築する際のポイントMySQL Clusterで高性能システムを構築する際のポイント
MySQL Clusterで高性能システムを構築する際のポイント
 
What Can Compilers Do for Us?
What Can Compilers Do for Us?What Can Compilers Do for Us?
What Can Compilers Do for Us?
 
Rails Deployment with NginX
Rails Deployment with NginXRails Deployment with NginX
Rails Deployment with NginX
 
Linuxユーザーのための Windows 管理入門
Linuxユーザーのための Windows 管理入門Linuxユーザーのための Windows 管理入門
Linuxユーザーのための Windows 管理入門
 

Plus de Akio Ishida (10)

Prophecyを使ったユニットテスト
Prophecyを使ったユニットテスト Prophecyを使ったユニットテスト
Prophecyを使ったユニットテスト
 
よりよいPHPUnitの実行方法を求めて
よりよいPHPUnitの実行方法を求めてよりよいPHPUnitの実行方法を求めて
よりよいPHPUnitの実行方法を求めて
 
phpspecで学ぶLondon School TDD
phpspecで学ぶLondon School TDDphpspecで学ぶLondon School TDD
phpspecで学ぶLondon School TDD
 
PostgreSQLの範囲型と排他制約
PostgreSQLの範囲型と排他制約PostgreSQLの範囲型と排他制約
PostgreSQLの範囲型と排他制約
 
Getting start with knockout.js
Getting start with knockout.jsGetting start with knockout.js
Getting start with knockout.js
 
XIDを周回させてみよう
XIDを周回させてみようXIDを周回させてみよう
XIDを周回させてみよう
 
Local php-100828 2
Local php-100828 2Local php-100828 2
Local php-100828 2
 
Rubysapporo Stringsearch
Rubysapporo StringsearchRubysapporo Stringsearch
Rubysapporo Stringsearch
 
Ruby Postgres 2009
Ruby Postgres 2009Ruby Postgres 2009
Ruby Postgres 2009
 
textsearch_jaで全文検索
textsearch_jaで全文検索textsearch_jaで全文検索
textsearch_jaで全文検索
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 

使いこなそうGUC

  • 2. GUC ● Grand Unified Configuration(ソースの中にしか出てこない 言葉かもしれない) ● PostgreSQLの設定はどうやって変更する? ● postgresql.confを書き換えたり ● SETコマンドとか ● いつ反映される? ● 再起動? ● リロード? ● 参考: ● src/include/misc/guc.h
  • 3. とりあえず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> ...
  • 4. context(1) ● いつ変更が反映されるのか ● internal ● 内部的な設定値。変更不可(server_version等) ● postmaster ● postmaster起動時 ● postgresql.conf又はコマンドラインオプション ● sighup ● kill -HUP(pg_ctl reload等)で読み込む
  • 5. context(2) ● backend ● バックエンド起動時(=接続時)のパラメータ ● なので接続毎に異なる値を持つ ● クライアントの環境変数や接続文字列 ● superuser ● スーパーユーザがsetコマンドで変更可能 ● user ● どのユーザでもsetコマンドで変更可能
  • 6. source(1) ● 現在の値はどこで設定されたものか ● default ● environment variable ● postmasterの環境変数 ● PGDATESTYLE,PGPORT,PGCLIENTENCODING ● 普通使いません ● configuration file ● postgresql.conf
  • 7. 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;
  • 8. source(3) ● client ● 環境変数PGOPTIONS,PGCLIENTENCODINGや接続文字列 等 ● PGOPTIONS=”-c add_missing_from=on” psql ● pg_connect(“options='--add_missing_from=on'”) ● session ● SETコマンド
  • 9. 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
  • 10. case study(1) ● 動作中のアプリのSQLのログを取りたい ● contextはsuperuser ● でもSETコマンドではそのセッションしか変更できない ● postgresql.confを変更するのは面倒 ● ALTER DATABASE又はALTER USERを使ってみれば?
  • 11. 間違ったGUCの使い方 ● http://www.postgres.cz/index.php/PostgreSQL_SQL_Tricks #Any_other_session_variables