对pg_buffercache 的利用实验

先看有没有脏数据:

postgres=# select isdirty from pg_buffercache where isdirty='t';
isdirty 
---------
(0 rows)

此时尚未有脏数据。

进一步确认:

postgres=# select count(*) from pg_buffercache where isdirty='f';
count 
-------
180
(1 row)

postgres=# select count(*) from pg_buffercache where isdirty='t';
count 
-------
0
(1 row)

为f 的个数是180, 为t的个数仍然为零。

postgres=# select count(*) from pg_buffercache;
count 
-------
4096
(1 row)

有一部分数据是空的。这可能象征着buffer中尚未被使用的数据区域。

建表,插入数据, 再看有没有脏数据,这是有了17条。

但是一旦关联 pg_class, 发现一条也无,估计是一些内部数据,暂时不理:

postgres=# create table testtab(id integer, val varchar(10));
CREATE TABLE
postgres=# insert into testtab values(1,'12345');
INSERT 0 1
postgres=# select count(*) from pg_buffercache where isdirty='t';
count 
-------
17
(1 row)

 


postgres=# select c.relname from pg_buffercache b, pg_class c where b.relfilenode=c.relfilenode and b.isdirty='t';
relname 
---------
(0 rows)

postgres=# select c.relname from pg_buffercache b, pg_class c where b.relfilenode=c.relfilenode;
relname 
-----------------------------------
pg_statistic
pg_statistic
pg_amop_fam_strat_index
pg_amop_fam_strat_index
pg_amop_fam_strat_index
pg_amop_opr_fam_index
pg_amop_opr_fam_index
pg_amop_opr_fam_index
pg_amproc_fam_proc_index
pg_amproc_fam_proc_index
pg_amproc_fam_proc_index
pg_aggregate_fnoid_index
pg_aggregate_fnoid_index
pg_cast_source_target_index
pg_cast_source_target_index
testtab
pg_index_indrelid_index
pg_index_indrelid_index
pg_index_indexrelid_index
pg_index_indexrelid_index
pg_operator_oid_index

.....

再来修改数据,看脏数据有否:

postgres=# select * from testtab;
id | val 
----+-------
1 | 12345
(1 row)

postgres=# update testtab set val='45678' where id=1;
UPDATE 1
postgres=# select c.relname from pg_buffercache b, pg_class c where b.relfilenode=c.relfilenode and b.isdirty='t';
relname 
---------
testtab
(1 row)

postgres=#

脏数据确实产生了。






本文转自健哥的数据花园博客园博客,原文链接:http://www.cnblogs.com/gaojian/archive/2012/10/25/2738682.html,如需转载请自行联系原作者

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值