“缓冲区”有多大?在PostgreSQL中 [英] How large is a "buffer" in PostgreSQL

查看:106
本文介绍了“缓冲区”有多大?在PostgreSQL中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 pg_buffercache 模块来查找占用我RAM缓存的猪。例如,当我运行以下查询时:

I am using pg_buffercache module for finding hogs eating up my RAM cache. For example when I run this query:

SELECT c.relname, count(*) AS buffers
FROM pg_buffercache b INNER JOIN pg_class c
    ON b.relfilenode = c.relfilenode AND
       b.reldatabase IN (0, (SELECT oid FROM pg_database WHERE datname = current_database()))
GROUP BY c.relname
ORDER BY 2 DESC
LIMIT 10;

我发现 sample_table 正在使用120个缓冲区。

I discover that sample_table is using 120 buffers.

120个字节缓冲区是多少?

How much is 120 buffers in bytes?

推荐答案

PostgreSQL硬编码的块大小为 8192 个字节-请参见预定义的block_size变量。每当您编辑配置以指定 shared_buffers 等时,这个数字就一直牢记在心,但是该配置现在支持 MB 会为您完成转换。

PostgreSQL has a hard coded block size of 8192 bytes -- see the pre-defined block_size variable. This used to be a number to hold in mind whenever you edited the config to specify shared_buffers, etc., but the config now supports suffixes like MB which will do the conversion for you.

通过艰苦的努力,可以将block_size更改为其他值。对于少数几个应用程序,可能会有更好的大小,但是代码假设大小的地方很大。

It is possible, with hard work, to change block_size to other values. For a minority of applications there might be a more optimal size, but the number of places the code makes an assumption about the size is large.

这篇关于“缓冲区”有多大?在PostgreSQL中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆