zoukankan      html  css  js  c++  java
  • 对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=#

    脏数据确实产生了。

  • 相关阅读:
    UE4分支的Git Flow
    手机Soc芯片简介
    游戏性能指标
    UE3客户端加入DS过程
    stereoscopic 3D
    UDK脚本函数性能工具
    vs2015启动崩溃,wpfgfx_v0400.dll加载D3DCompiler_47.dll失败
    UDK命令
    三维图形渲染管线
    【SpringCloud】Spring Cloud Sleuth + Zipkin 服务调用链路追踪(二十五)
  • 原文地址:https://www.cnblogs.com/gaojian/p/2738682.html
Copyright © 2011-2022 走看看