pg_buffercache
查看缓冲区缓存的内容: create extension pg_buffercache; select c.relname, count(1) as buffers from pg_class c join pg_buffercache b on b.relfilenode=c.relfilenode inner join pg_database d on (b.reldatabase=d.oid and d.datname=current_database()) group by c.relname order by 2 desc; -[ RECORD 1 ]------------------------------ relname | pg_depend_reference_index buffers | 12 -[ RECORD 2 ]------------------------------ relname | pg_depend buffers | 10 -[ RECORD 3 ]------------------------------ relname | pg_rewrite buffers | 6 -[ RECORD 4 ]------------------------------ relname | pg_extension buffers | 5 -[ RECORD 5 ]------------------------------ relname | pg_init_privs buffers | 5 -[ RECORD 6 ]------------------------------ relname | pg_statistic buffers | 5 -[ RECORD 7 ]------------------------------ relname | pg_amop buffers | 5 -[ RECORD 8 ]------------------------------ relname | pg_operator_oprname_l_r_n_index buffers | 5 -[ RECORD 9 ]------------------------------ relname | pg_depend_depender_index buffers | 5 缓存的都是数据字典视图。 排除掉此类视图 : select c.relname, count(1) as buffers from pg_class c join pg_buffercache b on b.relfilenode=c.relfilenode inner join pg_database d on (b.reldatabase=d.oid and d.datname=current_database()) where c.relname not like 'pg%' group by c.relname order by 2 desc; relname | buffers ---------+--------- (0 rows) 创建自己的表,然后插入记录: create table test(id numeric,name text); insert into test values(1,'dxmy'); test=# select * from test; id | name ----+------ 1 | dxmy (1 row) 然后再查询: test=# select c.relname,b.isdirty, count(1) as buffers from pg_class c join pg_buffercache b on b.relfilenode=c.relfilenode inner join pg_database d on (b.reldatabase=d.oid and d.datname=current_database()) where c.relname not like 'pg%' group by c.relname,b.isdirty order by 2 desc; relname | isdirty | buffers ---------+---------+--------- test | t | 1 (1 row) 发现我们新建的表及插入的数据缓存了: 其中,isdirty是f,意思就是不脏,来修改一下: update test set id=2; test=# update test set id=2; UPDATE 1 再查一次: test=# select c.relname,b.isdirty, count(1) as buffers from pg_class c join pg_buffercache b on b.relfilenode=c.relfilenode inner join pg_database d on (b.reldatabase=d.oid and d.datname=current_database()) where c.relname not like 'pg%' group by c.relname,b.isdirty order by 2 desc; relname | isdirty | buffers ---------+---------+--------- test | t | 1 (1 row) isdirty变为了t,说明是脏数据了。 来个检查点: test=# checkpoint; CHECKPOINT 再查一次: test=# select c.relname,b.isdirty, count(1) as buffers from pg_class c join pg_buffercache b on b.relfilenode=c.relfilenode inner join pg_database d on (b.reldatabase=d.oid and d.datname=current_database()) where c.relname not like 'pg%' group by c.relname,b.isdirty order by 2 desc; relname | isdirty | buffers ---------+---------+--------- test | f | 1 (1 row) 又不脏了。 有兴趣可以自己做实验玩。
pg_buffercache的更多相关文章
- 使用pg_buffercache查看缓存区缓存
PG提供了一个扩展pg_buffercache来查看缓存区的内容. create database test; CREATE DATABASE create extension pg_bufferca ...
- postgres安装pg_buffercache扩展
1.查看是否安装了pg_buffercache postgres=# \dx List of installed extensions Name | Version | Schema | Descri ...
- ERROR: relation "pg_buffercache" does not exist
创建pg_buffercache后,查询时报错: postgres=# create extension pg_buffercache; postgres=# select * from pg_buf ...
- PostgreSQL 磁盘使用大小监控
表大小信息 postgres=# SELECT *, pg_size_pretty(total_bytes) AS totalpostgres-# , pg_size_pretty(index_byt ...
- pg 资料大全1
https://github.com/ty4z2008/Qix/blob/master/pg.md?from=timeline&isappinstalled=0 PostgreSQL(数据库) ...
- 在CentOS上编译安装PostgreSQL
http://my.oschina.net/tashi/blog 第一步:准备阶段 获取必需软件包: CentOS中查看是否安装了某个软件的命令:rpm -qa | grep 软件名.which命令可 ...
- 深入理解Postgres中的cache
众所周知,缓存是提高数据库性能的一个重要手段.本文着重讲一讲PostgreSQL中的缓存相关的东西.当然万变不离其宗,原理都是共同的,理解了这些,你也很容易把它运用到其它数据库中. What is a ...
- # postgresql-shared_buffers
关于shared_buffers 什么是shred_buffer,我们为什么需要shared_buffers? 1.在数据库系统中,我们主要关注磁盘io,大多数oltp工作负载都是随机io,因此从磁盘 ...
- PostgreSQL 扩展开发基础教程
搭建基础结构 安装扩展 sudo apt-get install postgresql-contribcreatedb stupsql stucreate extension pg_buffercac ...
随机推荐
- beego——ORM使用方法
先来看一个简单示例: models.gp package main import ( "github.com/astaxie/beego/orm" ) type User stru ...
- Python(变量、数据类型)
常量:python中没有常量,只能通过名字特征来提示例如:全部大写,如 : OLDBOY_AGE=57 一.变量 变量声明变量#!/usr/bin/env python age=18gender1=' ...
- Mootools遮罩层练习(原为网上的jquery写法)
<html > <head> <meta charset="utf-8" /> <title>mootools 遮罩层</ti ...
- python selenium firefox使用
演示的版本信息如下: Python 3.6.0 Selenium 3.5.0 Firefox 55.0.3 geckodriver v1.0.18.0 win64 1.前提准备 1.1 安装pyth ...
- Javascript Array对象 sort()方法,记忆方法,方法扩展
相信 有很多 同仁们,尤其是初学者,在记住 Array对象 sort() 方法的排序,规则上,有点困难: 其实sort()方法已经在实际工作中用到很多遍了,可当我仔细推敲,这个sort()方法,什么时 ...
- Resharper 快捷键
编辑 Ctrl + Space 代码完成 Ctrl + Shift + Space代码完成 Ctrl + Alt + Space代码完成 Ctrl + P 显示参数信息 Alt + Insert ...
- Tomcat 线程池配置
线程池 Executor代表了一个线程池,可以在Tomcat组件之间共享.使用线程池的好处在于减少了创建销毁线程的相关消耗,而且可以提高线程的使用效率.要想使用线程池,首先需要在 Service标签中 ...
- 大牛是怎么思考设计MySQL优化方案的?
在进行MySQL的优化之前,必须要了解的就是MySQL的查询过程,很多查询优化工作实际上就是遵循一些原则,让MySQL的优化器能够按照预想的合理方式运行而已. 图-MySQL查询过程 一.优化的哲学 ...
- java-json与js-json转化
js中将字符串转换成json的三种方式http://www.jb51.net/article/25987.htm JAVA对象转换为JSON字符串 http://blog.163.com/zzf_fl ...
- BUG: scheduling while atomic 分析【转】
本文转载自:https://blog.csdn.net/cfy_phonex/article/details/12090943 遇到一个典型的schedule问题. <3>[26578 ...