当前位置:网站首页>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.
边栏推荐
- [CV-Learning] Semantic Segmentation
- 图像形变(插值方法)
- TensorFlow2 study notes: 4. The first neural network model, iris classification
- TensorRT 5 初步认识
- 安装dlib踩坑记录,报错:WARNING: pip is configured with locations that require TLS/SSL
- 逻辑回归---简介、API简介、案例:癌症分类预测、分类评估法以及ROC曲线和AUC指标
- 0, deep learning 21 days learning challenge 】 【 set up learning environment
- 两个APP进行AIDL通信
- Vision Transformer 论文 + 详解( ViT )
- The difference between oracle temporary table and pg temporary table
猜你喜欢

【CV-Learning】目标检测&实例分割

度量学习(Metric learning、损失函数、triplet、三元组损失、fastreid)

TensorFlow2 study notes: 7. Optimizer

RecyclerView的用法

YOLOV4流程图(方便理解)

MFC读取点云,只能正常显示第一个,显示后面时报错
![[CV-Learning] Convolutional Neural Network Preliminary Knowledge](/img/7d/58d9649b06e78eeb019d63615a90c4.png)
[CV-Learning] Convolutional Neural Network Preliminary Knowledge

Briefly say Q-Q map; stats.probplot (QQ map)

TensorFlow2学习笔记:8、tf.keras实现线性回归,Income数据集:受教育年限与收入数据集

典型CCN网络——efficientNet(2019-Google-已开源)
随机推荐
TensorFlow2 study notes: 4. The first neural network model, iris classification
Install dlib step pit record, error: WARNING: pip is configured with locations that require TLS/SSL
【深度学习21天学习挑战赛】2、复杂样本分类识别——卷积神经网络(CNN)服装图像分类
动手学深度学习_多层感知机
pytorch学习-没掌握的点
ValueError: Expected 96 from C header, got 88 from PyObject
sklearn中的pipeline机制
Android connects to mysql database using okhttp
线性回归简介01---API使用案例
The pipeline mechanism in sklearn
两个APP进行AIDL通信
JPEG2jpg
Matplotlib中的fill_between;np.argsort()函数
YOLOV5 V6.1 详细训练方法
Copy攻城狮5分钟在线体验 MindIR 格式模型生成
腾讯、网易纷纷出手,火到出圈的元宇宙到底是个啥?
MFC 打开与保存点云PCD文件
MFC读取点云,只能正常显示第一个,显示后面时报错
【CV-Learning】目标检测&实例分割
【go语言入门笔记】12、指针