PostgreSQL不会自动将可用RAM用于内存密集型查询

时间:2014-08-06 00:46:05

标签: linux postgresql database-performance

我正在使用PostgreSQL在linux(ubuntu)上运行数据库应用程序。该应用程序是内存密集型的,因此我为数据库服务器提供了64 GB的RAM(和8个CPU内核)。 Postgres似乎没有自动检测和使用可用的RAM,并且应用程序的查询运行速度非常慢。例如,top说:

PID   USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
5958 postgres  20   0 16.5g  70m  66m R   99  0.1   8:00.83  postgres
4233 postgres  20   0     0    0    0 R    8  0.0   0:00.04  postgres
789  postgres  20   0 16.5g 408m 407m S    2  0.6   0:32.15  postgres 
4221 root      20   0 17336 1292  952 R    2  0.0   0:00.01  top     
1    root      20   0 24348 2232 1340 S    0  0.0   0:01.59  init

我尝试通过/etc/sysctl.conf增加对SysV共享内存段的内核端限制...

kernel.shmmax=34359738368
kernel.shmall=2147483648

...但即使重启后这也没有效果。我接下来应该尝试什么?

1 个答案:

答案 0 :(得分:0)

有很多调优命令可以应用于postgres实例以尝试更好地利用您拥有的可用规范,如果要分配,甚至可以使用ALTER DATABASE修改特定性能变量的行为某些特定数据库的特殊资源。

我建议你阅读http://www.postgresql.org/docs/9.3/static/runtime-config-resource.html,然后开始尝试提高性能的价值。