postgres 统计信息收集器进程生成的 I/O 过多

nn4*_*n4l 11 postgresql performance performance-tuning database-performance

我将 XenServer 与多个具有本地 postgres 数据库的虚拟机一起使用。即使所有应用程序都未使用且数据库处于空闲状态,每个虚拟机也会导致持续的存储网络流量,从而降低 iSCSI 存储设备的性能。

运行后,iotop我注意到 postgres stats 收集器进程进程以大约 2 MByte/s 的速率不断写入磁盘。

然后我通过编辑禁用了统计信息的收集/etc/postgresql/8.4/main/postgresql.conf

#------------------------------------------------------------------------------
# RUNTIME STATISTICS
#------------------------------------------------------------------------------

# - Query/Index Statistics Collector -

track_activities = off
track_counts = off
...
Run Code Online (Sandbox Code Playgroud)

正如http://www.postgresql.org/docs/8.4/static/runtime-config-statistics.htm 中所建议的。

这消除了连续写入,但是关闭统计跟踪有什么缺点吗?

或者我应该将 pg_stat_tmp 目录放在 ramdisk 上以避免磁盘/网络流量?

系统是最新的 Debian 6.0.7(squeeze),带有 postgres 8.4 和大约 20 个数据库,大约有 50 个表,总转储文件大小小于 100 MB。

nn4*_*n4l 8

由于升级 PostgreSQL 不是一种选择,我尝试将 pg_stat_tmp 目录放在 tmpfs 文件系统上,这显着提高了性能。我现在在几十个系统上运行了几个月,没有任何明显的缺点。

为此,只需在 /etc/fstab 文件中挂载 pg_stat_tmp 和 tmpfs:

# <file system> <mount point>                                <type>  <options>  <dump>  <pass>
tmpfs           /var/lib/postgresql/8.4/main/pg_stat_tmp     tmpfs   defaults,noatime,mode=1777,uid=postgres,gid=postgres,nosuid,nodev 0 0
Run Code Online (Sandbox Code Playgroud)