pg_export_snapshot函数
psql (14.3)
Type "help" for help.
postgres=# \df+ pg_export_snapshot
List of functions
Schema | Name | Result data type | Argument data types | Type | Volatility | Parallel | Owner | Security | Access privileges | Language | Source code | Description
------------+--------------------+------------------+---------------------+------+------------+----------+----------+----------+-------------------+----------+--------------------+-------------------
pg_catalog | pg_export_snapshot | text | | func | volatile | unsafe | postgres | invoker | | internal | pg_export_snapshot | export a snapshot
(1 row)
postgres=# \c tt;
You are now connected to database "tt" as user "postgres".
tt=# begin TRANSACTION ISOLATION LEVEL REPEATABLE READ;
BEGIN
Time: 0.150 ms
tt=*# select * from t1 limit 10;
id | name
----+-----------
1 | 1_andyxi
2 | 2_andyxi
3 | 3_andyxi
4 | 4_andyxi
5 | 5_andyxi
6 | 6_andyxi
7 | 7_andyxi
8 | 8_andyxi
9 | 9_andyxi
10 | 10_andyxi
(10 rows)
Time: 0.529 ms
tt=*# select pg_export_snapshot(); ####查看当前快照
pg_export_snapshot
---------------------
00000004-00000118-1
(1 row)
Time: 0.290 ms
[postgres@harbor pg_snapshots]$ ls -la
总用量 8
drwx------ 2 postgres postgres 33 9月 12 11:30 .
drwx------ 20 postgres postgres 4096 9月 12 10:09 ..
-rw------- 1 postgres postgres 89 9月 12 11:30 00000004-00000118-1 ###当前快照在/pgccc/pgdata/pg_snapshots目录下可以查看。
[postgres@harbor pg_snapshots]$ pwd
/pgccc/pgdata/pg_snapshots
[postgres@harbor pg_snapshots]$
1.适用于REPEATABLE READ和SERIALIZABLE事务中。
2.在另一会话中我们可以导入这个快照。
tt=# BEGIN TRANSACTION ISOLATION LEVEL REPEATABLE READ ;
BEGIN
Time: 0.060 ms
tt=*# set transaction SNAPSHOT '00000004-0000011D-1';
SET
Time: 0.147 ms
tt=*# show tra
trace_notify trace_sort track_activity_query_size track_counts track_io_timing transaction_deferrable transaction_read_only
trace_recovery_messages track_activities track_commit_timestamp track_functions track_wal_io_timing transaction_isolation transform_null_equals
tt=*# show transaction_isolation
-#;
transaction_isolation
-----------------------
repeatable read
(1 row)
Time: 0.510 ms
tt=*# \q
[postgres@harbor pg_snapshots]$ ls -la
总用量 8
drwx------ 2 postgres postgres 33 9月 12 11:45 .
drwx------ 20 postgres postgres 4096 9月 12 10:09 ..
-rw------- 1 postgres postgres 89 9月 12 11:45 00000004-0000011D-1
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 葡萄城 AI 搜索升级:DeepSeek 加持,客户体验更智能
· 什么是nginx的强缓存和协商缓存
· 一文读懂知识蒸馏
2018-09-12 内存刷新机制
2018-09-12 MySQL内存结构
2018-09-12 show global status