当前位置:网站首页>Postgresql snapshot
Postgresql snapshot
2022-08-04 06:15:00 【Big Yellow Cat No. 1】
http://www.chensj.cn/article/postgresql-source-code-analysis-big-picture/
PostGreSQL adopts "snapshot" method to realize MVCC.Specifically, this means that queries in each transaction can only see:
1. Data changes made by transactions that have been committed before the transaction was started.
2. Changes made by queries preceding this query in the current transaction.
PostGreSQL obtains a current database snapshot for each transaction when the transaction starts. The data structure in the snapshot is as follows:
typedef struct SnapshotData
{
SnapshotSatisfiesFunc satisfies; /*Row test function pointer*/
TransactionId xmin; /* All transaction changes with id less than xmin are visible in the current snapshot*/
TransactionId xmax;visible*/
uint32 xcnt; /* count of running transactions */
TransactionId *xip; /* id list of all running transactions */
/* note: all idsin xip[] satisfy xmin <= xip[i] < xmax */
int32 subxcnt; /* # of xact ids in subxip[], -1 if overflow */
TransactionId *subxip;* array of subxact IDs in progress */
commandId curcid; /* in my xact, CID < curcid are visible */
uint32 active_count; /* refcount on ActiveSnapshot/stack */
uint32 regd_count;refcount on RegisteredSnapshotList */
bool copied; /* false if it's a static snapshot */
} SnapshotData;
When a transaction is started, the snapshot is to record the visible TransactionID of the transaction, excluding the invisible ID.Each version of the data in PostGreSQL has two IDs, one of which is CreationID, which is the TransactionID that inserts the data, and the other is ExpiredID, which is the TransactionID that deletes or updates the data.The ID of the data visible to a Transaction must meet the following conditions:
1.CreationID
Transaction starts the process of forming a snapshot:
Traverse all currently active Transactions and record them in an active Transaction ID array; according to the transaction order, select the smallest TransactionID visible to the current Transaction, record it in xmin, select the largest visible TransactionID, and record it in xmax.
边栏推荐
- 【论文阅读】Further Non-local and Channel Attention Networks for Vehicle Re-identification
- 软著撰写注意事项
- 【论文阅读】Multi-View Spectral Clustering with Optimal Neighborhood Laplacian Matrix
- Dictionary feature extraction, text feature extraction.
- 动手学深度学习_softmax回归
- 简单明了,数据库设计三大范式
- 审稿意见回复
- Lee‘s way of Deep Learning 深度学习笔记
- Usage of RecyclerView
- thymeleaf中 th:href使用笔记
猜你喜欢
【深度学习21天学习挑战赛】备忘篇:我们的神经网模型到底长啥样?——model.summary()详解
【深度学习21天学习挑战赛】0、搭建学习环境
TensorFlow2 study notes: 8. tf.keras implements linear regression, Income dataset: years of education and income dataset
度量学习(Metric learning)—— 基于分类损失函数(softmax、交叉熵、cosface、arcface)
剪映专业版字幕导出随笔
【CV-Learning】卷积神经网络
sklearn中的pipeline机制
【CV-Learning】图像分类
动手学深度学习__张量
[CV-Learning] Convolutional Neural Network Preliminary Knowledge
随机推荐
基于BiGRU和GAN的数据生成方法
两个APP进行AIDL通信
图像形变(插值方法)
【深度学习21天学习挑战赛】3、使用自制数据集——卷积神经网络(CNN)天气识别
MFC 打开与保存点云PCD文件
简单明了,数据库设计三大范式
Copy攻城狮的年度之“战”|回顾2020
【论文阅读】Exploring Spatial Significance via Hybrid Pyramidal Graph Network for Vehicle Re-identificatio
SQL注入详解
MySQL leftmost prefix principle [I understand hh]
read and study
【CV-Learning】语义分割
【CV-Learning】卷积神经网络预备知识
Simple and clear, the three paradigms of database design
卷积神经网络入门详解
Install dlib step pit record, error: WARNING: pip is configured with locations that require TLS/SSL
语音驱动嘴型与面部动画生成的现状和趋势
TypeError: load() missing 1 required positional argument: ‘Loader‘
空洞卷积
字典特征提取,文本特征提取。