暂无图片
PostgreSQL 参数设置简介
最近更新:2023-09-14 10:10:58

适用范围

PostgreSQL 9 and later

目的

PostgreSQL参数修改:实例级别、数据库级别、用户级别

详细方案

一、Postgresql 参数文件查看和解释

postgres=# show config_file;
-[ RECORD 1 ]----------------------------
config_file | /data/pgsql/postgresql.conf

postgres=# show hba_file;
-[ RECORD 1 ]---------------------
hba_file | /data/pgsql/pg_hba.conf

postgres=# show ident_file;
-[ RECORD 1 ]-------------------------
ident_file | /data/pgsql/pg_ident.conf

postgres=# show all;

                  name                  |            setting             |                                                          description                                                          
----------------------------------------+--------------------------------+-------------------------------------------------------------------------------------------------------------------------------
 allow_system_table_mods                | off                            | Allows modifications of the structure of system tables.
 application_name                       | psql                           | Sets the application name to be reported in statistics and logs.
 archive_cleanup_command                |                                | Sets the shell command that will be executed at every restart point.
 archive_command                        | (disabled)                     | Sets the shell command that will be called to archive a WAL file.
 archive_mode                           | off                            | Allows archiving of WAL files using archive_command.
 archive_timeout                        | 0                              | Forces a switch to the next WAL file if a new file has not been started within N seconds.
 array_nulls                            | on                             | Enable input of NULL elements in arrays.
 authentication_timeout                 | 1min                           | Sets the maximum allowed time to complete client authentication.
 autovacuum                             | on                             | Starts the autovacuum subprocess.
 autovacuum_analyze_scale_factor        | 0.1                            | Number of tuple inserts, updates, or deletes prior to analyze as a fraction of reltuples.
 autovacuum_analyze_threshold           | 50                             | Minimum number of tuple inserts, updates, or deletes prior to analyze.
 autovacuum_freeze_max_age              | 200000000                      | Age at which to autovacuum a table to prevent transaction ID wraparound.
 autovacuum_max_workers                 | 3                              | Sets the maximum number of simultaneously running autovacuum worker processes.
 autovacuum_multixact_freeze_max_age    | 400000000                      | Multixact age at which to autovacuum a table to prevent multixact wraparound.
 autovacuum_naptime                     | 1min                           | Time to sleep between autovacuum runs.
 autovacuum_vacuum_cost_delay           | 2ms                            | Vacuum cost delay in milliseconds, for autovacuum.
 autovacuum_vacuum_cost_limit           | -1                             | Vacuum cost amount available before napping, for autovacuum.
 autovacuum_vacuum_scale_factor         | 0.2                            | Number of tuple updates or deletes prior to vacuum as a fraction of reltuples.
 autovacuum_vacuum_threshold            | 50                             | Minimum number of tuple updates or deletes prior to vacuum.
 autovacuum_work_mem                    | -1                             | Sets the maximum memory to be used by each autovacuum worker process.
 backend_flush_after                    | 0                              | Number of pages after which previously performed writes are flushed to disk.
 backslash_quote                        | safe_encoding                  | Sets whether "\'" is allowed in string literals.
 bgwriter_delay                         | 200ms                          | Background writer sleep time between rounds.
 bgwriter_flush_after                   | 512kB                          | Number of pages after which previously performed writes are flushed to disk.
 bgwriter_lru_maxpages                  | 100                            | Background writer maximum number of LRU pages to flush per round.
 bgwriter_lru_multiplier                | 2                              | Multiple of the average buffer usage to free per round.
 block_size                             | 8192                           | Shows the size of a disk block.
 bonjour                                | off                            | Enables advertising the server via Bonjour.
 bonjour_name                           |                                | Sets the Bonjour service name.
 bytea_output                           | hex                            | Sets the output format for bytea.
 check_function_bodies                  | on                             | Check function bodies during CREATE FUNCTION.
 checkpoint_completion_target           | 0.5                            | Time spent flushing dirty buffers during checkpoint, as fraction of checkpoint interval.
 checkpoint_flush_after                 | 256kB                          | Number of pages after which previously performed writes are flushed to disk.
 checkpoint_timeout                     | 5min                           | Sets the maximum time between automatic WAL checkpoints.
 checkpoint_warning                     | 30s                            | Enables warnings if checkpoint segments are filled more frequently than this.
 client_encoding                        | UTF8                           | Sets the client's character set encoding.
 client_min_messages                    | notice                         | Sets the message levels that are sent to the client.
 cluster_name                           |                                | Sets the name of the cluster, which is included in the process title.
 commit_delay                           | 0                              | Sets the delay in microseconds between transaction commit and flushing WAL to disk.
 commit_siblings                        | 5                              | Sets the minimum concurrent open transactions before performing commit_delay.
 config_file                            | /data/pgsql/postgresql.conf    | Sets the server's main configuration file.
 constraint_exclusion                   | partition                      | Enables the planner to use constraints to optimize queries.
 cpu_index_tuple_cost                   | 0.005                          | Sets the planner's estimate of the cost of processing each index entry during an index scan.
 cpu_operator_cost                      | 0.0025                         | Sets the planner's estimate of the cost of processing each operator or function call.
 cpu_tuple_cost                         | 0.01                           | Sets the planner's estimate of the cost of processing each tuple (row).
 cursor_tuple_fraction                  | 0.1                            | Sets the planner's estimate of the fraction of a cursor's rows that will be retrieved.
 data_checksums                         | on                             | Shows whether data checksums are turned on for this cluster.
 data_directory                         | /data/pgsql                    | Sets the server's data directory.
 data_directory_mode                    | 0700                           | Mode of the data directory.
 data_sync_retry                        | off                            | Whether to continue running after a failure to sync data files.
 DateStyle                              | ISO, MDY                       | Sets the display format for date and time values.
 db_user_namespace                      | off                            | Enables per-database user names.
 deadlock_timeout                       | 1s                             | Sets the time to wait on a lock before checking for deadlock.
 debug_assertions                       | off                            | Shows whether the running server has assertion checks enabled.
 debug_pretty_print                     | on                             | Indents parse and plan tree displays.
 debug_print_parse                      | off                            | Logs each query's parse tree.
 debug_print_plan                       | off                            | Logs each query's execution plan.
 debug_print_rewritten                  | off                            | Logs each query's rewritten parse tree.
 default_statistics_target              | 100                            | Sets the default statistics target.
 default_table_access_method            | heap                           | Sets the default table access method for new tables.
 default_tablespace                     |                                | Sets the default tablespace to create tables and indexes in.
 default_text_search_config             | pg_catalog.english             | Sets default text search configuration.
 default_transaction_deferrable         | off                            | Sets the default deferrable status of new transactions.
 default_transaction_isolation          | read committed                 | Sets the transaction isolation level of each new transaction.
 default_transaction_read_only          | off                            | Sets the default read-only status of new transactions.
 dynamic_library_path                   | $libdir                        | Sets the path for dynamically loadable modules.
 dynamic_shared_memory_type             | posix                          | Selects the dynamic shared memory implementation used.
 effective_cache_size                   | 4GB                            | Sets the planner's assumption about the total size of the data caches.
 effective_io_concurrency               | 1                              | Number of simultaneous requests that can be handled efficiently by the disk subsystem.
......