当前位置:网站首页>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.
边栏推荐
- 浅谈游戏音效测试点
- 动手学深度学习_softmax回归
- yoloV5 使用——训练速度慢,加速训练
- 多项式回归(PolynomialFeatures)
- 属性动画的用法 以及ButterKnife的用法
- 逻辑回归---简介、API简介、案例:癌症分类预测、分类评估法以及ROC曲线和AUC指标
- The use of the attribute of the use of the animation and ButterKnife
- 【CV-Learning】Convolutional Neural Network
- TensorFlow2 study notes: 5. Common activation functions
- Simple and clear, the three paradigms of database design
猜你喜欢

【论文阅读】Multi-View Spectral Clustering with Optimal Neighborhood Laplacian Matrix

Vision Transformer 论文 + 详解( ViT )

Install dlib step pit record, error: WARNING: pip is configured with locations that require TLS/SSL

Qt日常学习

MAE 论文《Masked Autoencoders Are Scalable Vision Learners》

【深度学习21天学习挑战赛】备忘篇:我们的神经网模型到底长啥样?——model.summary()详解

图像形变(插值方法)

语音驱动嘴型与面部动画生成的现状和趋势

详解近端策略优化

Halcon缺陷检测
随机推荐
Transformer
Dictionary feature extraction, text feature extraction.
TensorFlow2 study notes: 4. The first neural network model, iris classification
yolov3 data reading (2)
DeblurGAN-v2: Deblurring (Orders-of-Magnitude) Faster and Better 图像去模糊
Use of double pointers
Introduction of linear regression 01 - API use cases
【go语言入门笔记】13、 结构体(struct)
【论文阅读】Multi-View Spectral Clustering with Optimal Neighborhood Laplacian Matrix
强化学习中,Q-Learning与Sarsa的差别有多大?
Learning curve learning_curve function in sklearn
【深度学习21天学习挑战赛】3、使用自制数据集——卷积神经网络(CNN)天气识别
tensorRT教程——tensor RT OP理解(实现自定义层,搭建网络)
Pytorch问题总结
【论文阅读】Exploring Spatial Significance via Hybrid Pyramidal Graph Network for Vehicle Re-identificatio
TensorFlow2学习笔记:4、第一个神经网模型,鸢尾花分类
两个APP进行AIDL通信
[Deep Learning 21 Days Learning Challenge] 2. Complex sample classification and recognition - convolutional neural network (CNN) clothing image classification
Usage of RecyclerView
TensorFlow2学习笔记:5、常用激活函数