· 8 years ago · May 09, 2018, 09:08 AM
1# -----------------------------
2# PostgreSQL configuration file
3# -----------------------------
4#
5# This file consists of lines of the form:
6#
7# name = value
8#
9# (The "=" is optional.) Whitespace may be used. Comments are introduced with
10# "#" anywhere on a line. The complete list of parameter names and allowed
11# values can be found in the PostgreSQL documentation.
12#
13# The commented-out settings shown in this file represent the default values.
14# Re-commenting a setting is NOT sufficient to revert it to the default value;
15# you need to reload the server.
16#
17# This file is read on server startup and when the server receives a SIGHUP
18# signal. If you edit the file on a running system, you have to SIGHUP the
19# server for the changes to take effect, run "pg_ctl reload", or execute
20# "SELECT pg_reload_conf()". Some parameters, which are marked below,
21# require a server shutdown and restart to take effect.
22#
23# Any parameter can also be given as a command-line option to the server, e.g.,
24# "postgres -c log_connections=on". Some parameters can be changed at run time
25# with the "SET" SQL command.
26#
27# Memory units: kB = kilobytes Time units: ms = milliseconds
28# MB = megabytes s = seconds
29# GB = gigabytes min = minutes
30# TB = terabytes h = hours
31# d = days
32
33
34#------------------------------------------------------------------------------
35# FILE LOCATIONS
36#------------------------------------------------------------------------------
37
38# The default values of these variables are driven from the -D command-line
39# option or PGDATA environment variable, represented here as ConfigDir.
40
41data_directory = '/var/lib/postgresql/10/main' # use data in another directory
42 # (change requires restart)
43hba_file = '/etc/postgresql/10/main/pg_hba.conf' # host-based authentication file
44 # (change requires restart)
45ident_file = '/etc/postgresql/10/main/pg_ident.conf' # ident configuration file
46 # (change requires restart)
47
48# If external_pid_file is not explicitly set, no extra PID file is written.
49external_pid_file = '/var/run/postgresql/10-main.pid' # write an extra PID file
50 # (change requires restart)
51
52
53#------------------------------------------------------------------------------
54# CONNECTIONS AND AUTHENTICATION
55#------------------------------------------------------------------------------
56
57# - Connection Settings -
58
59listen_addresses = '*' # what IP address(es) to listen on;
60 # comma-separated list of addresses;
61 # defaults to 'localhost'; use '*' for all
62 # (change requires restart)
63port = 5432 # (change requires restart)
64max_connections = 500 # (change requires restart)
65#superuser_reserved_connections = 3 # (change requires restart)
66unix_socket_directories = '/var/run/postgresql' # comma-separated list of directories
67 # (change requires restart)
68#unix_socket_group = '' # (change requires restart)
69#unix_socket_permissions = 0777 # begin with 0 to use octal notation
70 # (change requires restart)
71#bonjour = off # advertise server via Bonjour
72 # (change requires restart)
73#bonjour_name = '' # defaults to the computer name
74 # (change requires restart)
75
76# - Security and Authentication -
77
78#authentication_timeout = 1min # 1s-600s
79ssl = on
80#ssl_ciphers = 'HIGH:MEDIUM:+3DES:!aNULL' # allowed SSL ciphers
81#ssl_prefer_server_ciphers = on
82#ssl_ecdh_curve = 'prime256v1'
83#ssl_dh_params_file = ''
84ssl_cert_file = '/etc/ssl/certs/ssl-cert-snakeoil.pem'
85ssl_key_file = '/etc/ssl/private/ssl-cert-snakeoil.key'
86#ssl_ca_file = ''
87#ssl_crl_file = ''
88#password_encryption = md5 # md5 or scram-sha-256
89#db_user_namespace = off
90#row_security = on
91
92# GSSAPI using Kerberos
93#krb_server_keyfile = ''
94#krb_caseins_users = off
95
96# - TCP Keepalives -
97# see "man 7 tcp" for details
98
99#tcp_keepalives_idle = 0 # TCP_KEEPIDLE, in seconds;
100 # 0 selects the system default
101#tcp_keepalives_interval = 0 # TCP_KEEPINTVL, in seconds;
102 # 0 selects the system default
103#tcp_keepalives_count = 0 # TCP_KEEPCNT;
104 # 0 selects the system default
105
106
107#------------------------------------------------------------------------------
108# RESOURCE USAGE (except WAL)
109#------------------------------------------------------------------------------
110
111# - Memory -
112
113shared_buffers = 4GB # min 128kB
114 # (change requires restart)
115#huge_pages = try # on, off, or try
116 # (change requires restart)
117#temp_buffers = 8MB # min 800kB
118#max_prepared_transactions = 0 # zero disables the feature
119 # (change requires restart)
120# Caution: it is not advisable to set max_prepared_transactions nonzero unless
121# you actively intend to use prepared transactions.
122work_mem = 2796kB # min 64kB
123maintenance_work_mem = 1GB # min 1MB
124#replacement_sort_tuples = 150000 # limits use of replacement selection sort
125#autovacuum_work_mem = -1 # min 1MB, or -1 to use maintenance_work_mem
126#max_stack_depth = 2MB # min 100kB
127dynamic_shared_memory_type = posix # the default is the first option
128 # supported by the operating system:
129 # posix
130 # sysv
131 # windows
132 # mmap
133 # use none to disable dynamic shared memory
134 # (change requires restart)
135
136# - Disk -
137
138#temp_file_limit = -1 # limits per-process temp file space
139 # in kB, or -1 for no limit
140
141# - Kernel Resource Usage -
142
143#max_files_per_process = 1000 # min 25
144 # (change requires restart)
145shared_preload_libraries = 'pg_cron,pg_partman_bgw,timescaledb' # (change requires restart)
146cron.database_name = 'warehouse'
147
148# - Cost-Based Vacuum Delay -
149
150#vacuum_cost_delay = 0 # 0-100 milliseconds
151#vacuum_cost_page_hit = 1 # 0-10000 credits
152#vacuum_cost_page_miss = 10 # 0-10000 credits
153#vacuum_cost_page_dirty = 20 # 0-10000 credits
154#vacuum_cost_limit = 200 # 1-10000 credits
155
156# - Background Writer -
157
158#bgwriter_delay = 200ms # 10-10000ms between rounds
159#bgwriter_lru_maxpages = 100 # 0-1000 max buffers written/round
160#bgwriter_lru_multiplier = 2.0 # 0-10.0 multiplier on buffers scanned/round
161#bgwriter_flush_after = 512kB # measured in pages, 0 disables
162
163# - Asynchronous Behavior -
164
165effective_io_concurrency = 200 # 1-1000; 0 disables prefetching
166max_worker_processes = 6 # (change requires restart)
167max_parallel_workers_per_gather = 3 # taken from max_parallel_workers
168max_parallel_workers = 6 # maximum number of max_worker_processes that
169 # can be used in parallel queries
170#old_snapshot_threshold = -1 # 1min-60d; -1 disables; 0 is immediate
171 # (change requires restart)
172#backend_flush_after = 0 # measured in pages, 0 disables
173
174
175#------------------------------------------------------------------------------
176# WRITE AHEAD LOG
177#------------------------------------------------------------------------------
178
179# - Settings -
180
181wal_level = hot_standby # minimal, replica, or logical
182 # (change requires restart)
183#fsync = on # flush data to disk for crash safety
184 # (turning this off can cause
185 # unrecoverable data corruption)
186synchronous_commit = off # synchronization level;
187 # off, local, remote_write, remote_apply, or on
188#wal_sync_method = fsync # the default is the first option
189 # supported by the operating system:
190 # open_datasync
191 # fdatasync (default on Linux)
192 # fsync
193 # fsync_writethrough
194 # open_sync
195#full_page_writes = on # recover from partial page writes
196#wal_compression = off # enable compression of full-page writes
197#wal_log_hints = off # also do full page writes of non-critical updates
198 # (change requires restart)
199wal_buffers = 16MB # min 32kB, -1 sets based on shared_buffers
200 # (change requires restart)
201#wal_writer_delay = 200ms # 1-10000 milliseconds
202#wal_writer_flush_after = 1MB # measured in pages, 0 disables
203
204#commit_delay = 0 # range 0-100000, in microseconds
205#commit_siblings = 5 # range 1-1000
206
207# - Checkpoints -
208
209#checkpoint_timeout = 5min # range 30s-1d
210max_wal_size = 4GB
211min_wal_size = 2GB
212checkpoint_completion_target = 0.9 # checkpoint target duration, 0.0 - 1.0
213#checkpoint_flush_after = 256kB # measured in pages, 0 disables
214#checkpoint_warning = 30s # 0 disables
215
216# - Archiving -
217
218archive_mode = on # enables archiving; off, on, or always
219 # (change requires restart)
220archive_command = 'test ! -f /mnt/storage/disk1/pg_wal/%f && cp %p /mnt/storage/disk1/pg_wal/%f'
221#archive_command = '' # command to use to archive a logfile segment
222 # placeholders: %p = path of file to archive
223 # %f = file name only
224 # e.g. 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f'
225#archive_timeout = 0 # force a logfile segment switch after this
226 # number of seconds; 0 disables
227
228
229#------------------------------------------------------------------------------
230# REPLICATION
231#------------------------------------------------------------------------------
232
233# - Sending Server(s) -
234
235# Set these on the master and on any standby that will send replication data.
236
237max_wal_senders = 10 # max number of walsender processes
238 # (change requires restart)
239wal_keep_segments = 100 # in logfile segments, 16MB each; 0 disables
240#wal_sender_timeout = 60s # in milliseconds; 0 disables
241
242max_replication_slots = 10 # max number of replication slots
243 # (change requires restart)
244#track_commit_timestamp = off # collect timestamp of transaction commit
245 # (change requires restart)
246
247# - Master Server -
248
249# These settings are ignored on a standby server.
250
251#synchronous_standby_names = '' # standby servers that provide sync rep
252 # method to choose sync standbys, number of sync standbys,
253 # and comma-separated list of application_name
254 # from standby(s); '*' = all
255#vacuum_defer_cleanup_age = 0 # number of xacts by which cleanup is delayed
256
257# - Standby Servers -
258
259# These settings are ignored on a master server.
260
261hot_standby = on # "off" disallows queries during recovery
262 # (change requires restart)
263#max_standby_archive_delay = 30s # max delay before canceling queries
264 # when reading WAL from archive;
265 # -1 allows indefinite delay
266#max_standby_streaming_delay = 30s # max delay before canceling queries
267 # when reading streaming WAL;
268 # -1 allows indefinite delay
269#wal_receiver_status_interval = 10s # send replies at least this often
270 # 0 disables
271hot_standby_feedback = on # send info from standby to prevent
272 # query conflicts
273#wal_receiver_timeout = 60s # time that receiver waits for
274 # communication from master
275 # in milliseconds; 0 disables
276#wal_retrieve_retry_interval = 5s # time to wait before retrying to
277 # retrieve WAL after a failed attempt
278
279# - Subscribers -
280
281# These settings are ignored on a publisher.
282
283#max_logical_replication_workers = 4 # taken from max_worker_processes
284 # (change requires restart)
285#max_sync_workers_per_subscription = 2 # taken from max_logical_replication_workers
286
287
288#------------------------------------------------------------------------------
289# QUERY TUNING
290#------------------------------------------------------------------------------
291
292# - Planner Method Configuration -
293
294#enable_bitmapscan = on
295#enable_hashagg = on
296#enable_hashjoin = on
297#enable_indexscan = on
298#enable_indexonlyscan = on
299#enable_material = on
300#enable_mergejoin = on
301#enable_nestloop = on
302#enable_seqscan = on
303#enable_sort = on
304#enable_tidscan = on
305
306# - Planner Cost Constants -
307
308seq_page_cost = 1.1 # measured on an arbitrary scale
309random_page_cost = 1.1 # same scale as above
310#cpu_tuple_cost = 0.01 # same scale as above
311#cpu_index_tuple_cost = 0.005 # same scale as above
312#cpu_operator_cost = 0.0025 # same scale as above
313#parallel_tuple_cost = 0.1 # same scale as above
314#parallel_setup_cost = 1000.0 # same scale as above
315#min_parallel_table_scan_size = 8MB
316#min_parallel_index_scan_size = 512kB
317effective_cache_size = 12GB
318
319# - Genetic Query Optimizer -
320
321#geqo = on
322#geqo_threshold = 12
323#geqo_effort = 5 # range 1-10
324#geqo_pool_size = 0 # selects default based on effort
325#geqo_generations = 0 # selects default based on effort
326#geqo_selection_bias = 2.0 # range 1.5-2.0
327#geqo_seed = 0.0 # range 0.0-1.0
328
329# - Other Planner Options -
330
331default_statistics_target = 100 # range 1-10000
332#constraint_exclusion = partition # on, off, or partition
333#cursor_tuple_fraction = 0.1 # range 0.0-1.0
334#from_collapse_limit = 8
335#join_collapse_limit = 8 # 1 disables collapsing of explicit
336 # JOIN clauses
337#force_parallel_mode = off
338
339
340#------------------------------------------------------------------------------
341# ERROR REPORTING AND LOGGING
342#------------------------------------------------------------------------------
343
344# - Where to Log -
345
346log_destination = 'syslog' # Valid values are combinations of
347 # stderr, csvlog, syslog, and eventlog,
348 # depending on platform. csvlog
349 # requires logging_collector to be on.
350
351# This is used when logging to stderr:
352#logging_collector = off # Enable capturing of stderr and csvlog
353 # into log files. Required to be on for
354 # csvlogs.
355 # (change requires restart)
356
357# These are only used if logging_collector is on:
358#log_directory = 'log' # directory where log files are written,
359 # can be absolute or relative to PGDATA
360#log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # log file name pattern,
361 # can include strftime() escapes
362#log_file_mode = 0600 # creation mode for log files,
363 # begin with 0 to use octal notation
364#log_truncate_on_rotation = off # If on, an existing log file with the
365 # same name as the new log file will be
366 # truncated rather than appended to.
367 # But such truncation only occurs on
368 # time-driven rotation, not on restarts
369 # or size-driven rotation. Default is
370 # off, meaning append to existing files
371 # in all cases.
372#log_rotation_age = 1d # Automatic rotation of logfiles will
373 # happen after that time. 0 disables.
374#log_rotation_size = 10MB # Automatic rotation of logfiles will
375 # happen after that much log output.
376 # 0 disables.
377
378# These are relevant when logging to syslog:
379#syslog_facility = 'LOCAL0'
380#syslog_ident = 'postgres'
381#syslog_sequence_numbers = on
382#syslog_split_messages = on
383
384# This is only relevant when logging to eventlog (win32):
385# (change requires restart)
386#event_source = 'PostgreSQL'
387
388# - When to Log -
389
390#client_min_messages = notice # values in order of decreasing detail:
391 # debug5
392 # debug4
393 # debug3
394 # debug2
395 # debug1
396 # log
397 # notice
398 # warning
399 # error
400
401#log_min_messages = warning # values in order of decreasing detail:
402 # debug5
403 # debug4
404 # debug3
405 # debug2
406 # debug1
407 # info
408 # notice
409 # warning
410 # error
411 # log
412 # fatal
413 # panic
414
415#log_min_error_statement = error # values in order of decreasing detail:
416 # debug5
417 # debug4
418 # debug3
419 # debug2
420 # debug1
421 # info
422 # notice
423 # warning
424 # error
425 # log
426 # fatal
427 # panic (effectively off)
428
429#log_min_duration_statement = -1 # -1 is disabled, 0 logs all statements
430 # and their durations, > 0 logs only
431 # statements running at least this number
432 # of milliseconds
433
434
435# - What to Log -
436
437#debug_print_parse = off
438#debug_print_rewritten = off
439#debug_print_plan = off
440#debug_pretty_print = on
441#log_checkpoints = off
442#log_connections = off
443#log_disconnections = off
444#log_duration = off
445#log_error_verbosity = default # terse, default, or verbose messages
446#log_hostname = off
447log_line_prefix = '%m [%p] %q%u@%d ' # special values:
448 # %a = application name
449 # %u = user name
450 # %d = database name
451 # %r = remote host and port
452 # %h = remote host
453 # %p = process ID
454 # %t = timestamp without milliseconds
455 # %m = timestamp with milliseconds
456 # %n = timestamp with milliseconds (as a Unix epoch)
457 # %i = command tag
458 # %e = SQL state
459 # %c = session ID
460 # %l = session line number
461 # %s = session start timestamp
462 # %v = virtual transaction ID
463 # %x = transaction ID (0 if none)
464 # %q = stop here in non-session
465 # processes
466 # %% = '%'
467 # e.g. '<%u%%%d> '
468#log_lock_waits = off # log lock waits >= deadlock_timeout
469#log_statement = 'none' # none, ddl, mod, all
470#log_replication_commands = off
471#log_temp_files = -1 # log temporary files equal or larger
472 # than the specified size in kilobytes;
473 # -1 disables, 0 logs all temp files
474log_timezone = 'UTC'
475
476
477# - Process Title -
478
479cluster_name = '10/main' # added to process titles if nonempty
480 # (change requires restart)
481#update_process_title = on
482
483
484#------------------------------------------------------------------------------
485# RUNTIME STATISTICS
486#------------------------------------------------------------------------------
487
488# - Query/Index Statistics Collector -
489
490#track_activities = on
491#track_counts = on
492#track_io_timing = off
493#track_functions = none # none, pl, all
494#track_activity_query_size = 1024 # (change requires restart)
495stats_temp_directory = '/var/run/postgresql/10-main.pg_stat_tmp'
496
497
498# - Statistics Monitoring -
499
500#log_parser_stats = off
501#log_planner_stats = off
502#log_executor_stats = off
503#log_statement_stats = off
504
505
506#------------------------------------------------------------------------------
507# AUTOVACUUM PARAMETERS
508#------------------------------------------------------------------------------
509
510#autovacuum = on # Enable autovacuum subprocess? 'on'
511 # requires track_counts to also be on.
512#log_autovacuum_min_duration = -1 # -1 disables, 0 logs all actions and
513 # their durations, > 0 logs only
514 # actions running at least this number
515 # of milliseconds.
516#autovacuum_max_workers = 3 # max number of autovacuum subprocesses
517 # (change requires restart)
518#autovacuum_naptime = 1min # time between autovacuum runs
519#autovacuum_vacuum_threshold = 50 # min number of row updates before
520 # vacuum
521#autovacuum_analyze_threshold = 50 # min number of row updates before
522 # analyze
523#autovacuum_vacuum_scale_factor = 0.2 # fraction of table size before vacuum
524#autovacuum_analyze_scale_factor = 0.1 # fraction of table size before analyze
525#autovacuum_freeze_max_age = 200000000 # maximum XID age before forced vacuum
526 # (change requires restart)
527#autovacuum_multixact_freeze_max_age = 400000000 # maximum multixact age
528 # before forced vacuum
529 # (change requires restart)
530#autovacuum_vacuum_cost_delay = 20ms # default vacuum cost delay for
531 # autovacuum, in milliseconds;
532 # -1 means use vacuum_cost_delay
533#autovacuum_vacuum_cost_limit = -1 # default vacuum cost limit for
534 # autovacuum, -1 means use
535 # vacuum_cost_limit
536
537
538#------------------------------------------------------------------------------
539# CLIENT CONNECTION DEFAULTS
540#------------------------------------------------------------------------------
541
542# - Statement Behavior -
543
544#search_path = '"$user", public' # schema names
545#default_tablespace = '' # a tablespace name, '' uses the default
546#temp_tablespaces = '' # a list of tablespace names, '' uses
547 # only default tablespace
548#check_function_bodies = on
549#default_transaction_isolation = 'read committed'
550#default_transaction_read_only = off
551#default_transaction_deferrable = off
552#session_replication_role = 'origin'
553#statement_timeout = 0 # in milliseconds, 0 is disabled
554#lock_timeout = 0 # in milliseconds, 0 is disabled
555#idle_in_transaction_session_timeout = 0 # in milliseconds, 0 is disabled
556#vacuum_freeze_min_age = 50000000
557#vacuum_freeze_table_age = 150000000
558#vacuum_multixact_freeze_min_age = 5000000
559#vacuum_multixact_freeze_table_age = 150000000
560#bytea_output = 'hex' # hex, escape
561#xmlbinary = 'base64'
562#xmloption = 'content'
563#gin_fuzzy_search_limit = 0
564#gin_pending_list_limit = 4MB
565
566# - Locale and Formatting -
567
568datestyle = 'iso, mdy'
569#intervalstyle = 'postgres'
570timezone = 'UTC'
571#timezone_abbreviations = 'Default' # Select the set of available time zone
572 # abbreviations. Currently, there are
573 # Default
574 # Australia (historical usage)
575 # India
576 # You can create your own file in
577 # share/timezonesets/.
578#extra_float_digits = 0 # min -15, max 3
579#client_encoding = sql_ascii # actually, defaults to database
580 # encoding
581
582# These settings are initialized by initdb, but they can be changed.
583lc_messages = 'C.UTF-8' # locale for system error message
584 # strings
585lc_monetary = 'C.UTF-8' # locale for monetary formatting
586lc_numeric = 'C.UTF-8' # locale for number formatting
587lc_time = 'C.UTF-8' # locale for time formatting
588
589# default configuration for text search
590default_text_search_config = 'pg_catalog.english'
591
592# - Other Defaults -
593
594#dynamic_library_path = '$libdir'
595#local_preload_libraries = ''
596#session_preload_libraries = ''
597
598
599#------------------------------------------------------------------------------
600# LOCK MANAGEMENT
601#------------------------------------------------------------------------------
602
603#deadlock_timeout = 1s
604max_locks_per_transaction = 5000 # min 10
605 # (change requires restart)
606#max_pred_locks_per_transaction = 64 # min 10
607 # (change requires restart)
608#max_pred_locks_per_relation = -2 # negative values mean
609 # (max_pred_locks_per_transaction
610 # / -max_pred_locks_per_relation) - 1
611#max_pred_locks_per_page = 2 # min 0
612
613
614#------------------------------------------------------------------------------
615# VERSION/PLATFORM COMPATIBILITY
616#------------------------------------------------------------------------------
617
618# - Previous PostgreSQL Versions -
619
620#array_nulls = on
621#backslash_quote = safe_encoding # on, off, or safe_encoding
622#default_with_oids = off
623#escape_string_warning = on
624#lo_compat_privileges = off
625#operator_precedence_warning = off
626#quote_all_identifiers = off
627#standard_conforming_strings = on
628#synchronize_seqscans = on
629
630# - Other Platforms and Clients -
631
632#transform_null_equals = off
633
634
635#------------------------------------------------------------------------------
636# ERROR HANDLING
637#------------------------------------------------------------------------------
638
639#exit_on_error = off # terminate session on any error?
640#restart_after_crash = on # reinitialize after backend crash?
641
642
643#------------------------------------------------------------------------------
644# CONFIG FILE INCLUDES
645#------------------------------------------------------------------------------
646
647# These options allow settings to be loaded from files other than the
648# default postgresql.conf.
649
650include_dir = 'conf.d' # include files ending in '.conf' from
651 # directory 'conf.d'
652#include_if_exists = 'exists.conf' # include file only if it exists
653#include = 'special.conf' # include file
654
655
656#------------------------------------------------------------------------------
657# CUSTOMIZED OPTIONS
658#------------------------------------------------------------------------------
659
660# Add settings for extensions here