当前位置:网站首页>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.
边栏推荐
- 【论文阅读】SPANET: SPATIAL PYRAMID ATTENTION NETWORK FOR ENHANCED IMAGE RECOGNITION
- TensorFlow2学习笔记:6、过拟合和欠拟合,及其缓解方案
- Data reading in yolov3 (1)
- TensorFlow2 study notes: 5. Common activation functions
- 空洞卷积
- yolov3 data reading (2)
- 数据库的简述与常用操作指南
- Linear Regression 02---Boston Housing Price Prediction
- 【代码学习】
- Unity ML-agents 参数设置解明
猜你喜欢

Android connects to mysql database using okhttp

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

No matching function for call to ‘RCTBridgeModuleNameForClass‘

TensorRT 5 初步认识

fill_between in Matplotlib; np.argsort() function

Deep Adversarial Decomposition: A Unified Framework for Separating Superimposed Images

动手学深度学习_多层感知机

深度学习,“粮草”先行--浅谈数据集获取之道

线性回归简介01---API使用案例

图像形变(插值方法)
随机推荐
fill_between in Matplotlib; np.argsort() function
双向LSTM
TensorFlow2 study notes: 7. Optimizer
Attention Is All You Need(Transformer)
基于BiGRU和GAN的数据生成方法
安卓连接mysql数据库,使用okhttp
逻辑回归---简介、API简介、案例:癌症分类预测、分类评估法以及ROC曲线和AUC指标
字典特征提取,文本特征提取。
线性回归02---波士顿房价预测
YOLOV5 V6.1 详细训练方法
Thread 、Handler和IntentService的用法
Usage of RecyclerView
审稿意见回复
Copy攻城狮5分钟在线体验 MindIR 格式模型生成
线性回归简介01---API使用案例
Android connects to mysql database using okhttp
android基础 [超级详细android存储方式解析(SharedPreferences,SQLite数据库存储)]
典型CCN网络——efficientNet(2019-Google-已开源)
基于PyTorch的FCN-8s语义分割模型搭建
【CV-Learning】图像分类