暂无图片
pg中的行锁的存放地方再那里?
我来答
分享
暂无图片 匿名用户
pg中的行锁的存放地方再那里?

PostgreSQL被设计成不在内存中记录行锁信息 ,那么存储再那里行锁?

我来答
添加附件
收藏
分享
问题补充
1条回答
默认
最新
小满未满、

有一个函数pg_lock_status

基于这个函数有一个视图pg_locks 就是简单封装了这个函数 

CREATE OR REPLACE VIEW pg_catalog.pg_locks AS
 SELECT locktype,
    database,
    relation,
    page,
    tuple,
    virtualxid,
    transactionid,
    classid,
    objid,
    objsubid,
    virtualtransaction,
    pid,
    mode,
    granted,
    fastpath,
    waitstart
   FROM pg_lock_status() l(locktype, database, relation, page, tuple, virtualxid, transactionid, classid, objid, objsubid, virtualtransaction, pid, mode, granted, fastpath, waitstart)

你查看这个函数或者视图就可以看到相关锁的信息 比方说行锁信息

postgres=# select * from pg_locks;
  locktype  | database | relation | page | tuple | virtualxid | transactionid | classid | objid | objsubid | virtualtransaction |   pid   |      mode       | granted
 | fastpath | waitstart 
------------+----------+----------+------+-------+------------+---------------+---------+-------+----------+--------------------+---------+-----------------+--------
-+----------+-----------
 relation   |        5 |    12073 |      |       |            |               |         |       |          | 0/6                | 1427656 | AccessShareLock | t      
 | t        | 
 virtualxid |          |          |      |       | 0/6        |               |         |       |          | 0/6                | 1427656 | ExclusiveLock   | t      
 | t        | 
 relation   |        5 |    41746 |      |       |            |               |         |       |          | 1/2                | 1427834 | RowShareLock    | t      
 | t        | 
 relation   |        5 |    41741 |      |       |            |               |         |       |          | 1/2                | 1427834 | RowShareLock    | t      
 | t        | 
 virtualxid |          |          |      |       | 1/2        |               |         |       |          | 1/2                | 1427834 | ExclusiveLock   | t      
 | t        | 
(5 rows)
暂无图片 评论
暂无图片 有用 2
回答交流
提交
问题信息
请登录之后查看
邀请回答
暂无人订阅该标签,敬请期待~~
暂无图片墨值悬赏