SlideShare une entreprise Scribd logo
1  sur  44
The GUCS:
                     A Three-Hour Tour




Josh Berkus
PostgreSQL Experts Inc.
DrakeCon 2010 - San Francisco
agenda

# what are GUCS?
# understanding GUCS
# simple basic configuration
# new GUCS
# grand tour
related stuff




X
# pg_hba.conf
# recovery.conf
# pg_ident.conf
# libpq settings
# psql  commands
# system functions
What are GUCS?
# “Grand Unified Configuration Settings”
  –   A large set of global and session database settings
      which live in:

      src/backend/utils/misc/guc.c

# Your main way of configuring and tuning the
  database.
  –   in addition to compile options, system configuration
      and schema tuning!
# Pronounced “gucks”
208 Switches and Levers
208 Settings?!?
Don't worry!
Setting GUCS


     8
     6
     5
Eight types of GUCS
# Boolean             # Time
# Integer             # Strings
# Float               # ENUMs
# Memory / Disk       # Lists
Eight types of GUCS
# Boolean
  –   take TRUE | FALSE or ON | OFF

      enable_seqscan = on

# Integer
  –   take whole numbers only

      max_connections = 700
Eight types of GUCS
# Float
  –   take decimal values

      random_page_cost = 3.75

# Memory / Disk Size
  –   can take integers
  –   but can also take “computer units”: kB, MB, GB

      work_mem = 512MB
      shared_buffers = 4096
Eight Types of GUCS
# Time
  –   take time values (units vary)
  –   units are often omitted

      authentication_timeout = 30s

# Strings
  –   take unchecked strings
  –   often refers to file locations or program names

      log_directory = 'pg_log'
Eight Types of GUCS
# ENUMs
  –   take a string value from a prescribed list

      wal_level = hot_standby

# Lists
  –   take a list of values, either freeform or ENUM

      search_path = 'main, archive, “$user”'
Six GUCS Contexts
# session
# superuser
# reload
# restart
# backend
# internal
Six GUCS Contexts
# session, or “user”
  –   can be set on per-session basis at runtime
  –   can also be changed by altering the ROLE
# superuser
  –   can be set at runtime for the whole server, but only
      by the superuser
Six GUCS Contexts
# reload, or “sighup”
  –   requires a soft restart of the postmaster to change
  –   also called a “HUP”
# restart, or “postmaster”
  –   can only be changed with a hard restart
More on reloading
# Three methods for reloading


  pg_ctl -D PGDATA reload
  kill -HUP <postmaster.pid>
  SELECT pg_reload_conf();
Six GUCS Contexts
# backend
  –   developer settings which have to be set before
      session start
# internal
  –   compile-time settings provided for reference.
      Unalterable.
5 Places of set GUCs
1.postgresql.conf file
2.SET
3.pg_settings
4.ALTER objects
5.command-line switches & PGOPTIONS
postgresql.conf
# $PGDATA/postgresql.conf
  –   can be relocated or symlinked
# Primary way to change GUCS
  –   for performance
  –   for logging
  –   for defaults
postgresql.conf
# just a big list of settings
# defaults are “# commented” out
# if a setting appears multiple times, the last one
  takes effect
# can use “include” files
SET & SHOW
# Access GUCS in a SQL session
  –   SET changes
       ●   only applies to user and superuser contexts
       ●   best way to change things for only one session
       ●   can be embedded in stored procedures

           SET enable_mergejoin = false;

  –   SHOW displays
       ●   SHOW ALL lets you see all GUCS

           SHOW shared_buffers;
SET & SHOW: set_config
# set_config( setting, value, is_local )
      –   alternative to SET
      –   better for scripts since it takes a string
SELECT set_config('work_mem','1GB', TRUE);


# current_setting ( setting )
      –   alternative to SHOW
SELECT current_setting('lc_collate');
pg_settings
# Tabular representation of GUCS
  –   a “system view”
  –   can be queried
  –   can be updated, which runs a SET on the relevant
      parameter

      SELECT * FROM pg_settings
      WHERE name = 'work_mem';

      UPDATE pg_settings SET setting = '12MB'
      WHERE name = 'work_mem';
ALTER objects
# You can ALTER some objects to change their
  configuration settings
  –   ROLES (users)
  –   DATABASEs
  –   FUNCTIONs
  –   Changes configuration setting when that object is
      used (unless overridden by a SET)

      ALTER ROLE “data entry” SET
      search_path = 'entry, public';
New ALTER ROLE for 9.0
 ALTER ROLE IN DATABASE accts SET
 search_path = '$user, webview,
 contrib, public';

# now can set ROLE-based settings just for a
  specific database
# essential for search_path, useful for others
ALTER objects
# Good way to discriminate between applications
  & users
  –   set search_path
       ●   sometimes for security
  –   primitive resource management
       ●   change work_mem, etc. for specific ROLES, applications
           or reports
  –   localization
       ●   if different users have different desired displays

           ALTER DATABASE sao_paulo SET timezone =
           'America/SaoPaulo';
ALTER objects
CREATE FUNCTION check_password(uname TEXT,
pass TEXT)
RETURNS BOOLEAN AS $$
DECLARE passed BOOLEAN;
BEGIN
        SELECT (pwd = $2) INTO passed
        FROM    pwds
        WHERE   username = $1;

        RETURN passed;
END;
$$ LANGUAGE plpgsql
     SECURITY DEFINER
     -- Set a secure search_path: trusted
     -- schema(s), then 'pg_temp'.
     SET search_path = admin, pg_temp;
command-line and pgoptions
# Set options when you start PostgreSQL
  –   as command-line switches
  –   using the PGOPTIONS shell variable
# Not generally recommended
  –   hard to administrate or document
  –   mainly for running automated tests
       ●   and for restarting with recovery options

postgres -c 'bgwriter_delay = 50ms'
export PGOPTIONS = '-c zero_damaged_pages = ON'
GUCS Reference
The 13 Settings
            most users need to adjust
(1) listen_address       (8) checkpoint_segments
(2) max_connections      (9) wal_buffers
(3) shared_buffers       (10) autovacuum

(4) work_mem             (11) effective_cache_size

(5) maintenance_
                         (12) GROUP: replication
    work_mem
                         (13) GROUP: the logging settings
(6) synchronous_commit
GUCS Reference
What's New, GUCS?
X
add_missing_from
  regex_flavor
security & authentication
# bonjour
     –   lets you turn bonjour support off even if it's
           compiled
# ssl_renegotiation_limit
     –   works around SSL patch from OpenSSL exploit
application_name
# settable per session
# lets you log which application is running which
  statements
     –   different ROLEs no longer required
query planner settings
# enable_material
     –   lets you turn on and off materialization of
           subqueries for query plan troubleshooting
# geqo_seed
     –   make sure that GEQO plans are determinative
          for the same inputs
backwards compatibility
# bytea_output
     –   supports old bytea escapes as opposed to new
           hex format
# lo_compat_privileges
     –   disables new permission checks for large
           objects
replication settings
# wal_level
# wal_sender_delay
# wal_keep_segments
# hot_standby
# max_wal_senders
# vacuum_defer_cleanup_age
# max_standby_archive_delay
# max_standby_streaming_delay
# trace_recovery
GUCS: the Grand Tour
Categories (mine)
# file locations         # statistics
# connection settings    # locks
# resource               # locale & formatting
  management             # other settings &
# maintenance              defaults
# WAL & checkpoints      # compatibility
# replication            # custom GUCS
# query tuning           # developer options
# logging                # presets
custom variable classes
# for supporting various PostgreSQL Extensions
custom_variable_classes =
'pg_stat_statements,auto_explain'

pg_stat_statements.max = 10000
pg_stat_statements.track = all

auto_explain.log_min_duration = '200ms'
auto_explain.log_nested_statements = on
auto_explain.log_format = json
Finale
1) config_file                      20) ssl
2) data_directory                   21) krb_caseins_users
3) hba_file                         22) krb_realm
4) ident_file                       23) krb_server_hostname
5) external_pid_file                24) krb_server_keyfile
6) listen_addresses                 25) krb_srvname
7) port                             26) shared_buffers
8) max_connections                  27) work_mem
9) superuser_reserved_connections   28) temp_buffers
10) unix_socket_directory           29) max_prepared_transactions
11) unix_socket_group               30) max_files_per_process
12) unix_socket_permissions         31) max_stack_depth
13) bonjour_name                    32) shared_preload_libraries
14) authentication_timeout          33) maintenance_work_mem
15) tcp_keepalives_count            34) max_fsm_pages
16) tcp_keepalives_idle             35) max_fsm_relations
17) tcp_keepalives_interval         36) vacuum_cost_delay
18) db_user_namespace               37) vacuum_cost_limit
19) password_encryption             38) vacuum_cost_page_dirty
Contact
# Josh Berkus: josh@postgresql.org
  –   blog: blogs.ittoolbox.com/database/soup
# PostgreSQL: www.postgresql.org
  –   pgexperts: www.pgexperts.com
# Upcoming Events
  –   pgDay LA at SCALE9x
  –   MySQLCon

       This talk is copyright 2010 PostgreSQL Experts
       Inc., and is licensed under the creative commons
       attribution license. Images of Gilligan's Island TV
       show characters are property of CBS or the
       respective rights holders, and are used here under
       principles of fair use.

Contenu connexe

Tendances

PostgreSQL High Availability in a Containerized World
PostgreSQL High Availability in a Containerized WorldPostgreSQL High Availability in a Containerized World
PostgreSQL High Availability in a Containerized WorldJignesh Shah
 
Как PostgreSQL работает с диском
Как PostgreSQL работает с дискомКак PostgreSQL работает с диском
Как PostgreSQL работает с дискомPostgreSQL-Consulting
 
How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015
How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015
How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015PostgreSQL-Consulting
 
Mastering PostgreSQL Administration
Mastering PostgreSQL AdministrationMastering PostgreSQL Administration
Mastering PostgreSQL AdministrationEDB
 
GitLab PostgresMortem: Lessons Learned
GitLab PostgresMortem: Lessons LearnedGitLab PostgresMortem: Lessons Learned
GitLab PostgresMortem: Lessons LearnedAlexey Lesovsky
 
PostgreSQL Streaming Replication Cheatsheet
PostgreSQL Streaming Replication CheatsheetPostgreSQL Streaming Replication Cheatsheet
PostgreSQL Streaming Replication CheatsheetAlexey Lesovsky
 
Building tungsten-clusters-with-postgre sql-hot-standby-and-streaming-replica...
Building tungsten-clusters-with-postgre sql-hot-standby-and-streaming-replica...Building tungsten-clusters-with-postgre sql-hot-standby-and-streaming-replica...
Building tungsten-clusters-with-postgre sql-hot-standby-and-streaming-replica...Command Prompt., Inc
 
Out of the box replication in postgres 9.4
Out of the box replication in postgres 9.4Out of the box replication in postgres 9.4
Out of the box replication in postgres 9.4Denish Patel
 
Postgresql database administration volume 1
Postgresql database administration volume 1Postgresql database administration volume 1
Postgresql database administration volume 1Federico Campoli
 
Connection Pooling in PostgreSQL using pgbouncer
Connection Pooling in PostgreSQL using pgbouncer Connection Pooling in PostgreSQL using pgbouncer
Connection Pooling in PostgreSQL using pgbouncer Sameer Kumar
 
Patroni - HA PostgreSQL made easy
Patroni - HA PostgreSQL made easyPatroni - HA PostgreSQL made easy
Patroni - HA PostgreSQL made easyAlexander Kukushkin
 
plProxy, pgBouncer, pgBalancer
plProxy, pgBouncer, pgBalancerplProxy, pgBouncer, pgBalancer
plProxy, pgBouncer, pgBalancerelliando dias
 
Autovacuum, explained for engineers, new improved version PGConf.eu 2015 Vienna
Autovacuum, explained for engineers, new improved version PGConf.eu 2015 ViennaAutovacuum, explained for engineers, new improved version PGConf.eu 2015 Vienna
Autovacuum, explained for engineers, new improved version PGConf.eu 2015 ViennaPostgreSQL-Consulting
 
Tuning Linux for Databases.
Tuning Linux for Databases.Tuning Linux for Databases.
Tuning Linux for Databases.Alexey Lesovsky
 
Out of the box replication in postgres 9.4(pg confus)
Out of the box replication in postgres 9.4(pg confus)Out of the box replication in postgres 9.4(pg confus)
Out of the box replication in postgres 9.4(pg confus)Denish Patel
 
Logical replication with pglogical
Logical replication with pglogicalLogical replication with pglogical
Logical replication with pglogicalUmair Shahid
 
10 things i wish i'd known before using spark in production
10 things i wish i'd known before using spark in production10 things i wish i'd known before using spark in production
10 things i wish i'd known before using spark in productionParis Data Engineers !
 

Tendances (19)

PostgreSQL High Availability in a Containerized World
PostgreSQL High Availability in a Containerized WorldPostgreSQL High Availability in a Containerized World
PostgreSQL High Availability in a Containerized World
 
Как PostgreSQL работает с диском
Как PostgreSQL работает с дискомКак PostgreSQL работает с диском
Как PostgreSQL работает с диском
 
How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015
How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015
How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015
 
Mastering PostgreSQL Administration
Mastering PostgreSQL AdministrationMastering PostgreSQL Administration
Mastering PostgreSQL Administration
 
GitLab PostgresMortem: Lessons Learned
GitLab PostgresMortem: Lessons LearnedGitLab PostgresMortem: Lessons Learned
GitLab PostgresMortem: Lessons Learned
 
PostgreSQL Streaming Replication Cheatsheet
PostgreSQL Streaming Replication CheatsheetPostgreSQL Streaming Replication Cheatsheet
PostgreSQL Streaming Replication Cheatsheet
 
Building tungsten-clusters-with-postgre sql-hot-standby-and-streaming-replica...
Building tungsten-clusters-with-postgre sql-hot-standby-and-streaming-replica...Building tungsten-clusters-with-postgre sql-hot-standby-and-streaming-replica...
Building tungsten-clusters-with-postgre sql-hot-standby-and-streaming-replica...
 
Out of the box replication in postgres 9.4
Out of the box replication in postgres 9.4Out of the box replication in postgres 9.4
Out of the box replication in postgres 9.4
 
Postgresql database administration volume 1
Postgresql database administration volume 1Postgresql database administration volume 1
Postgresql database administration volume 1
 
Connection Pooling in PostgreSQL using pgbouncer
Connection Pooling in PostgreSQL using pgbouncer Connection Pooling in PostgreSQL using pgbouncer
Connection Pooling in PostgreSQL using pgbouncer
 
Patroni - HA PostgreSQL made easy
Patroni - HA PostgreSQL made easyPatroni - HA PostgreSQL made easy
Patroni - HA PostgreSQL made easy
 
Tuning Linux for MongoDB
Tuning Linux for MongoDBTuning Linux for MongoDB
Tuning Linux for MongoDB
 
plProxy, pgBouncer, pgBalancer
plProxy, pgBouncer, pgBalancerplProxy, pgBouncer, pgBalancer
plProxy, pgBouncer, pgBalancer
 
Autovacuum, explained for engineers, new improved version PGConf.eu 2015 Vienna
Autovacuum, explained for engineers, new improved version PGConf.eu 2015 ViennaAutovacuum, explained for engineers, new improved version PGConf.eu 2015 Vienna
Autovacuum, explained for engineers, new improved version PGConf.eu 2015 Vienna
 
Tuning Linux for Databases.
Tuning Linux for Databases.Tuning Linux for Databases.
Tuning Linux for Databases.
 
Out of the box replication in postgres 9.4(pg confus)
Out of the box replication in postgres 9.4(pg confus)Out of the box replication in postgres 9.4(pg confus)
Out of the box replication in postgres 9.4(pg confus)
 
Logical replication with pglogical
Logical replication with pglogicalLogical replication with pglogical
Logical replication with pglogical
 
10 things i wish i'd known before using spark in production
10 things i wish i'd known before using spark in production10 things i wish i'd known before using spark in production
10 things i wish i'd known before using spark in production
 
JahiaOne - Performance Tuning
JahiaOne - Performance TuningJahiaOne - Performance Tuning
JahiaOne - Performance Tuning
 

Similaire à GUC Tutorial Package (9.0)

guc_tutorial_10.pdf
guc_tutorial_10.pdfguc_tutorial_10.pdf
guc_tutorial_10.pdfssuser164ae5
 
PostgreSQL Administration for System Administrators
PostgreSQL Administration for System AdministratorsPostgreSQL Administration for System Administrators
PostgreSQL Administration for System AdministratorsCommand Prompt., Inc
 
Grabbing the PostgreSQL Elephant by the Trunk
Grabbing the PostgreSQL Elephant by the TrunkGrabbing the PostgreSQL Elephant by the Trunk
Grabbing the PostgreSQL Elephant by the TrunkHarold Giménez
 
OpenGurukul : Database : PostgreSQL
OpenGurukul : Database : PostgreSQLOpenGurukul : Database : PostgreSQL
OpenGurukul : Database : PostgreSQLOpen Gurukul
 
The Essential postgresql.conf
The Essential postgresql.confThe Essential postgresql.conf
The Essential postgresql.confRobert Treat
 
Oracle to Postgres Migration - part 2
Oracle to Postgres Migration - part 2Oracle to Postgres Migration - part 2
Oracle to Postgres Migration - part 2PgTraining
 
PuppetDB: Sneaking Clojure into Operations
PuppetDB: Sneaking Clojure into OperationsPuppetDB: Sneaking Clojure into Operations
PuppetDB: Sneaking Clojure into Operationsgrim_radical
 
PuppetConf 2016: An Introduction to Measuring and Tuning PE Performance – Cha...
PuppetConf 2016: An Introduction to Measuring and Tuning PE Performance – Cha...PuppetConf 2016: An Introduction to Measuring and Tuning PE Performance – Cha...
PuppetConf 2016: An Introduction to Measuring and Tuning PE Performance – Cha...Puppet
 
Cloud Meetup - Automation in the Cloud
Cloud Meetup - Automation in the CloudCloud Meetup - Automation in the Cloud
Cloud Meetup - Automation in the Cloudpetriojala123
 
Pandora FMS: PostgreSQL Plugin
Pandora FMS: PostgreSQL PluginPandora FMS: PostgreSQL Plugin
Pandora FMS: PostgreSQL PluginPandora FMS
 
Why and How Powershell will rule the Command Line - Barcamp LA 4
Why and How Powershell will rule the Command Line - Barcamp LA 4Why and How Powershell will rule the Command Line - Barcamp LA 4
Why and How Powershell will rule the Command Line - Barcamp LA 4Ilya Haykinson
 
Play vs Grails Smackdown - Devoxx France 2013
Play vs Grails Smackdown - Devoxx France 2013Play vs Grails Smackdown - Devoxx France 2013
Play vs Grails Smackdown - Devoxx France 2013Matt Raible
 
Frontend JS workflow - Gulp 4 and the like
Frontend JS workflow - Gulp 4 and the likeFrontend JS workflow - Gulp 4 and the like
Frontend JS workflow - Gulp 4 and the likeDamien Seguin
 
alfresco-global.properties-COMPLETO-3.4.6
alfresco-global.properties-COMPLETO-3.4.6alfresco-global.properties-COMPLETO-3.4.6
alfresco-global.properties-COMPLETO-3.4.6alfrescosedemo
 
linux_Commads
linux_Commadslinux_Commads
linux_Commadstastedone
 
Setup oracle golden gate 11g replication
Setup oracle golden gate 11g replicationSetup oracle golden gate 11g replication
Setup oracle golden gate 11g replicationKanwar Batra
 
X64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 newX64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 newYiwei Ma
 

Similaire à GUC Tutorial Package (9.0) (20)

guc_tutorial_10.pdf
guc_tutorial_10.pdfguc_tutorial_10.pdf
guc_tutorial_10.pdf
 
PostgreSQL Administration for System Administrators
PostgreSQL Administration for System AdministratorsPostgreSQL Administration for System Administrators
PostgreSQL Administration for System Administrators
 
Grabbing the PostgreSQL Elephant by the Trunk
Grabbing the PostgreSQL Elephant by the TrunkGrabbing the PostgreSQL Elephant by the Trunk
Grabbing the PostgreSQL Elephant by the Trunk
 
OpenGurukul : Database : PostgreSQL
OpenGurukul : Database : PostgreSQLOpenGurukul : Database : PostgreSQL
OpenGurukul : Database : PostgreSQL
 
The Essential postgresql.conf
The Essential postgresql.confThe Essential postgresql.conf
The Essential postgresql.conf
 
Oracle to Postgres Migration - part 2
Oracle to Postgres Migration - part 2Oracle to Postgres Migration - part 2
Oracle to Postgres Migration - part 2
 
PuppetDB: Sneaking Clojure into Operations
PuppetDB: Sneaking Clojure into OperationsPuppetDB: Sneaking Clojure into Operations
PuppetDB: Sneaking Clojure into Operations
 
PuppetConf 2016: An Introduction to Measuring and Tuning PE Performance – Cha...
PuppetConf 2016: An Introduction to Measuring and Tuning PE Performance – Cha...PuppetConf 2016: An Introduction to Measuring and Tuning PE Performance – Cha...
PuppetConf 2016: An Introduction to Measuring and Tuning PE Performance – Cha...
 
Cloud Meetup - Automation in the Cloud
Cloud Meetup - Automation in the CloudCloud Meetup - Automation in the Cloud
Cloud Meetup - Automation in the Cloud
 
Pandora FMS: PostgreSQL Plugin
Pandora FMS: PostgreSQL PluginPandora FMS: PostgreSQL Plugin
Pandora FMS: PostgreSQL Plugin
 
PostgreSQL Prologue
PostgreSQL ProloguePostgreSQL Prologue
PostgreSQL Prologue
 
Why and How Powershell will rule the Command Line - Barcamp LA 4
Why and How Powershell will rule the Command Line - Barcamp LA 4Why and How Powershell will rule the Command Line - Barcamp LA 4
Why and How Powershell will rule the Command Line - Barcamp LA 4
 
Play vs Grails Smackdown - Devoxx France 2013
Play vs Grails Smackdown - Devoxx France 2013Play vs Grails Smackdown - Devoxx France 2013
Play vs Grails Smackdown - Devoxx France 2013
 
Streaming replication
Streaming replicationStreaming replication
Streaming replication
 
Frontend JS workflow - Gulp 4 and the like
Frontend JS workflow - Gulp 4 and the likeFrontend JS workflow - Gulp 4 and the like
Frontend JS workflow - Gulp 4 and the like
 
alfresco-global.properties-COMPLETO-3.4.6
alfresco-global.properties-COMPLETO-3.4.6alfresco-global.properties-COMPLETO-3.4.6
alfresco-global.properties-COMPLETO-3.4.6
 
Gg steps
Gg stepsGg steps
Gg steps
 
linux_Commads
linux_Commadslinux_Commads
linux_Commads
 
Setup oracle golden gate 11g replication
Setup oracle golden gate 11g replicationSetup oracle golden gate 11g replication
Setup oracle golden gate 11g replication
 
X64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 newX64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 new
 

Plus de PostgreSQL Experts, Inc.

Elephant Roads: PostgreSQL Patches and Variants
Elephant Roads: PostgreSQL Patches and VariantsElephant Roads: PostgreSQL Patches and Variants
Elephant Roads: PostgreSQL Patches and VariantsPostgreSQL Experts, Inc.
 

Plus de PostgreSQL Experts, Inc. (20)

Fail over fail_back
Fail over fail_backFail over fail_back
Fail over fail_back
 
HowTo DR
HowTo DRHowTo DR
HowTo DR
 
Give A Great Tech Talk 2013
Give A Great Tech Talk 2013Give A Great Tech Talk 2013
Give A Great Tech Talk 2013
 
Pg py-and-squid-pypgday
Pg py-and-squid-pypgdayPg py-and-squid-pypgday
Pg py-and-squid-pypgday
 
Five steps perform_2013
Five steps perform_2013Five steps perform_2013
Five steps perform_2013
 
PWNage: Producing a newsletter with Perl
PWNage: Producing a newsletter with PerlPWNage: Producing a newsletter with Perl
PWNage: Producing a newsletter with Perl
 
10 Ways to Destroy Your Community
10 Ways to Destroy Your Community10 Ways to Destroy Your Community
10 Ways to Destroy Your Community
 
Open Source Press Relations
Open Source Press RelationsOpen Source Press Relations
Open Source Press Relations
 
5 (more) Ways To Destroy Your Community
5 (more) Ways To Destroy Your Community5 (more) Ways To Destroy Your Community
5 (more) Ways To Destroy Your Community
 
Preventing Community (from Linux Collab)
Preventing Community (from Linux Collab)Preventing Community (from Linux Collab)
Preventing Community (from Linux Collab)
 
Development of 8.3 In India
Development of 8.3 In IndiaDevelopment of 8.3 In India
Development of 8.3 In India
 
PostgreSQL and MySQL
PostgreSQL and MySQLPostgreSQL and MySQL
PostgreSQL and MySQL
 
50 Ways To Love Your Project
50 Ways To Love Your Project50 Ways To Love Your Project
50 Ways To Love Your Project
 
8.4 Upcoming Features
8.4 Upcoming Features 8.4 Upcoming Features
8.4 Upcoming Features
 
Elephant Roads: PostgreSQL Patches and Variants
Elephant Roads: PostgreSQL Patches and VariantsElephant Roads: PostgreSQL Patches and Variants
Elephant Roads: PostgreSQL Patches and Variants
 
Writeable CTEs: The Next Big Thing
Writeable CTEs: The Next Big ThingWriteable CTEs: The Next Big Thing
Writeable CTEs: The Next Big Thing
 
PostgreSQL Development Today: 9.0
PostgreSQL Development Today: 9.0PostgreSQL Development Today: 9.0
PostgreSQL Development Today: 9.0
 
9.1 Mystery Tour
9.1 Mystery Tour9.1 Mystery Tour
9.1 Mystery Tour
 
Postgres Open Keynote: The Next 25 Years
Postgres Open Keynote: The Next 25 YearsPostgres Open Keynote: The Next 25 Years
Postgres Open Keynote: The Next 25 Years
 
9.1 Grand Tour
9.1 Grand Tour9.1 Grand Tour
9.1 Grand Tour
 

Dernier

Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024SynarionITSolutions
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
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 2024The Digital Insurer
 
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 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
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...apidays
 

Dernier (20)

Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
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
 
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
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
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...
 

GUC Tutorial Package (9.0)

  • 1. The GUCS: A Three-Hour Tour Josh Berkus PostgreSQL Experts Inc. DrakeCon 2010 - San Francisco
  • 2. agenda # what are GUCS? # understanding GUCS # simple basic configuration # new GUCS # grand tour
  • 3. related stuff X # pg_hba.conf # recovery.conf # pg_ident.conf # libpq settings # psql commands # system functions
  • 4. What are GUCS? # “Grand Unified Configuration Settings” – A large set of global and session database settings which live in: src/backend/utils/misc/guc.c # Your main way of configuring and tuning the database. – in addition to compile options, system configuration and schema tuning! # Pronounced “gucks”
  • 8. Setting GUCS 8 6 5
  • 9. Eight types of GUCS # Boolean # Time # Integer # Strings # Float # ENUMs # Memory / Disk # Lists
  • 10. Eight types of GUCS # Boolean – take TRUE | FALSE or ON | OFF enable_seqscan = on # Integer – take whole numbers only max_connections = 700
  • 11. Eight types of GUCS # Float – take decimal values random_page_cost = 3.75 # Memory / Disk Size – can take integers – but can also take “computer units”: kB, MB, GB work_mem = 512MB shared_buffers = 4096
  • 12. Eight Types of GUCS # Time – take time values (units vary) – units are often omitted authentication_timeout = 30s # Strings – take unchecked strings – often refers to file locations or program names log_directory = 'pg_log'
  • 13. Eight Types of GUCS # ENUMs – take a string value from a prescribed list wal_level = hot_standby # Lists – take a list of values, either freeform or ENUM search_path = 'main, archive, “$user”'
  • 14. Six GUCS Contexts # session # superuser # reload # restart # backend # internal
  • 15. Six GUCS Contexts # session, or “user” – can be set on per-session basis at runtime – can also be changed by altering the ROLE # superuser – can be set at runtime for the whole server, but only by the superuser
  • 16. Six GUCS Contexts # reload, or “sighup” – requires a soft restart of the postmaster to change – also called a “HUP” # restart, or “postmaster” – can only be changed with a hard restart
  • 17. More on reloading # Three methods for reloading pg_ctl -D PGDATA reload kill -HUP <postmaster.pid> SELECT pg_reload_conf();
  • 18. Six GUCS Contexts # backend – developer settings which have to be set before session start # internal – compile-time settings provided for reference. Unalterable.
  • 19. 5 Places of set GUCs 1.postgresql.conf file 2.SET 3.pg_settings 4.ALTER objects 5.command-line switches & PGOPTIONS
  • 20. postgresql.conf # $PGDATA/postgresql.conf – can be relocated or symlinked # Primary way to change GUCS – for performance – for logging – for defaults
  • 21. postgresql.conf # just a big list of settings # defaults are “# commented” out # if a setting appears multiple times, the last one takes effect # can use “include” files
  • 22. SET & SHOW # Access GUCS in a SQL session – SET changes ● only applies to user and superuser contexts ● best way to change things for only one session ● can be embedded in stored procedures SET enable_mergejoin = false; – SHOW displays ● SHOW ALL lets you see all GUCS SHOW shared_buffers;
  • 23. SET & SHOW: set_config # set_config( setting, value, is_local ) – alternative to SET – better for scripts since it takes a string SELECT set_config('work_mem','1GB', TRUE); # current_setting ( setting ) – alternative to SHOW SELECT current_setting('lc_collate');
  • 24. pg_settings # Tabular representation of GUCS – a “system view” – can be queried – can be updated, which runs a SET on the relevant parameter SELECT * FROM pg_settings WHERE name = 'work_mem'; UPDATE pg_settings SET setting = '12MB' WHERE name = 'work_mem';
  • 25. ALTER objects # You can ALTER some objects to change their configuration settings – ROLES (users) – DATABASEs – FUNCTIONs – Changes configuration setting when that object is used (unless overridden by a SET) ALTER ROLE “data entry” SET search_path = 'entry, public';
  • 26. New ALTER ROLE for 9.0 ALTER ROLE IN DATABASE accts SET search_path = '$user, webview, contrib, public'; # now can set ROLE-based settings just for a specific database # essential for search_path, useful for others
  • 27. ALTER objects # Good way to discriminate between applications & users – set search_path ● sometimes for security – primitive resource management ● change work_mem, etc. for specific ROLES, applications or reports – localization ● if different users have different desired displays ALTER DATABASE sao_paulo SET timezone = 'America/SaoPaulo';
  • 28. ALTER objects CREATE FUNCTION check_password(uname TEXT, pass TEXT) RETURNS BOOLEAN AS $$ DECLARE passed BOOLEAN; BEGIN SELECT (pwd = $2) INTO passed FROM pwds WHERE username = $1; RETURN passed; END; $$ LANGUAGE plpgsql SECURITY DEFINER -- Set a secure search_path: trusted -- schema(s), then 'pg_temp'. SET search_path = admin, pg_temp;
  • 29. command-line and pgoptions # Set options when you start PostgreSQL – as command-line switches – using the PGOPTIONS shell variable # Not generally recommended – hard to administrate or document – mainly for running automated tests ● and for restarting with recovery options postgres -c 'bgwriter_delay = 50ms' export PGOPTIONS = '-c zero_damaged_pages = ON'
  • 31. The 13 Settings most users need to adjust (1) listen_address (8) checkpoint_segments (2) max_connections (9) wal_buffers (3) shared_buffers (10) autovacuum (4) work_mem (11) effective_cache_size (5) maintenance_ (12) GROUP: replication work_mem (13) GROUP: the logging settings (6) synchronous_commit
  • 35. security & authentication # bonjour – lets you turn bonjour support off even if it's compiled # ssl_renegotiation_limit – works around SSL patch from OpenSSL exploit
  • 36. application_name # settable per session # lets you log which application is running which statements – different ROLEs no longer required
  • 37. query planner settings # enable_material – lets you turn on and off materialization of subqueries for query plan troubleshooting # geqo_seed – make sure that GEQO plans are determinative for the same inputs
  • 38. backwards compatibility # bytea_output – supports old bytea escapes as opposed to new hex format # lo_compat_privileges – disables new permission checks for large objects
  • 39. replication settings # wal_level # wal_sender_delay # wal_keep_segments # hot_standby # max_wal_senders # vacuum_defer_cleanup_age # max_standby_archive_delay # max_standby_streaming_delay # trace_recovery
  • 41. Categories (mine) # file locations # statistics # connection settings # locks # resource # locale & formatting management # other settings & # maintenance defaults # WAL & checkpoints # compatibility # replication # custom GUCS # query tuning # developer options # logging # presets
  • 42. custom variable classes # for supporting various PostgreSQL Extensions custom_variable_classes = 'pg_stat_statements,auto_explain' pg_stat_statements.max = 10000 pg_stat_statements.track = all auto_explain.log_min_duration = '200ms' auto_explain.log_nested_statements = on auto_explain.log_format = json
  • 43. Finale 1) config_file 20) ssl 2) data_directory 21) krb_caseins_users 3) hba_file 22) krb_realm 4) ident_file 23) krb_server_hostname 5) external_pid_file 24) krb_server_keyfile 6) listen_addresses 25) krb_srvname 7) port 26) shared_buffers 8) max_connections 27) work_mem 9) superuser_reserved_connections 28) temp_buffers 10) unix_socket_directory 29) max_prepared_transactions 11) unix_socket_group 30) max_files_per_process 12) unix_socket_permissions 31) max_stack_depth 13) bonjour_name 32) shared_preload_libraries 14) authentication_timeout 33) maintenance_work_mem 15) tcp_keepalives_count 34) max_fsm_pages 16) tcp_keepalives_idle 35) max_fsm_relations 17) tcp_keepalives_interval 36) vacuum_cost_delay 18) db_user_namespace 37) vacuum_cost_limit 19) password_encryption 38) vacuum_cost_page_dirty
  • 44. Contact # Josh Berkus: josh@postgresql.org – blog: blogs.ittoolbox.com/database/soup # PostgreSQL: www.postgresql.org – pgexperts: www.pgexperts.com # Upcoming Events – pgDay LA at SCALE9x – MySQLCon This talk is copyright 2010 PostgreSQL Experts Inc., and is licensed under the creative commons attribution license. Images of Gilligan's Island TV show characters are property of CBS or the respective rights holders, and are used here under principles of fair use.