SlideShare a Scribd company logo
1 of 39
The Essential
                PostgreSQL.conf

                           9

                Robert Treat, JDCon East 2011

Thursday, March 31, 2011
Introduction

           • Robert
Treat
                 • OmniTI
                           • Database
Management
and
Consulting
                           • Large
and/or
High
Traffic
Architectures
                           • We’re
Hiring!
                 • Postgres
                           • Web,

Advocacy,
Conferences,
PhpPgAdmin
                           • Major
Contributor
                 • xzilla.net
                           • @robtreat2
Thursday, March 31, 2011
Introduction

           • Robert
Treat
                 • OmniTI
                           • Database
Management
and
Consulting
                           • Large
and/or
High
Traffic
Architectures
                           • We’re
Hiring!
                 • Postgres
                           • Web,

Advocacy,
Conferences,
PhpPgAdmin
                           • Major
Contributor
                 • xzilla.net
                           • @robtreat2
Thursday, March 31, 2011
The Grand Scheme




               • Understanding the postgresql.conf
               • Essential postgresql.conf parameters


Thursday, March 31, 2011
The Grand Scheme




               • Understanding the postgresql.conf
               • Essential postgresql.conf parameters


Thursday, March 31, 2011
Understanding the postgresql.conf




               • Types of Settings
               • When Settings Take Effect
               • PostgreSQL.conf “Gotchas”
               • Viewing Your Current Settings

Thursday, March 31, 2011
Types of Settings




Thursday, March 31, 2011
Types of Settings

               • Boolean: true, false, on, off




Thursday, March 31, 2011
Types of Settings

               • Boolean: true, false, on, off
               • Integer: whole numbers (2112)




Thursday, March 31, 2011
Types of Settings

               • Boolean: true, false, on, off
               • Integer: whole numbers (2112)
               • Float: decimal values (21.12)




Thursday, March 31, 2011
Types of Settings

               • Boolean: true, false, on, off
               • Integer: whole numbers (2112)
               • Float: decimal values (21.12)
               • Memory/Disk Units: 128MB, 2112GB




Thursday, March 31, 2011
Types of Settings

               • Boolean: true, false, on, off
               • Integer: whole numbers (2112)
               • Float: decimal values (21.12)
               • Memory/Disk Units: 128MB, 2112GB
                     •     Avoid using integers to size memory parameters




Thursday, March 31, 2011
Types of Settings

               • Boolean: true, false, on, off
               • Integer: whole numbers (2112)
               • Float: decimal values (21.12)
               • Memory/Disk Units: 128MB, 2112GB
                     •     Avoid using integers to size memory parameters

               • Time: d,m,s (30s)



Thursday, March 31, 2011
Types of Settings

               • Boolean: true, false, on, off
               • Integer: whole numbers (2112)
               • Float: decimal values (21.12)
               • Memory/Disk Units: 128MB, 2112GB
                     •     Avoid using integers to size memory parameters

               • Time: d,m,s (30s)
               • Strings: single quotes (‘pg_log’)


Thursday, March 31, 2011
Types of Settings

               • Boolean: true, false, on, off
               • Integer: whole numbers (2112)
               • Float: decimal values (21.12)
               • Memory/Disk Units: 128MB, 2112GB
                     •     Avoid using integers to size memory parameters

               • Time: d,m,s (30s)
               • Strings: single quotes (‘pg_log’)
               • Enum: single quotes (‘WARNING’ or ‘ERROR’)

Thursday, March 31, 2011
Types of Settings

               • Boolean: true, false, on, off
               • Integer: whole numbers (2112)
               • Float: decimal values (21.12)
               • Memory/Disk Units: 128MB, 2112GB
                     •     Avoid using integers to size memory parameters

               • Time: d,m,s (30s)
               • Strings: single quotes (‘pg_log’)
               • Enum: single quotes (‘WARNING’ or ‘ERROR’)
                     •     Limited set of acceptable strings

Thursday, March 31, 2011
Types of Settings

               • Boolean: true, false, on, off
               • Integer: whole numbers (2112)
               • Float: decimal values (21.12)
               • Memory/Disk Units: 128MB, 2112GB
                     •     Avoid using integers to size memory parameters

               • Time: d,m,s (30s)
               • Strings: single quotes (‘pg_log’)
               • Enum: single quotes (‘WARNING’ or ‘ERROR’)
                     •     Limited set of acceptable strings

               • Lists: comma seperated (‘“$user”,public,tsearch2’)
Thursday, March 31, 2011
When Settings Take Effect

               • Internal: set at compile time
               • Postmaster: requires database restart
               • Backend: must be set before session start
               • Sighup: change by reloading conf file
                     •     pg_reload_conf(), pg_ctl reload, kill -HUP

               • Superuser: set at runtime by superuser
               • User: set at runtime, affects only a single session
See
pg_settings.context
to
determine
setting
type
Thursday, March 31, 2011
When Settings Take Effect

               • Internal: set at compile time
               • Postmaster: requires database restart
               • Backend: must be set before session start
               • Sighup: change by reloading conf file
                     •     pg_reload_conf(), pg_ctl reload, kill -HUP

               • Superuser: set at runtime by superuser
               • User: set at runtime, affects only a single session
See
pg_settings.context
to
determine
setting
type
Thursday, March 31, 2011
postgresql.conf Gotchas!




               • Where is my postgresql.conf ?
               • $PGDATA/postgresql.conf
                     •     watch out for symbolic links

                     •     some distros put it in other places (/etc)

                     •     SHOW data_directory;

                     •     SHOW config_file;




Thursday, March 31, 2011
postgresql.conf Gotchas!




               • Lines with #
                     •     This line is a comment, and has no effect

                     •     On a fresh install, uses defaults

                     •     Commenting a line is the same as deleting a line,
                           it will restore the “default” for that instance




Thursday, March 31, 2011
Viewing Your Current Settings
               • Look in postgresql.conf
                     •     Works if you follow best practices

                     •     Not definitive!




Thursday, March 31, 2011
Viewing Your Current Settings
               • Look in postgresql.conf
                     •     Works if you follow best practices

                     •     Not definitive!

               • SHOW ALL, SHOW <setting>,
                       current_setting(setting)
                     •     Shows the current value

                     •     Watch out for session specific changes




Thursday, March 31, 2011
Viewing Your Current Settings
               • Look in postgresql.conf
                     •     Works if you follow best practices

                     •     Not definitive!

               • SHOW ALL, SHOW <setting>,
                       current_setting(setting)
                     •     Shows the current value

                     •     Watch out for session specific changes

               • SELECT * FROM pg_settings
                     •     Shows the current value

                     •     “source” column
Thursday, March 31, 2011
Viewing Your Current Settings

   pagila=# select current_setting(name), * from pg_settings
   where name = 'shared_buffers';
   -[ RECORD 1 ]------+----------------------------------------------
   current_setting         |   1600kB
   name                    |   shared_buffers
   setting                 |   200
   unit                    |   8kB
   category                |   Resource Usage / Memory
   short_desc              |   Sets the number of shared memory buffers used by the server.
   extra_desc              |
   context                 |   postmaster
   vartype                 |   integer
   source                  |   configuration file
   min_val                 |   16
   max_val                 |   1073741823
   enumvals                |
   boot_val                |   1024
   reset_val               |   200
   sourcefile              |   /opt/local/var/db/postgresql91/data/postgresql.conf
   sourceline              |   109

Thursday, March 31, 2011
The Essential Parameters


             • Logging
             • Getting Connected
             • Sizing Memory
             • Checkpoint Management
             • Vacuum Managment
             • WAL management
Thursday, March 31, 2011
Logging



          • log_destination, log_directory, log_filename
                • find out where you are logging
                • might be good to log to a different disk than your data




Thursday, March 31, 2011
Logging



          • log_destination, log_directory, log_filename
                • find out where you are logging
                • might be good to log to a different disk than your data


          • log_line_prefix
                • generic recommendation: ‘%t: %r: %u@%d: [%p]: ‘
                • timestamp, connecting host, username, database, pid



Thursday, March 31, 2011
Get Connected

          • listen_addresses
                • requires restart!
                • default is localhost only
                • use * to enable tcp/ip




Thursday, March 31, 2011
Get Connected

          • listen_addresses
                • requires restart!
                • default is localhost only
                • use * to enable tcp/ip

          • max_connections
                • requires restart!
                • 100 default (apache children default is higher)
                • affects other settings (work_mem)
                • for 1000+ connections, use connection pooler
Thursday, March 31, 2011
Sizing Memory

          • shared_buffers
                • requires restart!
                • most important setting for good performance
                • allocation of memory for Postgres caching
                • ~20% of Total Available RAM (up to 2GB)
                     • 32GB RAM, 1920 MB is probably ok
                     • 256GB RAM, 50 GB is probably not optimal
                     • Windows users probably want less
                • may require adjusting kernel params (shmmax)
                     • http://www.postgresql.org/docs/current/interactive/kernel-resources.html
Thursday, March 31, 2011
Sizing Memory

       • effective_cache_size
             • most important setting for good performance
             • based on memory available for filesystem cache
             • SET = TRAM - (DRAM - PGRAM)
                   • TRAM = Total RAM
                   • DRAM = RAM needed by OS and other apps
                   • PGRAM = RAM needed for Postgres (shared_buffers, etc...)
             • Guide for available memory, not an allocation



Thursday, March 31, 2011
Sizing Memory

          • work_mem
                • used by queries for sorting
                • higher values for more complex queries
                • limit is per sort
                     • 5 sorts in 1 query = 5*work_mem


          • maintenance_work_mem
                • used by vacuum, indexing, and similar operations
                • semi-allocation of memory when needed
                • don’t be scared to make this big (1GB)
Thursday, March 31, 2011
Checkpoint Management

          • checkpoint_segments
                • controls the amount of data required per checkpoint
                • default 3, recommended minimum of 10
                • set higher for heavy write activity
                     • 30 - 300 is not uncommon
                • increases space needed in pg_xlog
                • increases recovery time after crash
          • checkpoint_completion_target
                • with checkpoint_segments >= 10, set this to .9
                • http://www.westnet.com/~gsmith/content/postgresql/chkp-bgw-83.htm
Thursday, March 31, 2011
Vacuum Management



          • autovacuum
          • max_fsm_pages
          • max_fsm_relations
          • default_statistics_target
          • autovacuum_freeze_max_age
                • set to 1,000,000,000 to reduce vacuums for non-activity
                • requires restart


Thursday, March 31, 2011
WAL Management / Replication

          • WAL for Performance
                • wal_buffers
                  • requires restart!
                  • needed for write heavy loads
                  • 16MB, “set it and forget it!”
                • synchronous_commit
                   • can increase tps by a large margin
                   • allows data loss without corruption
                      • BAD: fsync = off
                      • GOOD: synchronous_commit = off
                   • can be set per database, user, or transaction
Thursday, March 31, 2011
WAL Management / Replication




          • WAL for Replication
                • wal_level
                  • requires restart!
                  • “hot_standby” needed for... hot standbys
                • max_wal_senders
                  • requires restart!
                  • controls the number of connections for streaming
                           replication



Thursday, March 31, 2011
The End



                                                  Thanks!


                                       Additional Resources
                   http://www.postgresql.org/docs/current/interactive/runtime-config.html

                           http://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server


                                                     Slides
                                         http://www.xzilla.net/writings.html



Thursday, March 31, 2011
No Really, The End




Thursday, March 31, 2011

More Related Content

Viewers also liked

Postgres in Production - Best Practices 2014
Postgres in Production - Best Practices 2014Postgres in Production - Best Practices 2014
Postgres in Production - Best Practices 2014EDB
 
Teaching Students with Emojis, Emoticons, & Textspeak
Teaching Students with Emojis, Emoticons, & TextspeakTeaching Students with Emojis, Emoticons, & Textspeak
Teaching Students with Emojis, Emoticons, & TextspeakShelly Sanchez Terrell
 
UX, ethnography and possibilities: for Libraries, Museums and Archives
UX, ethnography and possibilities: for Libraries, Museums and ArchivesUX, ethnography and possibilities: for Libraries, Museums and Archives
UX, ethnography and possibilities: for Libraries, Museums and ArchivesNed Potter
 
Hype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerHype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerLuminary Labs
 
Designing Teams for Emerging Challenges
Designing Teams for Emerging ChallengesDesigning Teams for Emerging Challenges
Designing Teams for Emerging ChallengesAaron Irizarry
 
Visual Design with Data
Visual Design with DataVisual Design with Data
Visual Design with DataSeth Familian
 
The Essential postgresql.conf
The Essential postgresql.confThe Essential postgresql.conf
The Essential postgresql.confRobert Treat
 
3 Things Every Sales Team Needs to Be Thinking About in 2017
3 Things Every Sales Team Needs to Be Thinking About in 20173 Things Every Sales Team Needs to Be Thinking About in 2017
3 Things Every Sales Team Needs to Be Thinking About in 2017Drift
 
How to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheHow to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheLeslie Samuel
 
Moodle Development Best Pracitces
Moodle Development Best PracitcesMoodle Development Best Pracitces
Moodle Development Best PracitcesJustin Filip
 
Postgres 9.4 First Look
Postgres 9.4 First LookPostgres 9.4 First Look
Postgres 9.4 First LookRobert Treat
 
Less Alarming Alerts - SRECon 2016
Less Alarming Alerts - SRECon 2016 Less Alarming Alerts - SRECon 2016
Less Alarming Alerts - SRECon 2016 Robert Treat
 
plProxy, pgBouncer, pgBalancer
plProxy, pgBouncer, pgBalancerplProxy, pgBouncer, pgBalancer
plProxy, pgBouncer, pgBalancerelliando dias
 
EDB Postgres DBA Best Practices
EDB Postgres DBA Best PracticesEDB Postgres DBA Best Practices
EDB Postgres DBA Best PracticesEDB
 
Managing Databases In A DevOps Environment
Managing Databases In A DevOps EnvironmentManaging Databases In A DevOps Environment
Managing Databases In A DevOps EnvironmentRobert Treat
 
Managing Databases In A DevOps Environment 2016
Managing Databases In A DevOps Environment 2016Managing Databases In A DevOps Environment 2016
Managing Databases In A DevOps Environment 2016Robert Treat
 
Best Practices for a Complete Postgres Enterprise Architecture Setup
Best Practices for a Complete Postgres Enterprise Architecture SetupBest Practices for a Complete Postgres Enterprise Architecture Setup
Best Practices for a Complete Postgres Enterprise Architecture SetupEDB
 

Viewers also liked (20)

Postgres in Production - Best Practices 2014
Postgres in Production - Best Practices 2014Postgres in Production - Best Practices 2014
Postgres in Production - Best Practices 2014
 
5 Steps to PostgreSQL Performance
5 Steps to PostgreSQL Performance5 Steps to PostgreSQL Performance
5 Steps to PostgreSQL Performance
 
Backups
BackupsBackups
Backups
 
Inaugural Addresses
Inaugural AddressesInaugural Addresses
Inaugural Addresses
 
Teaching Students with Emojis, Emoticons, & Textspeak
Teaching Students with Emojis, Emoticons, & TextspeakTeaching Students with Emojis, Emoticons, & Textspeak
Teaching Students with Emojis, Emoticons, & Textspeak
 
UX, ethnography and possibilities: for Libraries, Museums and Archives
UX, ethnography and possibilities: for Libraries, Museums and ArchivesUX, ethnography and possibilities: for Libraries, Museums and Archives
UX, ethnography and possibilities: for Libraries, Museums and Archives
 
Hype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerHype vs. Reality: The AI Explainer
Hype vs. Reality: The AI Explainer
 
Designing Teams for Emerging Challenges
Designing Teams for Emerging ChallengesDesigning Teams for Emerging Challenges
Designing Teams for Emerging Challenges
 
Visual Design with Data
Visual Design with DataVisual Design with Data
Visual Design with Data
 
The Essential postgresql.conf
The Essential postgresql.confThe Essential postgresql.conf
The Essential postgresql.conf
 
3 Things Every Sales Team Needs to Be Thinking About in 2017
3 Things Every Sales Team Needs to Be Thinking About in 20173 Things Every Sales Team Needs to Be Thinking About in 2017
3 Things Every Sales Team Needs to Be Thinking About in 2017
 
How to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheHow to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your Niche
 
Moodle Development Best Pracitces
Moodle Development Best PracitcesMoodle Development Best Pracitces
Moodle Development Best Pracitces
 
Postgres 9.4 First Look
Postgres 9.4 First LookPostgres 9.4 First Look
Postgres 9.4 First Look
 
Less Alarming Alerts - SRECon 2016
Less Alarming Alerts - SRECon 2016 Less Alarming Alerts - SRECon 2016
Less Alarming Alerts - SRECon 2016
 
plProxy, pgBouncer, pgBalancer
plProxy, pgBouncer, pgBalancerplProxy, pgBouncer, pgBalancer
plProxy, pgBouncer, pgBalancer
 
EDB Postgres DBA Best Practices
EDB Postgres DBA Best PracticesEDB Postgres DBA Best Practices
EDB Postgres DBA Best Practices
 
Managing Databases In A DevOps Environment
Managing Databases In A DevOps EnvironmentManaging Databases In A DevOps Environment
Managing Databases In A DevOps Environment
 
Managing Databases In A DevOps Environment 2016
Managing Databases In A DevOps Environment 2016Managing Databases In A DevOps Environment 2016
Managing Databases In A DevOps Environment 2016
 
Best Practices for a Complete Postgres Enterprise Architecture Setup
Best Practices for a Complete Postgres Enterprise Architecture SetupBest Practices for a Complete Postgres Enterprise Architecture Setup
Best Practices for a Complete Postgres Enterprise Architecture Setup
 

Similar to The Essential PostgreSQL.conf

Spotify: Horizontal Scalability for Great Success
Spotify: Horizontal Scalability for Great SuccessSpotify: Horizontal Scalability for Great Success
Spotify: Horizontal Scalability for Great SuccessNick Barkas
 
Drizzle 7.0, Future of Virtualizing
Drizzle 7.0, Future of VirtualizingDrizzle 7.0, Future of Virtualizing
Drizzle 7.0, Future of VirtualizingBrian Aker
 
7. Key-Value Databases: In Depth
7. Key-Value Databases: In Depth7. Key-Value Databases: In Depth
7. Key-Value Databases: In DepthFabio Fumarola
 
PostgreSQL worst practices, version PGConf.US 2017 by Ilya Kosmodemiansky
PostgreSQL worst practices, version PGConf.US 2017 by Ilya KosmodemianskyPostgreSQL worst practices, version PGConf.US 2017 by Ilya Kosmodemiansky
PostgreSQL worst practices, version PGConf.US 2017 by Ilya KosmodemianskyPostgreSQL-Consulting
 
Implementing the Databese Server session 02
Implementing the Databese Server session 02Implementing the Databese Server session 02
Implementing the Databese Server session 02Guillermo Julca
 
Ledingkart Meetup #2: Scaling Search @Lendingkart
Ledingkart Meetup #2: Scaling Search @LendingkartLedingkart Meetup #2: Scaling Search @Lendingkart
Ledingkart Meetup #2: Scaling Search @LendingkartMukesh Singh
 
Advanced memory allocation
Advanced memory allocationAdvanced memory allocation
Advanced memory allocationJoris Bonnefoy
 
Distributed Erlang Systems In Operation
Distributed Erlang Systems In OperationDistributed Erlang Systems In Operation
Distributed Erlang Systems In OperationAndy Gross
 
Optimizing Hive Queries
Optimizing Hive QueriesOptimizing Hive Queries
Optimizing Hive QueriesOwen O'Malley
 
Managing data and operation distribution in MongoDB
Managing data and operation distribution in MongoDBManaging data and operation distribution in MongoDB
Managing data and operation distribution in MongoDBAntonios Giannopoulos
 
Utopia Kingdoms scaling case. From 4 users to 50.000+
Utopia Kingdoms scaling case. From 4 users to 50.000+Utopia Kingdoms scaling case. From 4 users to 50.000+
Utopia Kingdoms scaling case. From 4 users to 50.000+Python Ireland
 
Utopia Kindgoms scaling case: From 4 to 50K users
Utopia Kindgoms scaling case: From 4 to 50K usersUtopia Kindgoms scaling case: From 4 to 50K users
Utopia Kindgoms scaling case: From 4 to 50K usersJaime Buelta
 
PostgreSQL 9.0 & The Future
PostgreSQL 9.0 & The FuturePostgreSQL 9.0 & The Future
PostgreSQL 9.0 & The FutureAaron Thul
 
Webinar: Understanding Storage for Performance and Data Safety
Webinar: Understanding Storage for Performance and Data SafetyWebinar: Understanding Storage for Performance and Data Safety
Webinar: Understanding Storage for Performance and Data SafetyMongoDB
 
Distributed Model Validation with Epsilon
Distributed Model Validation with EpsilonDistributed Model Validation with Epsilon
Distributed Model Validation with EpsilonSina Madani
 
Approximate "Now" is Better Than Accurate "Later"
Approximate "Now" is Better Than Accurate "Later"Approximate "Now" is Better Than Accurate "Later"
Approximate "Now" is Better Than Accurate "Later"NUS-ISS
 
Buytaert kris my_sql-pacemaker
Buytaert kris my_sql-pacemakerBuytaert kris my_sql-pacemaker
Buytaert kris my_sql-pacemakerkuchinskaya
 

Similar to The Essential PostgreSQL.conf (20)

Spotify: Horizontal Scalability for Great Success
Spotify: Horizontal Scalability for Great SuccessSpotify: Horizontal Scalability for Great Success
Spotify: Horizontal Scalability for Great Success
 
Drizzle 7.0, Future of Virtualizing
Drizzle 7.0, Future of VirtualizingDrizzle 7.0, Future of Virtualizing
Drizzle 7.0, Future of Virtualizing
 
7. Key-Value Databases: In Depth
7. Key-Value Databases: In Depth7. Key-Value Databases: In Depth
7. Key-Value Databases: In Depth
 
PostgreSQL worst practices, version PGConf.US 2017 by Ilya Kosmodemiansky
PostgreSQL worst practices, version PGConf.US 2017 by Ilya KosmodemianskyPostgreSQL worst practices, version PGConf.US 2017 by Ilya Kosmodemiansky
PostgreSQL worst practices, version PGConf.US 2017 by Ilya Kosmodemiansky
 
Optimizing Hive Queries
Optimizing Hive QueriesOptimizing Hive Queries
Optimizing Hive Queries
 
Implementing the Databese Server session 02
Implementing the Databese Server session 02Implementing the Databese Server session 02
Implementing the Databese Server session 02
 
Ledingkart Meetup #2: Scaling Search @Lendingkart
Ledingkart Meetup #2: Scaling Search @LendingkartLedingkart Meetup #2: Scaling Search @Lendingkart
Ledingkart Meetup #2: Scaling Search @Lendingkart
 
Advanced memory allocation
Advanced memory allocationAdvanced memory allocation
Advanced memory allocation
 
Distributed Erlang Systems In Operation
Distributed Erlang Systems In OperationDistributed Erlang Systems In Operation
Distributed Erlang Systems In Operation
 
Optimizing Hive Queries
Optimizing Hive QueriesOptimizing Hive Queries
Optimizing Hive Queries
 
02-hashing.pdf
02-hashing.pdf02-hashing.pdf
02-hashing.pdf
 
Managing data and operation distribution in MongoDB
Managing data and operation distribution in MongoDBManaging data and operation distribution in MongoDB
Managing data and operation distribution in MongoDB
 
DB
DBDB
DB
 
Utopia Kingdoms scaling case. From 4 users to 50.000+
Utopia Kingdoms scaling case. From 4 users to 50.000+Utopia Kingdoms scaling case. From 4 users to 50.000+
Utopia Kingdoms scaling case. From 4 users to 50.000+
 
Utopia Kindgoms scaling case: From 4 to 50K users
Utopia Kindgoms scaling case: From 4 to 50K usersUtopia Kindgoms scaling case: From 4 to 50K users
Utopia Kindgoms scaling case: From 4 to 50K users
 
PostgreSQL 9.0 & The Future
PostgreSQL 9.0 & The FuturePostgreSQL 9.0 & The Future
PostgreSQL 9.0 & The Future
 
Webinar: Understanding Storage for Performance and Data Safety
Webinar: Understanding Storage for Performance and Data SafetyWebinar: Understanding Storage for Performance and Data Safety
Webinar: Understanding Storage for Performance and Data Safety
 
Distributed Model Validation with Epsilon
Distributed Model Validation with EpsilonDistributed Model Validation with Epsilon
Distributed Model Validation with Epsilon
 
Approximate "Now" is Better Than Accurate "Later"
Approximate "Now" is Better Than Accurate "Later"Approximate "Now" is Better Than Accurate "Later"
Approximate "Now" is Better Than Accurate "Later"
 
Buytaert kris my_sql-pacemaker
Buytaert kris my_sql-pacemakerBuytaert kris my_sql-pacemaker
Buytaert kris my_sql-pacemaker
 

More from Robert Treat

Advanced Int->Bigint Conversions
Advanced Int->Bigint ConversionsAdvanced Int->Bigint Conversions
Advanced Int->Bigint ConversionsRobert Treat
 
Explaining Explain
Explaining ExplainExplaining Explain
Explaining ExplainRobert Treat
 
the-lost-art-of-plpgsql
the-lost-art-of-plpgsqlthe-lost-art-of-plpgsql
the-lost-art-of-plpgsqlRobert Treat
 
Managing Chaos In Production: Testing vs Monitoring
Managing Chaos In Production: Testing vs MonitoringManaging Chaos In Production: Testing vs Monitoring
Managing Chaos In Production: Testing vs MonitoringRobert Treat
 
What Ops Can Learn From Design
What Ops Can Learn From DesignWhat Ops Can Learn From Design
What Ops Can Learn From DesignRobert Treat
 
Less Alarming Alerts!
Less Alarming Alerts!Less Alarming Alerts!
Less Alarming Alerts!Robert Treat
 
Past, Present, and Pachyderm - All Things Open - 2013
Past, Present, and Pachyderm - All Things Open - 2013Past, Present, and Pachyderm - All Things Open - 2013
Past, Present, and Pachyderm - All Things Open - 2013Robert Treat
 
Big Bad "Upgraded" Postgres
Big Bad "Upgraded" PostgresBig Bad "Upgraded" Postgres
Big Bad "Upgraded" PostgresRobert Treat
 
Scaling with Postgres (Highload++ 2010)
Scaling with Postgres (Highload++ 2010)Scaling with Postgres (Highload++ 2010)
Scaling with Postgres (Highload++ 2010)Robert Treat
 
Intro to Postgres 9 Tutorial
Intro to Postgres 9 TutorialIntro to Postgres 9 Tutorial
Intro to Postgres 9 TutorialRobert Treat
 
Database Scalability Patterns
Database Scalability PatternsDatabase Scalability Patterns
Database Scalability PatternsRobert Treat
 
A Guide To PostgreSQL 9.0
A Guide To PostgreSQL 9.0A Guide To PostgreSQL 9.0
A Guide To PostgreSQL 9.0Robert Treat
 
Scaling With Postgres
Scaling With PostgresScaling With Postgres
Scaling With PostgresRobert Treat
 
Intro to Postgres 8.4 Tutorial
Intro to Postgres 8.4 TutorialIntro to Postgres 8.4 Tutorial
Intro to Postgres 8.4 TutorialRobert Treat
 
Intro to pl/PHP Oscon2007
Intro to pl/PHP Oscon2007Intro to pl/PHP Oscon2007
Intro to pl/PHP Oscon2007Robert Treat
 
PostgreSQL Partitioning, PGCon 2007
PostgreSQL Partitioning, PGCon 2007PostgreSQL Partitioning, PGCon 2007
PostgreSQL Partitioning, PGCon 2007Robert Treat
 
Pro PostgreSQL, OSCon 2008
Pro PostgreSQL, OSCon 2008Pro PostgreSQL, OSCon 2008
Pro PostgreSQL, OSCon 2008Robert Treat
 
Database Anti Patterns
Database Anti PatternsDatabase Anti Patterns
Database Anti PatternsRobert Treat
 

More from Robert Treat (20)

Advanced Int->Bigint Conversions
Advanced Int->Bigint ConversionsAdvanced Int->Bigint Conversions
Advanced Int->Bigint Conversions
 
Explaining Explain
Explaining ExplainExplaining Explain
Explaining Explain
 
the-lost-art-of-plpgsql
the-lost-art-of-plpgsqlthe-lost-art-of-plpgsql
the-lost-art-of-plpgsql
 
Managing Chaos In Production: Testing vs Monitoring
Managing Chaos In Production: Testing vs MonitoringManaging Chaos In Production: Testing vs Monitoring
Managing Chaos In Production: Testing vs Monitoring
 
What Ops Can Learn From Design
What Ops Can Learn From DesignWhat Ops Can Learn From Design
What Ops Can Learn From Design
 
Less Alarming Alerts!
Less Alarming Alerts!Less Alarming Alerts!
Less Alarming Alerts!
 
Past, Present, and Pachyderm - All Things Open - 2013
Past, Present, and Pachyderm - All Things Open - 2013Past, Present, and Pachyderm - All Things Open - 2013
Past, Present, and Pachyderm - All Things Open - 2013
 
Big Bad "Upgraded" Postgres
Big Bad "Upgraded" PostgresBig Bad "Upgraded" Postgres
Big Bad "Upgraded" Postgres
 
Scaling with Postgres (Highload++ 2010)
Scaling with Postgres (Highload++ 2010)Scaling with Postgres (Highload++ 2010)
Scaling with Postgres (Highload++ 2010)
 
Intro to Postgres 9 Tutorial
Intro to Postgres 9 TutorialIntro to Postgres 9 Tutorial
Intro to Postgres 9 Tutorial
 
Check Please!
Check Please!Check Please!
Check Please!
 
Database Scalability Patterns
Database Scalability PatternsDatabase Scalability Patterns
Database Scalability Patterns
 
A Guide To PostgreSQL 9.0
A Guide To PostgreSQL 9.0A Guide To PostgreSQL 9.0
A Guide To PostgreSQL 9.0
 
Scaling With Postgres
Scaling With PostgresScaling With Postgres
Scaling With Postgres
 
Intro to Postgres 8.4 Tutorial
Intro to Postgres 8.4 TutorialIntro to Postgres 8.4 Tutorial
Intro to Postgres 8.4 Tutorial
 
Intro to pl/PHP Oscon2007
Intro to pl/PHP Oscon2007Intro to pl/PHP Oscon2007
Intro to pl/PHP Oscon2007
 
PostgreSQL Partitioning, PGCon 2007
PostgreSQL Partitioning, PGCon 2007PostgreSQL Partitioning, PGCon 2007
PostgreSQL Partitioning, PGCon 2007
 
Pro PostgreSQL, OSCon 2008
Pro PostgreSQL, OSCon 2008Pro PostgreSQL, OSCon 2008
Pro PostgreSQL, OSCon 2008
 
Database Anti Patterns
Database Anti PatternsDatabase Anti Patterns
Database Anti Patterns
 
Pro PostgreSQL
Pro PostgreSQLPro PostgreSQL
Pro PostgreSQL
 

Recently uploaded

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
 
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 productivityPrincipled Technologies
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
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 RobisonAnna Loughnan Colquhoun
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
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.pdfEnterprise Knowledge
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
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 interpreternaman860154
 

Recently uploaded (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 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
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
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
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
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
 

The Essential PostgreSQL.conf

  • 1. The Essential PostgreSQL.conf 9 Robert Treat, JDCon East 2011 Thursday, March 31, 2011
  • 2. Introduction • Robert
Treat • OmniTI • Database
Management
and
Consulting • Large
and/or
High
Traffic
Architectures • We’re
Hiring! • Postgres • Web,

Advocacy,
Conferences,
PhpPgAdmin • Major
Contributor • xzilla.net • @robtreat2 Thursday, March 31, 2011
  • 3. Introduction • Robert
Treat • OmniTI • Database
Management
and
Consulting • Large
and/or
High
Traffic
Architectures • We’re
Hiring! • Postgres • Web,

Advocacy,
Conferences,
PhpPgAdmin • Major
Contributor • xzilla.net • @robtreat2 Thursday, March 31, 2011
  • 4. The Grand Scheme • Understanding the postgresql.conf • Essential postgresql.conf parameters Thursday, March 31, 2011
  • 5. The Grand Scheme • Understanding the postgresql.conf • Essential postgresql.conf parameters Thursday, March 31, 2011
  • 6. Understanding the postgresql.conf • Types of Settings • When Settings Take Effect • PostgreSQL.conf “Gotchas” • Viewing Your Current Settings Thursday, March 31, 2011
  • 8. Types of Settings • Boolean: true, false, on, off Thursday, March 31, 2011
  • 9. Types of Settings • Boolean: true, false, on, off • Integer: whole numbers (2112) Thursday, March 31, 2011
  • 10. Types of Settings • Boolean: true, false, on, off • Integer: whole numbers (2112) • Float: decimal values (21.12) Thursday, March 31, 2011
  • 11. Types of Settings • Boolean: true, false, on, off • Integer: whole numbers (2112) • Float: decimal values (21.12) • Memory/Disk Units: 128MB, 2112GB Thursday, March 31, 2011
  • 12. Types of Settings • Boolean: true, false, on, off • Integer: whole numbers (2112) • Float: decimal values (21.12) • Memory/Disk Units: 128MB, 2112GB • Avoid using integers to size memory parameters Thursday, March 31, 2011
  • 13. Types of Settings • Boolean: true, false, on, off • Integer: whole numbers (2112) • Float: decimal values (21.12) • Memory/Disk Units: 128MB, 2112GB • Avoid using integers to size memory parameters • Time: d,m,s (30s) Thursday, March 31, 2011
  • 14. Types of Settings • Boolean: true, false, on, off • Integer: whole numbers (2112) • Float: decimal values (21.12) • Memory/Disk Units: 128MB, 2112GB • Avoid using integers to size memory parameters • Time: d,m,s (30s) • Strings: single quotes (‘pg_log’) Thursday, March 31, 2011
  • 15. Types of Settings • Boolean: true, false, on, off • Integer: whole numbers (2112) • Float: decimal values (21.12) • Memory/Disk Units: 128MB, 2112GB • Avoid using integers to size memory parameters • Time: d,m,s (30s) • Strings: single quotes (‘pg_log’) • Enum: single quotes (‘WARNING’ or ‘ERROR’) Thursday, March 31, 2011
  • 16. Types of Settings • Boolean: true, false, on, off • Integer: whole numbers (2112) • Float: decimal values (21.12) • Memory/Disk Units: 128MB, 2112GB • Avoid using integers to size memory parameters • Time: d,m,s (30s) • Strings: single quotes (‘pg_log’) • Enum: single quotes (‘WARNING’ or ‘ERROR’) • Limited set of acceptable strings Thursday, March 31, 2011
  • 17. Types of Settings • Boolean: true, false, on, off • Integer: whole numbers (2112) • Float: decimal values (21.12) • Memory/Disk Units: 128MB, 2112GB • Avoid using integers to size memory parameters • Time: d,m,s (30s) • Strings: single quotes (‘pg_log’) • Enum: single quotes (‘WARNING’ or ‘ERROR’) • Limited set of acceptable strings • Lists: comma seperated (‘“$user”,public,tsearch2’) Thursday, March 31, 2011
  • 18. When Settings Take Effect • Internal: set at compile time • Postmaster: requires database restart • Backend: must be set before session start • Sighup: change by reloading conf file • pg_reload_conf(), pg_ctl reload, kill -HUP • Superuser: set at runtime by superuser • User: set at runtime, affects only a single session See
pg_settings.context
to
determine
setting
type Thursday, March 31, 2011
  • 19. When Settings Take Effect • Internal: set at compile time • Postmaster: requires database restart • Backend: must be set before session start • Sighup: change by reloading conf file • pg_reload_conf(), pg_ctl reload, kill -HUP • Superuser: set at runtime by superuser • User: set at runtime, affects only a single session See
pg_settings.context
to
determine
setting
type Thursday, March 31, 2011
  • 20. postgresql.conf Gotchas! • Where is my postgresql.conf ? • $PGDATA/postgresql.conf • watch out for symbolic links • some distros put it in other places (/etc) • SHOW data_directory; • SHOW config_file; Thursday, March 31, 2011
  • 21. postgresql.conf Gotchas! • Lines with # • This line is a comment, and has no effect • On a fresh install, uses defaults • Commenting a line is the same as deleting a line, it will restore the “default” for that instance Thursday, March 31, 2011
  • 22. Viewing Your Current Settings • Look in postgresql.conf • Works if you follow best practices • Not definitive! Thursday, March 31, 2011
  • 23. Viewing Your Current Settings • Look in postgresql.conf • Works if you follow best practices • Not definitive! • SHOW ALL, SHOW <setting>, current_setting(setting) • Shows the current value • Watch out for session specific changes Thursday, March 31, 2011
  • 24. Viewing Your Current Settings • Look in postgresql.conf • Works if you follow best practices • Not definitive! • SHOW ALL, SHOW <setting>, current_setting(setting) • Shows the current value • Watch out for session specific changes • SELECT * FROM pg_settings • Shows the current value • “source” column Thursday, March 31, 2011
  • 25. Viewing Your Current Settings pagila=# select current_setting(name), * from pg_settings where name = 'shared_buffers'; -[ RECORD 1 ]------+---------------------------------------------- current_setting | 1600kB name | shared_buffers setting | 200 unit | 8kB category | Resource Usage / Memory short_desc | Sets the number of shared memory buffers used by the server. extra_desc | context | postmaster vartype | integer source | configuration file min_val | 16 max_val | 1073741823 enumvals | boot_val | 1024 reset_val | 200 sourcefile | /opt/local/var/db/postgresql91/data/postgresql.conf sourceline | 109 Thursday, March 31, 2011
  • 26. The Essential Parameters • Logging • Getting Connected • Sizing Memory • Checkpoint Management • Vacuum Managment • WAL management Thursday, March 31, 2011
  • 27. Logging • log_destination, log_directory, log_filename • find out where you are logging • might be good to log to a different disk than your data Thursday, March 31, 2011
  • 28. Logging • log_destination, log_directory, log_filename • find out where you are logging • might be good to log to a different disk than your data • log_line_prefix • generic recommendation: ‘%t: %r: %u@%d: [%p]: ‘ • timestamp, connecting host, username, database, pid Thursday, March 31, 2011
  • 29. Get Connected • listen_addresses • requires restart! • default is localhost only • use * to enable tcp/ip Thursday, March 31, 2011
  • 30. Get Connected • listen_addresses • requires restart! • default is localhost only • use * to enable tcp/ip • max_connections • requires restart! • 100 default (apache children default is higher) • affects other settings (work_mem) • for 1000+ connections, use connection pooler Thursday, March 31, 2011
  • 31. Sizing Memory • shared_buffers • requires restart! • most important setting for good performance • allocation of memory for Postgres caching • ~20% of Total Available RAM (up to 2GB) • 32GB RAM, 1920 MB is probably ok • 256GB RAM, 50 GB is probably not optimal • Windows users probably want less • may require adjusting kernel params (shmmax) • http://www.postgresql.org/docs/current/interactive/kernel-resources.html Thursday, March 31, 2011
  • 32. Sizing Memory • effective_cache_size • most important setting for good performance • based on memory available for filesystem cache • SET = TRAM - (DRAM - PGRAM) • TRAM = Total RAM • DRAM = RAM needed by OS and other apps • PGRAM = RAM needed for Postgres (shared_buffers, etc...) • Guide for available memory, not an allocation Thursday, March 31, 2011
  • 33. Sizing Memory • work_mem • used by queries for sorting • higher values for more complex queries • limit is per sort • 5 sorts in 1 query = 5*work_mem • maintenance_work_mem • used by vacuum, indexing, and similar operations • semi-allocation of memory when needed • don’t be scared to make this big (1GB) Thursday, March 31, 2011
  • 34. Checkpoint Management • checkpoint_segments • controls the amount of data required per checkpoint • default 3, recommended minimum of 10 • set higher for heavy write activity • 30 - 300 is not uncommon • increases space needed in pg_xlog • increases recovery time after crash • checkpoint_completion_target • with checkpoint_segments >= 10, set this to .9 • http://www.westnet.com/~gsmith/content/postgresql/chkp-bgw-83.htm Thursday, March 31, 2011
  • 35. Vacuum Management • autovacuum • max_fsm_pages • max_fsm_relations • default_statistics_target • autovacuum_freeze_max_age • set to 1,000,000,000 to reduce vacuums for non-activity • requires restart Thursday, March 31, 2011
  • 36. WAL Management / Replication • WAL for Performance • wal_buffers • requires restart! • needed for write heavy loads • 16MB, “set it and forget it!” • synchronous_commit • can increase tps by a large margin • allows data loss without corruption • BAD: fsync = off • GOOD: synchronous_commit = off • can be set per database, user, or transaction Thursday, March 31, 2011
  • 37. WAL Management / Replication • WAL for Replication • wal_level • requires restart! • “hot_standby” needed for... hot standbys • max_wal_senders • requires restart! • controls the number of connections for streaming replication Thursday, March 31, 2011
  • 38. The End Thanks! Additional Resources http://www.postgresql.org/docs/current/interactive/runtime-config.html http://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server Slides http://www.xzilla.net/writings.html Thursday, March 31, 2011
  • 39. No Really, The End Thursday, March 31, 2011