PostgreSQL数据库表的内部结构

A page within a table contains three kinds of data described as follows:
- heap tuple(s) – A heap tuple is a record data itself. They are stacked in order from the bottom of the page. The internal structure of tuple is described in Section 5.2 and Chapter 9 as the knowledge of both Concurrency Control(CC) and WAL in PostgreSQL are required.
- line pointer(s) – A line pointer is 4 byte long and holds a pointer to each heap tuple. It is also called an item pointer.
- Line pointers form a simple array, which plays the role of index to the tuples. Each index is numbered sequentially from 1, and called offset number. When a new tuple is added to the page, a new line pointer is also pushed onto the array to point to the new one.
- header data – A header data defined by the structure PageHeaderData is allocated in the beginning of the page. It is 24 byte long and contains general information about the page. The major variables of the structure are described below.
- pd_lsn – This variable stores the LSN of XLOG record written by the last change of this page. It is an 8-byte unsigned integer, related to the WAL (Write-Ahead Logging) mechanism. The details are described in Chapter 9.
- pd_checksum – This variable stores the checksum value of this page. (Note that this variable is supported in version 9.3 or later; in earlier versions, this part had stored the timelineId of the page.)
- pd_lower, pd_upper – pd_lower points to the end of line pointers, and pd_upper to the beginning of the newest heap tuple.
- pd_special – This variable is for indexes. In the page within tables, it points to the end of the page. (In the page within indexes, it points to the beginning of special space which is the data area held only by indexes and contains the particular data according to the kind of index types such as B-tree, GiST, GiN, etc.)
An empty space between the end of line pointers and the beginning of the newest tuple is referred to as free space or hole.
To identify a tuple within the table, tuple identifier (TID) is internally used. A TID comprises a pair of values: the block number of the page that contains the tuple, and the offset number of the line pointer that points to the tuple. A typical example of its usage is index. See more detail in Section 1.4.2.
While the HeapTupleHeaderData structure contains seven fields, four fields are required in the subsequent sections.
- t_xmin holds the txid of the transaction that inserted this tuple.
- t_xmax holds the txid of the transaction that deleted or updated this tuple. If this tuple has not been deleted or updated, t_xmax is set to 0, which means INVALID.
- t_cid holds the command id (cid), which means how many SQL commands were executed before this command was executed within the current transaction beginning from 0. For example, assume that we execute three INSERT commands within a single transaction: 'BEGIN; INSERT; INSERT; INSERT; COMMIT;'. If the first command inserts this tuple, t_cid is set to 0. If the second command inserts this, t_cid is set to 1, and so on.
- t_ctid holds the tuple identifier (tid) that points to itself or a new tuple. tid, described in Section 1.3, is used to identify a tuple within a table. When this tuple is updated, the t_ctid of this tuple points to the new tuple; otherwise, the t_ctid points to itself.
引用:http://www.interdb.jp/pg/pgsql01.html
PostgreSQL数据库表的内部结构的更多相关文章
- mybatis使用注解往postgresql数据库表insert数据[主键自增]的写法
建表SQL: DROP TABLE IF EXISTS person; CREATE TABLE person( person_id serial PRIMARY KEY NOT NULL, pers ...
- Solr 4.4.0利用dataimporthandler导入postgresql数据库表
将数据库edbstore的edbtore schema下的customers表导入到solr 1. 首先查看customers表字段信息 edbstore=> \d customers Tabl ...
- PostgreSQL数据库表名的大小写实验
磨砺技术珠矶,践行数据之道,追求卓越价值回到上一级页面:PostgreSQL基础知识与基本操作索引页 回到顶级页面:PostgreSQL索引页[作者 高健@博客园 luckyjackgao@g ...
- PostgreSQL数据库中获取表主键名称
PostgreSQL数据库中获取表主键名称 一.如下表示,要获取teacher表的主键信息: select pg_constraint.conname as pk_name,pg_attribute. ...
- .netcore2.1 使用postgresql数据库,不能实现表的CRUD问题
PostgreSQL对表名.字段名都是区分大小写的.为了兼容其他的数据库程序代码的编写,推荐使用小写加_的方式,例如:swagger_info 我们使用.netcore连接postgresql数据库时 ...
- Java连接postgreSQL数据库,找不到表。
postgreSQL数据库遵守SQL标准,表名库名不区分大小写. 数据库中是存在 gongan_address_ALL的表的,但是执行下列代码就会出错. stmt = c.createStatemen ...
- 数据库并发事务控制四:postgresql数据库的锁机制二:表锁 <转>
在博文<数据库并发事务控制四:postgresql数据库的锁机制 > http://blog.csdn.net/beiigang/article/details/43302947 中后面提 ...
- PostgreSQL介绍以及如何开发框架中使用PostgreSQL数据库
最近准备下PostgreSQL数据库开发的相关知识,本文把总结的PPT内容通过博客记录分享,本随笔的主要内容是介绍PostgreSQL数据库的基础信息,以及如何在我们的开发框架中使用PostgreSQ ...
- 对于多个数据库表对应一个Model问题的思考
最近做项目遇到一个场景,就是客户要求为其下属的每一个分支机构建一个表存储相关数据,而这些表的结构都是一样的,只是分属于不同的机构.这个问题抽象一下就是多个数据库表对应一个Model(或者叫实体类).有 ...
随机推荐
- viewport的相关知识点
主要说一些viewport的基本原理以及使用 ㈠概念 手机浏览器是把页面放在一个虚拟的“窗口”(viewport)中,通常这个虚拟的“窗口”(viewport)比屏幕宽,这样就不用把每个网页挤到很小的 ...
- Trie树(字典树)整理
字典树 (Trie) 用于存储字符串.树的每条边恰好表示一个字符,每个节点代表从根到该节点的路径所对应的字符串. 简介与操作实现可见蓝书P82~83. Trie字典树很好地利用了前缀,节省了很多空间. ...
- BZOJ 4849 [NEERC2016]Mole Tunnels (模拟费用流)
题目链接 https://www.lydsy.com/JudgeOnline/problem.php?id=4849 题解 其实也是模拟费用流,但是这道题和一般的题目不一样,这道题是在一个完全二叉树上 ...
- input选择框默认样式修改
input选择框是无法直接修改样式,我们只能间接来改变它样式. 原理:用图片来代替原来的input选择框,原来的input选择框定位到图片上方并让它opacity为0,鼠标点击时用js来改变图片,这样 ...
- [清华集训2016]温暖会指引我们前行——LCT+最大生成树
题目链接: [清华集训2016]温暖会指引我们前行 题目大意:有$n$个点$m$次操作,每次操作分为三种:1.在$u,v$两点之间连接一条编号为$id$,长度为$l$,温度为$t$的边.2.查询从$u ...
- 安卓项目集成objectbox-java数据库框架教程(非关系型)
objectbox数据库是greenrobot团队开发的全新非关系型数据库框架,该团队还开发过greenDao,EventBus等热门框架,objectbox可能是第一次听说,但是greenDao,E ...
- C++入门经典-例2.8-输出整数,控制打印格式
1:代码如下: // 2.8.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream> #incl ...
- opencv_将图像上的4个点按逆时针排序
1:代码如下: #include "stdafx.h" #include "cxcore.h" #include "cvcam.h" #in ...
- shiro的Quickstart
/** * Simple Quickstart application showing how to use Shiro's API. * * @since 0.9 RC2 */ public cla ...
- 网络1911、1912 C语言第2次作业--循环结构 批改总结
一.评分规则 伪代码务必是文字+代码描述,直接反应代码,每题扣1分 提交列表没内容,或者太简单,每题得分0分.注意选择提交列表长的题目介绍. 代码格式不规范,继续扣分. 代码互评,内容简单,0分. 原 ...