标签
Postgresql,参数,参数级别
背景
在添加GUC参数时,需要注意你添加的参数属于什么类别的参数。
例如如果你想让普通用户能随时修改它,那么你需要将参数级别设置为PGC_USERSET。如果你想让超级用户能在线修改它,那么你需要将它设置为PGC_SUSET。如果你想让它能够在修改配置参数并通过信号生效,那么需要设置为PGC_SIGHUP。
GUC参数相关的代码如下
src/backend/utils/misc/guc.c
参数级别介绍
/* * Displayable names for context types (enum GucContext) * * Note: these strings are deliberately not localized. */ const char *const GucContext_Names[] = { /* PGC_INTERNAL */ "internal",编译数据库集群时设置 /* PGC_POSTMASTER */ "postmaster",只能启动是设置 /* PGC_SIGHUP */ "sighup",允许通过修改配置文件,并通过SIGHUP信号更新参数。 /* PGC_SU_BACKEND */ "superuser-backend",超级用户的backend级参数 /* PGC_BACKEND */ "backend",普通用户的backend级参数 /* PGC_SUSET */ "superuser",允许超级用户在线修改的参数 /* PGC_USERSET */ "user" 允许普通用户在线修改的参数 };
如何查看所有参数级别
postgres=# select context,name,short_desc from pg_settings order by context,category,name; context | name | short_desc -------------------+-------------------------------------+------------------------------------------------------------------------------------------------------------------------------- backend | ignore_system_indexes | Disables reading from system indexes. backend | post_auth_delay | Waits N seconds on connection startup after authentication. internal | lc_collate | Shows the collation order locale. internal | lc_ctype | Shows the character classification and case conversion locale. internal | server_encoding | Sets the server (database) character set encoding. internal | block_size | Shows the size of a disk block. internal | data_checksums | Shows whether data checksums are turned on for this cluster. internal | debug_assertions | Shows whether the running server has assertion checks enabled. internal | integer_datetimes | Datetimes are integer based. internal | max_function_args | Shows the maximum number of function arguments. internal | max_identifier_length | Shows the maximum identifier length. internal | max_index_keys | Shows the maximum number of index keys. internal | segment_size | Shows the number of pages per disk file. internal | server_version | Shows the server version. internal | server_version_num | Shows the server version as an integer. internal | wal_block_size | Shows the block size in the write ahead log. internal | wal_segment_size | Shows the number of pages per write ahead log segment. postmaster | autovacuum_freeze_max_age | Age at which to autovacuum a table to prevent transaction ID wraparound. postmaster | autovacuum_max_workers | Sets the maximum number of simultaneously running autovacuum worker processes. postmaster | autovacuum_multixact_freeze_max_age | Multixact age at which to autovacuum a table to prevent multixact wraparound. postmaster | shared_preload_libraries | Lists shared libraries to preload into server. postmaster | bonjour | Enables advertising the server via Bonjour. postmaster | bonjour_name | Sets the Bonjour service name. postmaster | listen_addresses | Sets the host name or IP address(es) to listen to. postmaster | max_connections | Sets the maximum number of concurrent connections. postmaster | port | Sets the TCP port the server listens on. postmaster | superuser_reserved_connections | Sets the number of connection slots reserved for superusers. postmaster | unix_socket_directories | Sets the directories where Unix-domain sockets will be created. postmaster | unix_socket_group | Sets the owning group of the Unix-domain socket. postmaster | unix_socket_permissions | Sets the access permissions of the Unix-domain socket. postmaster | allow_system_table_mods | Allows modifications of the structure of system tables. postmaster | config_file | Sets the server's main configuration file. postmaster | data_directory | Sets the server's data directory. postmaster | external_pid_file | Writes the postmaster PID to the specified file. postmaster | hba_file | Sets the server's "hba" configuration file. postmaster | ident_file | Sets the server's "ident" configuration file. postmaster | max_locks_per_transaction | Sets the maximum number of locks per transaction. postmaster | max_pred_locks_per_transaction | Sets the maximum number of predicate locks per transaction. postmaster | cluster_name | Sets the name of the cluster,which is included in the process title. postmaster | track_commit_timestamp | Collects transaction commit time. postmaster | max_replication_slots | Sets the maximum number of simultaneously defined replication slots. postmaster | max_wal_senders | Sets the maximum number of simultaneously running WAL sender processes. postmaster | hot_standby | Allows connections and queries during recovery. postmaster | max_logical_replication_workers | Maximum number of logical replication worker processes. postmaster | event_source | Sets the application name used to identify Postgresql messages in the event log. postmaster | logging_collector | Start a subprocess to capture stderr output and/or csvlogs into log files. postmaster | max_worker_processes | Maximum number of concurrent worker processes. postmaster | old_snapshot_threshold | Time before a snapshot is too old to read pages changed after the snapshot was taken. postmaster | max_files_per_process | Sets the maximum number of simultaneously open files for each server process. postmaster | dynamic_shared_memory_type | Selects the dynamic shared memory implementation used. postmaster | huge_pages | Use of huge pages on Linux. postmaster | max_prepared_transactions | Sets the maximum number of simultaneously prepared transactions. postmaster | shared_buffers | Sets the number of shared memory buffers used by the server. postmaster | track_activity_query_size | Sets the size reserved for pg_stat_activity.query,in bytes. postmaster | archive_mode | Allows archiving of WAL files using archive_command. postmaster | wal_buffers | Sets the number of disk-page buffers in shared memory for WAL. postmaster | wal_level | Set the level of information written to the WAL. postmaster | wal_log_hints | Writes full pages to WAL when first modified after a checkpoint,even for a non-critical modifications. sighup | autovacuum | Starts the autovacuum subprocess. sighup | autovacuum_analyze_scale_factor | Number of tuple inserts,updates,or deletes prior to analyze as a fraction of reltuples. sighup | autovacuum_analyze_threshold | Minimum number of tuple inserts,or deletes prior to analyze. sighup | autovacuum_naptime | Time to sleep between autovacuum runs. sighup | autovacuum_vacuum_cost_delay | Vacuum cost delay in milliseconds,for autovacuum. sighup | autovacuum_vacuum_cost_limit | Vacuum cost amount available before napping,for autovacuum. sighup | autovacuum_vacuum_scale_factor | Number of tuple updates or deletes prior to vacuum as a fraction of reltuples. sighup | autovacuum_vacuum_threshold | Minimum number of tuple updates or deletes prior to vacuum. sighup | authentication_timeout | Sets the maximum allowed time to complete client authentication. sighup | db_user_namespace | Enables per-database user names. sighup | krb_caseins_users | Sets whether Kerberos and GSSAPI user names should be treated as case-insensitive. sighup | krb_server_keyfile | Sets the location of the Kerberos server key file. sighup | ssl | Enables SSL connections. sighup | ssl_ca_file | Location of the SSL certificate authority file. sighup | ssl_cert_file | Location of the SSL server certificate file. sighup | ssl_ciphers | Sets the list of allowed SSL ciphers. sighup | ssl_crl_file | Location of the SSL certificate revocation list file. sighup | ssl_dh_params_file | Location of the SSL DH params file. sighup | ssl_ecdh_curve | Sets the curve to use for ECDH. sighup | ssl_key_file | Location of the SSL server private key file. sighup | ssl_prefer_server_ciphers | Give priority to server ciphersuite order. sighup | pre_auth_delay | Waits N seconds on connection startup before authentication. sighup | trace_recovery_messages | Enables logging of recovery-related debugging information. sighup | restart_after_crash | Reinitialize server after backend crash. sighup | max_pred_locks_per_page | Sets the maximum number of predicate-locked tuples per page. sighup | max_pred_locks_per_relation | Sets the maximum number of predicate-locked pages and tuples per relation. sighup | synchronous_standby_names | Number of synchronous standbys and list of names of potential synchronous ones. sighup | vacuum_defer_cleanup_age | Number of transactions by which VACUUM and HOT cleanup should be deferred,if any. sighup | wal_keep_segments | Sets the number of WAL files held for standby servers. sighup | wal_sender_timeout | Sets the maximum time to wait for WAL replication. sighup | hot_standby_Feedback | Allows Feedback from a hot standby to the primary that will avoid query conflicts. sighup | max_standby_archive_delay | Sets the maximum delay before canceling queries when a hot standby server is processing archived WAL data. sighup | max_standby_streaming_delay | Sets the maximum delay before canceling queries when a hot standby server is processing streamed WAL data. sighup | wal_receiver_status_interval | Sets the maximum interval between WAL receiver status reports to the primary. sighup | wal_receiver_timeout | Sets the maximum wait time to receive data from the primary. sighup | wal_retrieve_retry_interval | Sets the time to wait before retrying to retrieve WAL after a Failed attempt. sighup | max_sync_workers_per_subscription | Maximum number of table synchronization workers per subscription. sighup | log_autovacuum_min_duration | Sets the minimum execution time above which autovacuum actions will be logged. sighup | log_checkpoints | Logs each checkpoint. sighup | log_hostname | Logs the host name in the connection logs. sighup | log_line_prefix | Controls information prefixed to each log line. sighup | log_timezone | Sets the time zone to use in log messages. sighup | log_destination | Sets the destination for server log output. sighup | log_directory | Sets the destination directory for log files. sighup | log_file_mode | Sets the file permissions for log files. sighup | log_filename | Sets the file name pattern for log files. sighup | log_rotation_age | Automatic log file rotation will occur after N minutes. sighup | log_rotation_size | Automatic log file rotation will occur after N kilobytes. sighup | log_truncate_on_rotation | Truncate existing log files of same name during log rotation. sighup | syslog_facility | Sets the syslog "facility" to be used when syslog enabled. sighup | syslog_ident | Sets the program name used to identify Postgresql messages in syslog. sighup | syslog_sequence_numbers | Add sequence number to syslog messages to avoid duplicate suppression. sighup | syslog_split_messages | Split messages sent to syslog by lines and to fit into 1024 bytes. sighup | bgwriter_delay | Background writer sleep time between rounds. sighup | bgwriter_flush_after | Number of pages after which prevIoUsly performed writes are flushed to disk. sighup | bgwriter_lru_maxpages | Background writer maximum number of LRU pages to flush per round. sighup | bgwriter_lru_multiplier | Multiple of the average buffer usage to free per round. sighup | autovacuum_work_mem | Sets the maximum memory to be used by each autovacuum worker process. sighup | stats_temp_directory | Writes temporary statistics files to the specified directory. sighup | archive_command | Sets the shell command that will be called to archive a WAL file. sighup | archive_timeout | Forces a switch to the next WAL file if a new file has not been started within N seconds. sighup | checkpoint_completion_target | Time spent flushing dirty buffers during checkpoint,as fraction of checkpoint interval. sighup | checkpoint_flush_after | Number of pages after which prevIoUsly performed writes are flushed to disk. sighup | checkpoint_timeout | Sets the maximum time between automatic WAL checkpoints. sighup | checkpoint_warning | Enables warnings if checkpoint segments are filled more frequently than this. sighup | max_wal_size | Sets the WAL size that triggers a checkpoint. sighup | min_wal_size | Sets the minimum size to shrink the WAL to. sighup | fsync | Forces synchronization of updates to disk. sighup | full_page_writes | Writes full pages to WAL when first modified after a checkpoint. sighup | wal_sync_method | Selects the method used for forcing WAL updates to disk. sighup | wal_writer_delay | Time between WAL flushes performed in the WAL writer. sighup | wal_writer_flush_after | Amount of WAL written out by WAL writer that triggers a flush. superuser | lc_messages | Sets the language in which messages are displayed. superuser | dynamic_library_path | Sets the path for dynamically loadable modules. superuser | session_preload_libraries | Lists shared libraries to preload into each backend. superuser | session_replication_role | Sets the session's behavior for triggers and rewrite rules. superuser | ignore_checksum_failure | Continues processing after a checksum failure. superuser | wal_consistency_checking | Sets the WAL resource managers for which WAL consistency checks are done. superuser | zero_damaged_pages | Continues processing past damaged page headers. superuser | deadlock_timeout | Sets the time to wait on a lock before checking for deadlock. superuser | update_process_title | Updates the process title to show the active sql command. superuser | log_duration | Logs the duration of each completed sql statement. superuser | log_error_verbosity | Sets the verbosity of logged messages. superuser | log_lock_waits | Logs long lock waits. superuser | log_replication_commands | Logs each replication command. superuser | log_statement | Sets the type of statements logged. superuser | log_temp_files | Log the use of temporary files larger than this number of kilobytes. superuser | log_min_duration_statement | Sets the minimum execution time above which statements will be logged. superuser | log_min_error_statement | Causes all statements generating error at or above this level to be logged. superuser | log_min_messages | Sets the message levels that are logged. superuser | temp_file_limit | Limits the total size of all temporary files used by each process. superuser | max_stack_depth | Sets the maximum stack depth,in kilobytes. superuser | log_executor_stats | Writes executor performance statistics to the server log. superuser | log_parser_stats | Writes parser performance statistics to the server log. superuser | log_planner_stats | Writes planner performance statistics to the server log. superuser | log_statement_stats | Writes cumulative performance statistics to the server log. superuser | track_activities | Collects information about executing commands. superuser | track_counts | Collects statistics on database activity. superuser | track_functions | Collects function-level statistics on database activity. superuser | track_io_timing | Collects timing statistics for database I/O activity. superuser | lo_compat_privileges | Enables backward compatibility mode for privilege checks on large objects. superuser | commit_delay | Sets the delay in microseconds between transaction commit and flushing WAL to disk. superuser | wal_compression | Compresses full-page writes written in WAL file. superuser-backend | log_connections | Logs each successful connection. superuser-backend | log_disconnections | Logs end of a session,including duration. user | DateStyle | Sets the display format for date and time values. user | IntervalStyle | Sets the display format for interval values. user | TimeZone | Sets the time zone for displaying and interpreting time stamps. user | client_encoding | Sets the client's character set encoding. user | default_text_search_config | Sets default text search configuration. user | extra_float_digits | Sets the number of digits displayed for floating-point values. user | lc_monetary | Sets the locale for formatting monetary amounts. user | lc_numeric | Sets the locale for formatting numbers. user | lc_time | Sets the locale for formatting date and time values. user | timezone_abbreviations | Selects a file of time zone abbreviations. user | gin_fuzzy_search_limit | Sets the maximum allowed result for exact search by GIN. user | tcp_keepalives_count | Maximum number of TCP keepalive retransmits. user | tcp_keepalives_idle | Time between issuing TCP keepalives. user | tcp_keepalives_interval | Time between TCP keepalive retransmits. user | local_preload_libraries | Lists unprivileged shared libraries to preload into each backend. user | bytea_output | Sets the output format for bytea. user | check_function_bodies | Check function bodies during CREATE FUNCTION. user | default_tablespace | Sets the default tablespace to create tables and indexes in. user | default_transaction_deferrable | Sets the default deferrable status of new transactions. user | default_transaction_isolation | Sets the transaction isolation level of each new transaction. user | default_transaction_read_only | Sets the default read-only status of new transactions. user | gin_pending_list_limit | Sets the maximum size of the pending list for GIN index. user | idle_in_transaction_session_timeout | Sets the maximum allowed duration of any idling transaction. user | lock_timeout | Sets the maximum allowed duration of any wait for a lock. user | search_path | Sets the schema search order for names that are not schema-qualified. user | statement_timeout | Sets the maximum allowed duration of any statement. user | temp_tablespaces | Sets the tablespace(s) to use for temporary tables and sort files. user | transaction_deferrable | Whether to defer a read-only serializable transaction until it can be executed with no possible serialization failures. user | transaction_isolation | Sets the current transaction's isolation level. user | transaction_read_only | Sets the current transaction's read-only status. user | vacuum_freeze_min_age | Minimum age at which VACUUM should freeze a table row. user | vacuum_freeze_table_age | Age at which VACUUM should scan whole table to freeze tuples. user | vacuum_multixact_freeze_min_age | Minimum age at which VACUUM should freeze a MultiXactId in a table row. user | vacuum_multixact_freeze_table_age | Multixact age at which VACUUM should scan whole table to freeze tuples. user | xmlbinary | Sets how binary values are to be encoded in XML. user | xmloption | Sets whether XML data in implicit parsing and serialization operations is to be considered as documents or content fragments. user | password_encryption | Encrypt passwords. user | row_security | Enable row security. user | trace_notify | Generates debugging output for LISTEN and NOTIFY. user | trace_sort | Emit information about resource usage in sorting. user | exit_on_error | Terminate session on any error. user | geqo | Enables genetic query optimization. user | geqo_effort | GEQO: effort is used to set the default for other GEQO parameters. user | geqo_generations | GEQO: number of iterations of the algorithm. user | geqo_pool_size | GEQO: number of individuals in the population. user | geqo_seed | GEQO: seed for random path selection. user | geqo_selection_bias | GEQO: selective pressure within the population. user | geqo_threshold | Sets the threshold of FROM items beyond which GEQO is used. user | constraint_exclusion | Enables the planner to use constraints to optimize queries. user | cursor_tuple_fraction | Sets the planner's estimate of the fraction of a cursor's rows that will be retrieved. user | default_statistics_target | Sets the default statistics target. user | force_parallel_mode | Forces use of parallel query facilities. user | from_collapse_limit | Sets the FROM-list size beyond which subqueries are not collapsed. user | join_collapse_limit | Sets the FROM-list size beyond which JOIN constructs are not flattened. user | cpu_index_tuple_cost | Sets the planner's estimate of the cost of processing each index entry during an index scan. user | cpu_operator_cost | Sets the planner's estimate of the cost of processing each operator or function call. user | cpu_tuple_cost | Sets the planner's estimate of the cost of processing each tuple (row). user | effective_cache_size | Sets the planner's assumption about the size of the disk cache. user | min_parallel_index_scan_size | Sets the minimum amount of index data for a parallel scan. user | min_parallel_table_scan_size | Sets the minimum amount of table data for a parallel scan. user | parallel_setup_cost | Sets the planner's estimate of the cost of starting up worker processes for parallel query. user | parallel_tuple_cost | Sets the planner's estimate of the cost of passing each tuple (row) from worker to master backend. user | random_page_cost | Sets the planner's estimate of the cost of a nonsequentially fetched disk page. user | seq_page_cost | Sets the planner's estimate of the cost of a sequentially fetched disk page. user | enable_bitmapscan | Enables the planner's use of bitmap-scan plans. user | enable_gathermerge | Enables the planner's use of gather merge plans. user | enable_hashagg | Enables the planner's use of hashed aggregation plans. user | enable_hashjoin | Enables the planner's use of hash join plans. user | enable_indexonlyscan | Enables the planner's use of index-only-scan plans. user | enable_indexscan | Enables the planner's use of index-scan plans. user | enable_material | Enables the planner's use of materialization. user | enable_mergejoin | Enables the planner's use of merge join plans. user | enable_nestloop | Enables the planner's use of nested-loop join plans. user | enable_parallelappend | Enables the planner's use of parallel append plans. user | enable_seqscan | Enables the planner's use of sequential-scan plans. user | enable_sort | Enables the planner's use of explicit sort steps. user | enable_tidscan | Enables the planner's use of TID scan plans. user | application_name | Sets the application name to be reported in statistics and logs. user | debug_pretty_print | Indents parse and plan tree displays. user | debug_print_parse | Logs each query's parse tree. user | debug_print_plan | Logs each query's execution plan. user | debug_print_rewritten | Logs each query's rewritten parse tree. user | client_min_messages | Sets the message levels that are sent to the client. user | backend_flush_after | Number of pages after which prevIoUsly performed writes are flushed to disk. user | effective_io_concurrency | Number of simultaneous requests that can be handled efficiently by the disk subsystem. user | max_parallel_workers | Sets the maximum number of parallel workers than can be active at one time. user | max_parallel_workers_per_gather | Sets the maximum number of parallel processes per executor node. user | vacuum_cost_delay | Vacuum cost delay in milliseconds. user | vacuum_cost_limit | Vacuum cost amount available before napping. user | vacuum_cost_page_dirty | Vacuum cost for a page dirtied by vacuum. user | vacuum_cost_page_hit | Vacuum cost for a page found in the buffer cache. user | vacuum_cost_page_miss | Vacuum cost for a page not found in the buffer cache. user | maintenance_work_mem | Sets the maximum memory to be used for maintenance operations. user | replacement_sort_tuples | Sets the maximum number of tuples to be sorted using replacement selection. user | temp_buffers | Sets the maximum number of temporary buffers used by each session. user | work_mem | Sets the maximum memory to be used for query workspaces. user | transform_null_equals | Treats "expr=NULL" as "expr IS NULL". user | array_nulls | Enable input of NULL elements in arrays. user | backslash_quote | Sets whether "\'" is allowed in string literals. user | default_with_oids | Create new tables with OIDs by default. user | escape_string_warning | Warn about backslash escapes in ordinary string literals. user | operator_precedence_warning | Emit a warning for constructs that changed meaning since Postgresql 9.4. user | quote_all_identifiers | When generating sql fragments,quote all identifiers. user | standard_conforming_strings | Causes '...' strings to treat backslashes literally. user | synchronize_seqscans | Enable synchronized sequential scans. user | commit_siblings | Sets the minimum concurrent open transactions before performing commit_delay. user | synchronous_commit | Sets the current transaction's synchronization level. (270 rows)