当前位置:网站首页>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.
边栏推荐
- 动手学深度学习_卷积神经网络CNN
- Lee‘s way of Deep Learning 深度学习笔记
- 强化学习中,Q-Learning与Sarsa的差别有多大?
- 【CV-Learning】图像分类
- 【论文阅读】Multi-View Spectral Clustering with Optimal Neighborhood Laplacian Matrix
- 简单说Q-Q图;stats.probplot(QQ图)
- MySQL leftmost prefix principle [I understand hh]
- Copy攻城狮5分钟在线体验 MindIR 格式模型生成
- JPEG2jpg
- 线性回归02---波士顿房价预测
猜你喜欢

深度确定性策略梯度(DDPG)

【深度学习日记】第一天:Hello world,Hello CNN MNIST

target has libraries with conflicting names: libcrypto.a and libssl.a.

【论文阅读】SPANET: SPATIAL PYRAMID ATTENTION NETWORK FOR ENHANCED IMAGE RECOGNITION

Polynomial Regression (PolynomialFeatures)

TensorFlow2 study notes: 4. The first neural network model, iris classification

浅谈外挂常识和如何防御

TensorFlow2 study notes: 5. Common activation functions
![[Deep Learning 21 Days Learning Challenge] 2. Complex sample classification and recognition - convolutional neural network (CNN) clothing image classification](/img/5f/e5db59bdca19b275b2139020ebc6ea.png)
[Deep Learning 21 Days Learning Challenge] 2. Complex sample classification and recognition - convolutional neural network (CNN) clothing image classification
![[Introduction to go language] 12. Pointer](/img/c8/4489993e66f1ef383ce49c95d78b1f.png)
[Introduction to go language] 12. Pointer
随机推荐
动手学深度学习_softmax回归
Pytorch语义分割理解
Polynomial Regression (PolynomialFeatures)
逻辑回归---简介、API简介、案例:癌症分类预测、分类评估法以及ROC曲线和AUC指标
Halcon缺陷检测
动手学深度学习_多层感知机
android基础 [超级详细android存储方式解析(SharedPreferences,SQLite数据库存储)]
动手学深度学习_线性回归
pytorch学习-没掌握的点
Lee‘s way of Deep Learning 深度学习笔记
No matching function for call to ‘RCTBridgeModuleNameForClass‘
【论文阅读】SPANET: SPATIAL PYRAMID ATTENTION NETWORK FOR ENHANCED IMAGE RECOGNITION
sklearn中的pipeline机制
动手学深度学习_卷积神经网络CNN
Various commands such as creating a new user in postgresql
Thread 、Handler和IntentService的用法
【go语言入门笔记】13、 结构体(struct)
Linear Regression 02---Boston Housing Price Prediction
空洞卷积
WARNING: sql version 9.2, server version 11.0. Some psql features might not work.