博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PostgreSQL Memory for Database Caching(2)
阅读量:2395 次
发布时间:2019-05-10

本文共 1450 字,大约阅读时间需要 4 分钟。

Inspecting the database cache

想让postgresQL 使用shared_buffers database cache ,需要使用pg_buffercache module,这是一个contrib里的可选模块。

Installing pg_buffercache into a database

In order to install this utility or to use it, you will need to be connected to the database as its superuser. Here's a sample that installs pg_buffercache into a new database, presuming the RedHat Linux standard directory installation tree; substitute your own PostgreSQL installation directory here:
$ createdb pgbench
$ psql -d pgbench -f /usr/share/postgresql/contrib/pg_buffercache.sql
注意:在8.x和9.x里都没有pg_buffercache.sql,需要从网上去下载。
安装此sql后,就可以在客户端上查看相关的share memory信息。SQL语句如下:
SELECT name,setting,unit,current_setting(name) FROM pg_settings WHERE name='shared_buffers';
或者
select count(*) from pg_buffercache;

Database disk layout

In order to fully interpret the information returned by utilities such as pg_buffercahe,and therefore use that information to adjust memory sizing,
it's helpful to know a bit about how databases are stored on disk.
使用SQL命令:
show data_directory;
就可以知道数据存放的路径
如果想查看其他文件的存放路径,命令如图:
在data目录下面有一个base目录。
base目录下的内容如图:
 这个目录下的数字术语叫
object identifier or
OID.这个标识是唯一的。

这些ID对应一个数据库,如果想知道映射关系,你也可以用SQL语句来查看,命令如图:

补充下,如果查询表的相关信息,是pg_class这张表,SQL就省略了。

你也可以在命令行里查看,命令如图:

Creating a new block in a database

Once you insert something into this table, a page is allocated in the buffer cache to hold that new information, and a standard 8K block is allocated on disk.

转载地址:http://npzob.baihongyu.com/

你可能感兴趣的文章
学好C语言,你只需要这几句口诀!
查看>>
选择大于努力!0基础学好C语言编程,首先要掌握的是什么?
查看>>
C语言和其他语言的不得不说的差别!
查看>>
夫妻俩在互联网公司工作,年收入曝光,网友:这么高!
查看>>
程序员5年工作经验,因频繁跳槽被面试官压工资!
查看>>
职场中神奇的程序员,却常常被人说“太直”,这是什么样的思维?
查看>>
@初学编程的朋友们,如果你能学得这些方法,学习将会更快一步!
查看>>
C/C++编程笔记:C/C++ 的编译和链接
查看>>
C/C++编程知识分享:C++四种强制转换,教你多种类型转换方式!
查看>>
全球最厉害的 14 位程序员,你知道几位呢?最厉害的研究出了它!
查看>>
C/C++基础语法复习(二):C++ 面向对象编程,你需要知道的点
查看>>
简述 C语言 有和 C++ 的基本区别,你真的懂吗?(新手面试必学)
查看>>
刚进职场的程序员,请万分珍重你的第一份工作,不要轻易辞职!
查看>>
C/C++之QT攻略——在QT中容易遇到的那些坑,千万别踩了!
查看>>
@90后程序员,“颜值即正义”的现在,程序员应该如何更新穿搭?
查看>>
程序员须知:必须建立个人知识库,它的重要性你需要了解一下!
查看>>
C/C++知识分享番外:如何申请一个腾讯地图用户Key?
查看>>
程序员提高编程技术最有效的一件事?了解一下,迅速提升自己!
查看>>
程序员想找工作怎么办?如果记住这一点,不怕找不到好工作!
查看>>
程序员找工作时,大公司 VS 小公司,应该如何做出正确的选择?
查看>>