zoukankan      html  css  js  c++  java
  • pg_current_xlog_insert_location、pg_current_xlog_location、pg_current_xlog_flush_location的含义

    os: centos 7.4
    postgresql: 9.6.10

    最近在看postgresql的管理函数时,看到下面这几个函数,研究了一下:

    pg_current_xlog_flush_location()    pg_lsn  Get current transaction log flush location
    pg_current_xlog_insert_location()   pg_lsn  Get current transaction log insert location
    pg_current_xlog_location()          pg_lsn  Get current transaction log write location
    pg_current_xlog_flush_location()    pg_lsn  得到当前的事务日志刷写位置
    pg_current_xlog_insert_location()   pg_lsn  获得当前事务日志插入位置
    pg_current_xlog_location()          pg_lsn  获得当前事务日志写入位置

    修改postgresql.conf 文件参数

    synchronous_commit = off
    wal_writer_delay = 200ms 

    插入数据,查看

    postgres=# create table tmp_t0 (c0 varchar(100),c1 varchar(100));
    CREATE TABLE
    postgres=# 
    postgres=# 
    postgres=# insert into tmp_t0 select md5(id::varchar),md5(id::varchar) from generate_series(1,1000000) as id;
    
    postgres=# x
    postgres=# select pg_current_xlog_insert_location(),
                      pg_current_xlog_location(),
                      pg_current_xlog_flush_location();
    -[ RECORD 1 ]-------------------+-----------
    pg_current_xlog_insert_location | 0/15062020
    pg_current_xlog_location        | 0/14C62000
    pg_current_xlog_flush_location  | 0/14800000

    可以看出:

    pg_current_xlog_insert_location | 0/15062020
    >=
    pg_current_xlog_location        | 0/14C62000
    >=
    pg_current_xlog_flush_location  | 0/14800000

    正确的理解应该是这样的:

    pg_current_xlog_insert_location() 写入 wal buffer 的位置
    pg_current_xlog_location()        writewal 文件的位置
    pg_current_xlog_flush_location()  wal 数据 flush 到磁盘的位置

    参考:
    https://www.postgresql.org/docs/9.6/static/functions-admin.html
    http://postgres.cn/docs/9.6/functions-admin.html

  • 相关阅读:
    mcstructs使用CMake生成Makefile文件
    打印man手册为pdf文件
    ubuntu安装wine之后进不了系统
    如何知道自己梦呓的内容
    Opencv step by step
    Opencv step by step
    树莓派实现只有一个按键的播放器
    virtualbox 打不开ubuntu解决
    wifi使用的一些误区
    Opencv step by step
  • 原文地址:https://www.cnblogs.com/ctypyb2002/p/9792899.html
Copyright © 2011-2022 走看看