其他分享
首页 > 其他分享> > pg mvcc

pg mvcc

作者:互联网

Session A:
mydb=# select * from car;
id | name
----+------
1 | aa
2 | bb
(2 rows)
Time: 0.264 ms
mydb=# begin;
BEGIN
Time: 0.069 ms
mydb=*# delete from car;
DELETE 2
Time: 0.227 ms
mydb=*# select pg_current_xact_id();
pg_current_xact_id
--------------------
810
(1 row)
Time: 0.162 ms
mydb=*# select ctid,xmin,xmax,* from car;
ctid | xmin | xmax | id | name
------+------+------+----+------
(0 rows)
Time: 0.132 ms
mydb=*# select pg_current_xact_id();
pg_current_xact_id
--------------------
810
(1 row)
Time: 0.098 ms

mydb=*# commit;
COMMIT
Time: 5.824 ms
mydb=# select ctid,xmin,xmax,* from car;
ctid | xmin | xmax | id | name
------+------+------+----+------
(0 rows)
Time: 0.210 ms
mydb=# select pg_current_xact_id();
pg_current_xact_id
--------------------
814
(1 row)

 

Session B:

 

mydb=# select pg_current_xact_id();
pg_current_xact_id
--------------------
813
(1 row)

 

Time: 0.210 ms
mydb=# select ctid,xmin,xmax,* from car;
ctid | xmin | xmax | id | name
-------+------+------+----+------
(0,2) | 809 | 810 | 1 | aa
(0,3) | 809 | 810 | 2 | bb
(2 rows)

 

Time: 0.417 ms
mydb=# select ctid,xmin,xmax,* from car;
ctid | xmin | xmax | id | name
------+------+------+----+------
(0 rows)

 

Time: 0.201 ms
mydb=# select pg_current_xact_id();
pg_current_xact_id
--------------------
815
(1 row)

 

Time: 0.598 ms

 

标签:msmydb,current,pg,mvcc,xact,id,select
来源: https://www.cnblogs.com/chinaops/p/16490268.html