瀚高数据库
目录
文档用途
详细信息
文档用途
在PostgreSQL12版本中,对部分数据库默认参数进行了优化调整,本文主要分三个部分对调整后的参数进行介绍,主要涉及配置文件为postgresql.conf文件。
详细信息
一、新增参数
以下参数为新增参数.
表1 新增参数统计
参数名称 | 描述 | 默认值 |
---|---|---|
archive_cleanup_command | 自recovery.conf迁移至此(sighup) | - |
data_sync_retry | fsync系统调用失败时动作(postmaster) | off |
default_table_access_method | 默认存储引擎名称 (user) | heap |
log_statement_sample_rate | SQL语句输出到日志的速率(superuser) | 1 |
plan_cache_mode | 改变缓存执行计划的模式行为 (user) | auto |
primary_conninfo | 自recovery.conf file迁移至此 (postmaster) | - |
primary_slot_name | 自recovery.conf file迁移至此 (postmaster) | - |
promote_trigger_file | 自recovery.conf file迁移至此(sighup) | - |
recovery_end_command | 自recovery.conf file迁移至此(sighup) | - |
recovery_min_apply_delay | 自recovery.conf file迁移至此(sighup) | 0 |
recovery_target | 自recovery.conf file迁移至此(postmaster) | - |
recovery_target_action | 自recovery.conf file迁移至此(postmaster) | pause |
recovery_target_inclusive | 自recovery.conf file迁移至此(postmaster) | on |
recovery_target_lsn | 自recovery.conf file迁移至此(postmaster) | - |
recovery_target_name | 自recovery.conf file迁移至此(postmaster) | - |
recovery_target_time | 自recovery.conf file迁移至此(postmaster) | - |
recovery_target_timeline | 自recovery.conf file迁移至此(postmaster) | latest |
recovery_target_xid | 自recovery.conf file迁移至此(postmaster) | - |
shared_memory_type | 定义共享内存类型(postmaster) | OS depend |
ssl_library | 定义提供SSL 函数的library名称(internal) | - |
ssl_max_protocol_version | 支持SSL协议的最高版本(sighup) | - |
ssl_min_protocol_version | 支持SSL协议的最低版本(sighup) | TLSv1 |
tcp_user_timeout | 定义TCP超时时间(user | 0 |
wal_init_zero | 将WAL文件填写为零(superuser) | on |
wal_recycle | 回收WAL文件(superuser) | on |
1.primary_conninfo参数
定义连接主库的连接串。在之前的版本中此参数配置在recovery.conf文件中。一般情况下application_name参数的默认值为“walreceiver”,但是当配置备库的cluster_name参数后,备库的cluster_name的值就会成为application_name参数默认值。
2.ssl_library参数
此参数显示提供SSL特性的库的名称。当在RHEL环境中编译安装数据库时,在执行configure命令指定–with-openssl时,安装完成后查询此参数值为“OpenSSL”。
示例1:ssl_libarary参数查询
postgres=# show ssl_library ;
ssl_library
-------------
OpenSSL
(1 row)
3.Shared_memory_type 参数
此参数定义共享内存的类型(例如shared_buffers)
表2 shared_memory_type 参数值
设置 | 描述 | 系统调用 |
---|---|---|
mmap | 使用匿名内存映射。. | mmap |
sysv | 使用System V共享内存. | shmget |
windows | 使用Windows共享内存. | CreateFileMapping |
Linux上这个参数的默认值是mmap。这与PostgreSQL 9.3及以后版本的默认值相同。非常少量的系统V共享内存和大多数共享内存是使用内存映射文件(mmap)配置的。对于9.2及之前的版本,此参数一般设置为sysv。在这种情况下,数据库使用System V共享内存配置所有共享内存。
4.Plancache_mode 参数
此参数设置用于缓存已准备语句(由准备语句创建)的执行计划的方法。同之前的版本相同,此参数的默认值是auto。通常,每次由EXECUTE语句执行由PREPARE语句创建的SQL语句时,都会生成一个执行计划。
5.Data_sync_retry参数
此参数决定在检查点期间发出的fsync系统调用失败时的动作。在之前的版本中,fsync函数被重新执行(data_sync_retry = “on”),在新版本中如果fsync系统调用失败,则默认行为(data_sync_retry = “off”)是由PANIC导致实例停止。这个参数是在PostgreSQL 11.2之后添加的。
二、设置范围调整参数
下列参数的设置范围及设置项发生变更。
表3 变化参数统计
参数名称 | 变更 |
---|---|
client_min_messages | 不再能够设置为比 ERROR更高的参数. |
dynamic_shared_memory_type | 参数值"none" 已经被移除 |
log_autovacuum_min_duration | 日志的输出内容根据VACUUM的执行状态而改变 |
log_connections | 日志中增加Application_name信息 |
plpgsql.extra_warnings | 以下两个参数被增加 1 too_many_rows 2 strict_multi_assignment |
trace_sort | 日志输出信息被更改. |
wal_level | 数据库启动时会检查wal_level参数是否在合适. |
wal_sender_timeout | 参数的访问设置形式由sighup变为user等级. |
default_with_oids | 无法被设置为”on” |
recovery_target_timeline | 可设置参数中添加"Current"项, 默认值修改为"latest". |
autovacuum_vacuum_cost_delay | 数据类型从integer 修改为real |
1.无法从pg_settings视图中查看default_with_oid参数。
示例2 default_with_oids parameter
postgres=# show default_with_oids;
-[ RECORD 1 ]-----+----
default_with_oids | off
postgres=# set default_with_oids=on;
ERROR: tables declared WITH OIDS are not supported
postgres=# SELECT COUNT(*) FROM pg_settings WHERE name='default_with_oids';
-[ RECORD 1 ]
count | 0
2.Wal_sender_timeout 参数
现在用户可以在每个会话的基础上更改此参数。这允许在流复制环境中从备库实例上修改每个连接的参数。
示例3 wal_sender_timeout 参数
$grep primary_conninfo data/postgresql.conf
primary_conninfo = 'host=svrhost1 port=5432 user=postgres password=password options=''-c wal_sender_timeout=5000'''
3.Log_connections 参数
当将该参数设置为’on’时, application_name参数的值会添加到输出的日志中。
示例4:log_connections 参数
*Connection from psql command
LOG:connection authorized: user=postgres database=postgres application_name=psql
*Connection from pg_basebackup command
LOG:replication connection authorized: user=postgres application_name=pg_baseback
*Connection from Streaming Replication slave instance
LOG:replication connection authorized: user=postgres application_name=walreceiver
4.Wal_level 参数
当设置使用复制槽时,在实例启动过程中会检查
当设置使用复制槽时,在实例启动过程中会检查wal_level参数值设置的是否恰当。如果没有设置所需的级别,实例启动将失败。
示例5:wal_leverl值检查
postgres=# ALTER SYSTEM SET wal_level=minimal ;
ALTER SYSTEM
postgres=# \q
$
$ pg_ctl -D data restart
waiting for server to shut down.... done server stopped
waiting for server to start....2019-10-04 00:52:19.890 EDT [22682] FATAL: WAL archival cannot be enabled when wal_level is "minimal" stopped waiting
pg_ctl: could not start server Examine the log output.
$
三、默认值变化参数
下列配置参数的默认值已被修
表4 默认值已改变的参数统计
参数名称 | PostgreSQL 11 | PostgreSQL 12 | Note |
---|---|---|---|
autovacuum_vacuum_cost_delay | 20 | 2 | |
extra_float_digits | 0 | 1 | |
jit | off | on | |
recovery_target_timeline | current | latest | |
server_version | 11.5 | 12.0 | |
server_version_num | 110005 | 120000 |
备注:本文译自《PostgreSQL_12_GA_New_Features_en_20191011-1》