PostgreSQL 特殊数据类型UUID & PG_LSN

1.UUID类型

UUID(Universally Unique Identifier)用于存储一个UUID。 UUID定义在RFC 4122和ISO/IEC 9834-8:2005中。它是一个128bit的数 字。

[postgres@postgres ~]$ 
[postgres@postgres ~]$ psql
psql (13.9)
Type "help" for help.

postgres=# select uuid '1b34eaba-0d59-11e4-bf51-dc85de4d74f3' < uuid '1e0e95b0-0d59-11e4-bf51-dc85de4d74f3';
 ?column? 
----------
 t
(1 row)

postgres=# 

2.pg_lsn类型

pg_lsn类型是PostgreSQL9.4以上版本提供的一种表示LSN(Log Sequence Number)的数据类型。LSN表示WAL日志的位置。一些记录 WAL日志信息的系统表中某些字段的类型就是pg_lsn类型,

postgres=# \d pg_stat_replication
                    View "pg_catalog.pg_stat_replication"
      Column      |           Type           | Collation | Nullable | Default 
------------------+--------------------------+-----------+----------+---------
 pid              | integer                  |           |          | 
 usesysid         | oid                      |           |          | 
 usename          | name                     |           |          | 
 application_name | text                     |           |          | 
 client_addr      | inet                     |           |          | 
 client_hostname  | text                     |           |          | 
 client_port      | integer                  |           |          | 
 backend_start    | timestamp with time zone |           |          | 
 backend_xmin     | xid                      |           |          | 
 state            | text                     |           |          | 
 sent_lsn         | pg_lsn                   |           |          | 
 write_lsn        | pg_lsn                   |           |          | 
 flush_lsn        | pg_lsn                   |           |          | 
 replay_lsn       | pg_lsn                   |           |          | 
 write_lag        | interval                 |           |          | 
 flush_lag        | interval                 |           |          | 
 replay_lag       | interval                 |           |          | 
 sync_priority    | integer                  |           |          | 
 sync_state       | text                     |           |          | 
 reply_time       | timestamp with time zone |           |          | 

postgres=# \d pg_replication_slots
             View "pg_catalog.pg_replication_slots"
       Column        |  Type   | Collation | Nullable | Default 
---------------------+---------+-----------+----------+---------
 slot_name           | name    |           |          | 
 plugin              | name    |           |          | 
 slot_type           | text    |           |          | 
 datoid              | oid     |           |          | 
 database            | name    |           |          | 
 temporary           | boolean |           |          | 
 active              | boolean |           |          | 
 active_pid          | integer |           |          | 
 xmin                | xid     |           |          | 
 catalog_xmin        | xid     |           |          | 
 restart_lsn         | pg_lsn  |           |          | 
 confirmed_flush_lsn | pg_lsn  |           |          | 
 wal_status          | text    |           |          | 
 safe_wal_size       | bigint  |           |          | 

postgres=#

在数据库内部,LSN是一个64bit的大整数,其输出类似如下格 式:

16/B374D848

pg_lsn类型可以使用基本的比较运算符,如“=”“>”“<”等, 两个pg_lsn的值可以相减,此时使用“-”运算符,相减所得的结果是 两个WAL日志相差的字节数

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值