Skip to content

Commit c2ecb45

Browse files
committed
Update storage.sgml
校对58.6,数据库页的布局
1 parent 6445b52 commit c2ecb45

File tree

1 file changed

+59
-62
lines changed

1 file changed

+59
-62
lines changed

postgresql/doc/src/sgml/storage.sgml

Lines changed: 59 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,7 @@ erased (they will be recreated automatically as needed).
923923
This section provides an overview of the page format used within
924924
<productname>PostgreSQL</productname> tables and indexes.<footnote>
925925
-->
926-
本节提供一个在<productname>PostgreSQL</productname>表和索引使用的页格式的概述。<footnote>
926+
本节对<productname>PostgreSQL</productname>中表和索引使用的页格式进行介绍。<footnote>
927927
<para>
928928
<!--
929929
Actually, index access methods need not use this page format.
@@ -932,14 +932,14 @@ This section provides an overview of the page format used within
932932
the item layout rules.
933933
-->
934934
实际上,索引访问方法不需要使用这个页格式。所有已经存在的索引方法
935-
需要使用基本格式,但是保持在索引元页上的数据通常不遵循项布局规则
935+
需要使用这些基本格式,但保存在索引元页中的数据通常不遵循这些项的布局规则
936936
</para>
937937

938938
</footnote>
939939
<!--
940940
Sequences and <acronym>TOAST</> tables are formatted just like a regular table.
941941
-->
942-
序列和<acronym>TOAST</>表的格式就像一个普通表的
942+
序列表和<acronym>TOAST</>表的格式与普通表类似
943943
</para>
944944

945945
<!--
@@ -953,7 +953,7 @@ an item is a row; in an index, an item is an index entry.
953953
</para>
954954
-->
955955
<para>
956-
下面说明一下,一个<firstterm>字节</firstterm>假定为包含8位。另外,
956+
下面说明一下,一个<firstterm>字节</firstterm>假定为包含8个比特位。另外,
957957
术语<firstterm>项</firstterm>为存储在页上的一个独立数据值。
958958
在表中,一项是一行;在索引中,一项为一个索引条目。
959959
</para>
@@ -970,11 +970,11 @@ within the index, depending on the index access method.
970970
</para>
971971
-->
972972
<para>
973-
每个表和索引存储为固定大小的<firstterm>页</>数组。
974-
(通常 8 kB,不过当编译服务器的时候,可以选择不同的页大小)
973+
每个表和索引存储为<firstterm>页</>的数组,页的大小固定
974+
(通常 8 kB,不过当编译服务器的时候,可以选择不同的页大小)
975975
在表中,所有的页是逻辑等价的,所以一个特殊项(行)
976-
可以存储在任意页。在索引,第一页通常保留为持有控制信息的<firstterm>元页</>,
977-
这里可以有不同类型的索引页,依赖于索引访问方法
976+
可以存储在任意页。在索引中,第一页通常保留为持有控制信息的<firstterm>元页</>,
977+
这里可以有不同类型的索引页,这依赖于索引访问方法
978978
</para>
979979

980980
<!--
@@ -984,7 +984,7 @@ There are five parts to each page.
984984
</para>
985985
-->
986986
<para>
987-
<xref linkend="page-table">显示一个页的整体布局,这里每页有5部分
987+
<xref linkend="page-table">为一个页的整体布局,每页有5部分
988988
</para>
989989

990990
<table tocentry="1" id="page-table">
@@ -1019,7 +1019,7 @@ Item
10191019
<entry>24 bytes long. Contains general information about the page, including
10201020
free space pointers.</entry>
10211021
-->
1022-
<entry>24字节长整型。包含关于页的一般信息,包含自由空间指针。</entry>
1022+
<entry>24字节长整型。包含关于页的一般信息,包括空闲空间指针。</entry>
10231023
</row>
10241024

10251025
<row>
@@ -1037,7 +1037,7 @@ free space pointers.</entry>
10371037
<entry>The unallocated space. New item pointers are allocated from the start
10381038
of this area, new items from the end.</entry>
10391039
-->
1040-
<entry>未分配空间。从这个区域开始分配新项指针,或从结尾分配新项指针</entry>
1040+
<entry>未分配空间。从这个区域开始分配新项指针,从结尾开始分配新项。</entry>
10411041
</row>
10421042

10431043
<row>
@@ -1054,7 +1054,7 @@ of this area, new items from the end.</entry>
10541054
<entry>Index access method specific data. Different methods store different
10551055
data. Empty in ordinary tables.</entry>
10561056
-->
1057-
<entry>索引访问方法专用数据。不同方法存储不同的数据。普通表里为空。</entry>
1057+
<entry>索引访问方法专用数据。不同方法存储不同的数据。对于普通表该区域为空。</entry>
10581058
</row>
10591059

10601060
</tbody>
@@ -1094,20 +1094,19 @@ data. Empty in ordinary tables.</entry>
10941094
<para>
10951095
每页的前24个字节构成一个页头(PageHeaderData)。
10961096
在<xref linkend="pageheaderdata-table">有它的详细格式。
1097-
前两个字段跟踪相关页的最近的WAL条目
1098-
下边的一个2字节的字段是包含标志位
1099-
随后由3个2字节整数字段(<structfield>pd_lower</structfield>, <structfield>pd_upper</structfield>,
1097+
前两个字段跟踪该页最近的WAL条目
1098+
下边的一个2字节的字段包含标志位
1099+
随后有3个2字节整数字段(<structfield>pd_lower</structfield>, <structfield>pd_upper</structfield>,
11001100
和<structfield>pd_special</structfield>)。
1101-
这些包含分别为从页开始到未分配空间的开始,到未分配空间的结束
1102-
专用空间的开始的偏移字节数。下边页头的2字节,pd_pagesize_version,
1101+
这些字段分别表示从页开始位置至未分配空间的开始,未分配空间的结束
1102+
专用空间的开始处的偏移字节数。页头中随后的2字节,pd_pagesize_version,
11031103
存储页大小和版本指示符。 从<productname>PostgreSQL</productname> 8.3开始版本编号是4;
11041104
<productname>PostgreSQL</productname> 8.1和8.2使用版本编号3;
11051105
<productname>PostgreSQL</productname> 8.0使用版本编号2;
11061106
<productname>PostgreSQL</productname> 7.3和7.4使用版本编号1;
1107-
先前发布版本使用版本编号0。(在大多数这些版本中,基本的页布局和头格式没有变化,但是堆布局有行头.)
1108-
页面大小是基本上只存在一个交叉检查;在安装的版本中,
1109-
这里不支持多于一页大小的。最后一个字段是个提示,显示是否整理页,
1110-
可能是有利的。它跟踪在页上最旧的未修整的XMAX。
1107+
先前发布版本使用版本编号0。(在大多数这些版本中,基本的页布局和头格式没有变化,但是堆的行头有变化.)
1108+
页面的大小基本上只用于交叉检查;在安装的版本中,
1109+
不支持多种页面大小。最后一个字段是个提示,显示是否整理页可能是有利的,它跟踪该页上最旧的未整理的XMAX。
11111110
</para>
11121111

11131112
<table tocentry="1" id="pageheaderdata-table">
@@ -1141,7 +1140,7 @@ data. Empty in ordinary tables.</entry>
11411140
to this page</entry>
11421141
-->
11431142
<entry>8字节</entry>
1144-
<entry>LSN: 该页上xlog日志记录变化的最后字节的下一字节</entry>
1143+
<entry>LSN: 该页上最后的变化对应的xlog记录的最后字节的下一字节</entry>
11451144
</row>
11461145
<row>
11471146
<entry>pd_tli</entry>
@@ -1151,7 +1150,7 @@ data. Empty in ordinary tables.</entry>
11511150
<entry>TimeLineID of last change (only its lowest 16 bits)</entry>
11521151
-->
11531152
<entry>2字节</entry>
1154-
<entry>最后变化的时间线ID(仅其最低16位)</entry>
1153+
<entry>最后变化对应的时间线ID(仅其最低16位)</entry>
11551154
</row>
11561155
<row>
11571156
<entry>pd_flags</entry>
@@ -1167,7 +1166,7 @@ data. Empty in ordinary tables.</entry>
11671166
<entry>Offset to start of free space</entry>
11681167
-->
11691168
<entry>2字节</entry>
1170-
<entry>到自由空间开始的偏移量</entry>
1169+
<entry>到空闲空间开始处的偏移量</entry>
11711170
</row>
11721171
<row>
11731172
<entry>pd_upper</entry>
@@ -1177,7 +1176,7 @@ data. Empty in ordinary tables.</entry>
11771176
<entry>Offset to end of free space</entry>
11781177
-->
11791178
<entry>2字节</entry>
1180-
<entry>到自由空间结尾的偏移量</entry>
1179+
<entry>到空闲空间结尾处的偏移量</entry>
11811180
</row>
11821181
<row>
11831182
<entry>pd_special</entry>
@@ -1187,7 +1186,7 @@ data. Empty in ordinary tables.</entry>
11871186
<entry>Offset to start of special space</entry>
11881187
-->
11891188
<entry>2字节</entry>
1190-
<entry>到专用空间开始的偏移量</entry>
1189+
<entry>到专用空间开始处的偏移量</entry>
11911190
</row>
11921191
<row>
11931192
<entry>pd_pagesize_version</entry>
@@ -1197,7 +1196,7 @@ data. Empty in ordinary tables.</entry>
11971196
<entry>Page size and layout version number information</entry>
11981197
-->
11991198
<entry>2字节</entry>
1200-
<entry>页大小和版本编号布局信息</entry>
1199+
<entry>页大小和布局版本号信息</entry>
12011200
</row>
12021201
<row>
12031202
<entry>pd_prune_xid</entry>
@@ -1247,14 +1246,13 @@ data. Empty in ordinary tables.</entry>
12471246
</para>
12481247
-->
12491248
<para>
1250-
下面的页头是项标识符(<type>ItemIdData</type>),每个需要4字节
1249+
紧挨着页头的是项标识符(<type>ItemIdData</type>),每个4字节
12511250
一个项标识符包含一个到项开始的字节偏移,
1252-
以字节计的长度,和一些影响它解释的属性位。
1253-
新项标识符需要从未分配空间的开始分配。
1254-
可以通过查看<structfield>pd_lower</>来确定项标识符的数量,分配新的标示符,
1255-
其会增加。因为一个项标示符从来不移动直到释放了它,实际上,
1256-
每个指针为<productname>PostgreSQL</productname>所创建的一项由页号和项标识符的索引构成。
1257-
(<type>ItemPointer</type>,还可以称为<type>CTID</type>)。
1251+
其长度以字节计,和一些影响它解释的属性位。
1252+
新项标识符需要从未分配空间的开始处分配。
1253+
可以通过查看<structfield>pd_lower</>来确定项标识符的数量,分配新的项标识符时,
1254+
pd_lower会随之增加。因为一个项标识符从来不移动直到释放了它,即使为了紧凑空闲空间,项本身被移除,引用该项的索引可以长期被使用。实际上,
1255+
<productname>PostgreSQL</productname>创建的每个指向项的指针(<type>ItemPointer</type>,也称之为<type>CTID</type>,是由页号和项标识符索引组成的。
12581256
</para>
12591257

12601258
<!--
@@ -1268,8 +1266,8 @@ data. Empty in ordinary tables.</entry>
12681266
</para>
12691267
-->
12701268
<para>
1271-
项本身存储在从未分配的空间的结尾向后分配的空间。确切的结构取决于包含什么表。
1272-
表和序列两都使用一个名为<type>HeapTupleHeaderData</type>的结构,下面描述。
1269+
项本身从未分配空间的结尾处开始反向存储。确切的结构取决于包含什么表。
1270+
表和序列两者都使用一个名为<type>HeapTupleHeaderData</type>的结构,下面描述。
12731271
</para>
12741272

12751273
<!--
@@ -1285,10 +1283,10 @@ data. Empty in ordinary tables.</entry>
12851283
</para>
12861284
-->
12871285
<para>
1288-
最后这段是<quote>特殊段</quote>其包含想存放的任何访问方法
1289-
例如,b-tree索引存储连接页左右的兄弟,以及相应的索引结构的一些其它数据
1290-
普通的表根本没有使用特殊段。
1291-
(通过设置<structfield>pd_special</>等于页大小来表示)
1286+
最后的段是<quote>特殊段</quote>,其可以包含任何想存放访问方法
1287+
例如,b-tree索引存储指向该页左右兄弟的连接,以及相应索引结构的一些其它数据
1288+
普通表不使用特殊段
1289+
(通过设置<structfield>pd_special</>等于页大小来表示)
12921290
</para>
12931291

12941292
<!--
@@ -1319,17 +1317,16 @@ data. Empty in ordinary tables.</entry>
13191317
</para>
13201318
-->
13211319
<para>
1322-
所有表行结构方式相同。有个固定大小的头(在大多数机器占用23字节),
1323-
随后一个NULL位图的可选项,对象ID字段,和用户数据
1324-
该头的详细信息在<xref linkend="heaptupleheaderdata-table">。
1325-
实际的用户数据(行中列)由<structfield>t_hoff</>表示的偏移量开始,
1326-
它必须始终是为平台的MAXALIGN间距的倍数
1327-
NULL位图仅存在,如果在<structfield>t_infomask</structfield>设置了<firstterm>HEAP_HASNULL</firstterm>
1320+
所有表的行结构相同。有个固定大小的头(在大多数机器占用23字节),
1321+
随后一个可选的NULL位图项,对象ID字段和用户数据
1322+
该头的详细信息见<xref linkend="heaptupleheaderdata-table">。
1323+
实际的用户数据(行中的列)从<structfield>t_hoff</>表示的偏移量开始,
1324+
它必须始终是平台的MAXALIGN的倍数
1325+
仅在<structfield>t_infomask</structfield>设置了<firstterm>HEAP_HASNULL</firstterm>位时,NULL位图才存在
13281326
如果它存在,它就开始于固定头的后面,占用足够的字节,每数据列一位。
1329-
(那是,<structfield>t_natts</>位一块) 在这个位列表中,一个1位 标识非空,一个 0 位是空。
1330-
对象ID 仅存在,如果在<structfield>t_infomask</structfield>设置了<firstterm>HEAP_HASOID</firstterm>位。
1331-
如果存在,它将出现在t_hoff边界前。任何需要做 t_hoff 的MAXALIGN倍数的填充,
1332-
出现在NULL位图和对象ID之间。(反过来又保证对象ID得到恰当的对齐)
1327+
(总共<structfield>t_natts</>位) 在这个位列表中,1位表示非空, 0 表示空。
1328+
仅在<structfield>t_infomask</structfield>设置了<firstterm>HEAP_HASOID</firstterm>位时,对象ID 才存在。
1329+
如果存在,它将出现在t_hoff边界前。任何使 t_hoff 为MAXALIGN倍数的填充将出现在NULL位图和对象ID之间。(反过来又保证对象ID得到恰当的对齐)
13331330
</para>
13341331

13351332
<table tocentry="1" id="heaptupleheaderdata-table">
@@ -1382,7 +1379,7 @@ data. Empty in ordinary tables.</entry>
13821379
<entry>insert and/or delete CID stamp (overlays with t_xvac)</entry>
13831380
-->
13841381
<entry>4字节</entry>
1385-
<entry>插入和/或 删除 CID戳(使用t_xvac覆盖)</entry>
1382+
<entry>插入和/或删除 CID戳(使用t_xvac覆盖)</entry>
13861383
</row>
13871384
<row>
13881385
<entry>t_xvac</entry>
@@ -1412,7 +1409,7 @@ data. Empty in ordinary tables.</entry>
14121409
<entry>number of attributes, plus various flag bits</entry>
14131410
-->
14141411
<entry>2字节</entry>
1415-
<entry>字段个数,加上各种标志位</entry>
1412+
<entry>字段个数,以及各种标志位</entry>
14161413
</row>
14171414
<row>
14181415
<entry>t_infomask</entry>
@@ -1422,7 +1419,7 @@ data. Empty in ordinary tables.</entry>
14221419
<entry>various flag bits</entry>
14231420
-->
14241421
<entry>2字节</entry>
1425-
<entry>各种标志位数</entry>
1422+
<entry>各种标志位</entry>
14261423
</row>
14271424
<row>
14281425
<entry>t_hoff</entry>
@@ -1464,11 +1461,11 @@ data. Empty in ordinary tables.</entry>
14641461
</para>
14651462
-->
14661463
<para>
1467-
解释实际数据只能从其它表获取信息来做,大多<structname>pg_attribute</structname>
1468-
需要来表示字段位置的键值是<structfield>attlen</structfield>和<structfield>attalign</structfield>。
1469-
没有直接获取特定字段的方法,除仅当有固定宽度字段并且没有空值的情况外
1470-
所有这些策略封装在函数<firstterm>heap_getattr</firstterm><firstterm>fastgetattr</firstterm>
1471-
和<firstterm>heap_getsysattr</firstterm>。
1464+
对实际数据的解析只能通过从其它表获取信息来做,大多来自于<structname>pg_attribute</structname>
1465+
表示字段位置的键值是<structfield>attlen</structfield>和<structfield>attalign</structfield>。
1466+
没有直接获取特定字属性的方法,除非只有固定宽度的字段并且没有空值
1467+
所有这些策略被封装在函数<firstterm>heap_getattr</firstterm><firstterm>fastgetattr</firstterm>
1468+
和<firstterm>heap_getsysattr</firstterm>
14721469
</para>
14731470
<!--
14741471
<para>
@@ -1487,12 +1484,12 @@ data. Empty in ordinary tables.</entry>
14871484
</para>
14881485
-->
14891486
<para>
1490-
要读取数据你需要逐次检查每个属性。首先检查字段是否为NULL依据NULL位图。
1491-
如果是,跳到下一个然后确定你已经右对齐。如果字段是固定宽度的字段
1492-
那么所有的字节简单的放置。如果它是变长的字段(attlen = -1)
1487+
要读取数据你需要逐次检查每个属性。首先依据NULL位图检查字段是否为NULL,
1488+
如果是,跳到下一个然后确定你已经右对齐;如果字段是固定宽度的
1489+
那么所有的字节被简单地放置,如果它是变长的字段(attlen = -1)
14931490
那么它是一个更复杂的位。所有变长数据类型共享通用的头结构<type>struct varlena</type>,
14941491
其包括存储值的总长度和一些标志位。
1495-
依赖这些标志,数据可能是行内或在一个<acronym>TOAST</>表;它也可能是压缩的
1492+
依赖这些标志,可以判断数据是行内或在一个<acronym>TOAST</>表,也可能是压缩的
14961493
(参阅<xref linkend="storage-toast">)
14971494
</para>
14981495
</sect1>

0 commit comments

Comments
 (0)