我有一个 PostgreSQL 只读副本,其唯一目的是执行一些聚合查询。目前,为了进行聚合,正在进行大量 I/O,即使有大量可用内存,而且由于实例仅用于此目的,我想知道是否可能:
简单地告诉 PostgreSQL 缓存表的大部分内容以加速聚合查询。这可能吗?
最佳答案
根据 Craig 的评论:
The pg_prewarm module provides a convenient way to load relation data into either the operating system buffer cache or the PostgreSQL buffer cache. http://www.postgresql.org/docs/9.4/static/pgprewarm.html
不要忘记 pg_prewarm 是一个扩展,所以你必须添加它:
create extension pg_prewarm;
.. a lot of I/O is going on in order to do the aggregates, even though there's a lot of memory available ..
您可能还想研究一些内存配置选项 ( http://www.postgresql.org/docs/9.4/static/runtime-config-resource.html#RUNTIME-CONFIG-RESOURCE-MEMORY )
关于sql - 将表moSTLy或部分加载到工作内存中以供查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33601179/