当前位置:网站首页>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】Object Detection & Instance Segmentation
- 【深度学习21天学习挑战赛】0、搭建学习环境
- TensorFlow2学习笔记:6、过拟合和欠拟合,及其缓解方案
- TensorFlow2 study notes: 8. tf.keras implements linear regression, Income dataset: years of education and income dataset
- 安卓连接mysql数据库,使用okhttp
- 彻底搞懂箱形图分析
- TensorFlow2 study notes: 4. The first neural network model, iris classification
- 打金?工作室?账号被封?游戏灰黑产离我们有多近
- Qt日常学习
- SQL注入详解
猜你喜欢

Halcon缺陷检测

安卓连接mysql数据库,使用okhttp

Copy攻城狮信手”粘“来 AI 对对联

fill_between in Matplotlib; np.argsort() function

AIDL communication between two APPs

Jupyter Notebook installed library;ModuleNotFoundError: No module named 'plotly' solution.

tensorRT5.15 使用中的注意点

逻辑回归---简介、API简介、案例:癌症分类预测、分类评估法以及ROC曲线和AUC指标

度量学习(Metric learning)—— 基于分类损失函数(softmax、交叉熵、cosface、arcface)

fuser 使用—— YOLOV5内存溢出——kill nvidai-smi 无pid 的 GPU 进程
随机推荐
2020-10-19
Pytorch语义分割理解
Androd Day02
sklearn中的pipeline机制
【深度学习日记】第一天:Hello world,Hello CNN MNIST
【CV-Learning】Convolutional Neural Network
【深度学习21天学习挑战赛】2、复杂样本分类识别——卷积神经网络(CNN)服装图像分类
[Deep Learning 21 Days Learning Challenge] 2. Complex sample classification and recognition - convolutional neural network (CNN) clothing image classification
学习资料re-id
[Go language entry notes] 13. Structure (struct)
PP-LiteSeg
fill_between in Matplotlib; np.argsort() function
【CV-Learning】语义分割
Matplotlib中的fill_between;np.argsort()函数
Copy攻城狮的年度之“战”|回顾2020
Pytorch问题总结
光条提取中的连通域筛除
sklearn中的学习曲线learning_curve函数
图像合并水平拼接
Copy攻城狮5分钟在线体验 MindIR 格式模型生成