@@ -923,7 +923,7 @@ erased (they will be recreated automatically as needed).
923
923
This section provides an overview of the page format used within
924
924
<productname>PostgreSQL</productname> tables and indexes.<footnote>
925
925
-->
926
- 本节提供一个在 <productname>PostgreSQL</productname>表和索引使用的页格式的概述 。<footnote>
926
+ 本节对 <productname>PostgreSQL</productname>中表和索引使用的页格式进行介绍 。<footnote>
927
927
<para>
928
928
<!--
929
929
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
932
932
the item layout rules.
933
933
-->
934
934
实际上,索引访问方法不需要使用这个页格式。所有已经存在的索引方法
935
- 需要使用基本格式,但是保持在索引元页上的数据通常不遵循项布局规则 。
935
+ 需要使用这些基本格式,但保存在索引元页中的数据通常不遵循这些项的布局规则 。
936
936
</para>
937
937
938
938
</footnote>
939
939
<!--
940
940
Sequences and <acronym>TOAST</> tables are formatted just like a regular table.
941
941
-->
942
- 序列和 <acronym>TOAST</>表的格式就像一个普通表的 。
942
+ 序列表和 <acronym>TOAST</>表的格式与普通表类似 。
943
943
</para>
944
944
945
945
<!--
@@ -953,7 +953,7 @@ an item is a row; in an index, an item is an index entry.
953
953
</para>
954
954
-->
955
955
<para>
956
- 下面说明一下,一个<firstterm>字节</firstterm>假定为包含8位 。另外,
956
+ 下面说明一下,一个<firstterm>字节</firstterm>假定为包含8个比特位 。另外,
957
957
术语<firstterm>项</firstterm>为存储在页上的一个独立数据值。
958
958
在表中,一项是一行;在索引中,一项为一个索引条目。
959
959
</para>
@@ -970,11 +970,11 @@ within the index, depending on the index access method.
970
970
</para>
971
971
-->
972
972
<para>
973
- 每个表和索引存储为固定大小的 <firstterm>页</>数组。
974
- (通常 8 kB,不过当编译服务器的时候,可以选择不同的页大小)
973
+ 每个表和索引存储为 <firstterm>页</>的数组,页的大小固定
974
+ (通常 8 kB,不过当编译服务器的时候,可以选择不同的页大小)。
975
975
在表中,所有的页是逻辑等价的,所以一个特殊项(行)
976
- 可以存储在任意页。在索引 ,第一页通常保留为持有控制信息的<firstterm>元页</>,
977
- 这里可以有不同类型的索引页,依赖于索引访问方法 。
976
+ 可以存储在任意页。在索引中 ,第一页通常保留为持有控制信息的<firstterm>元页</>,
977
+ 这里可以有不同类型的索引页,这依赖于索引访问方法 。
978
978
</para>
979
979
980
980
<!--
@@ -984,7 +984,7 @@ There are five parts to each page.
984
984
</para>
985
985
-->
986
986
<para>
987
- <xref linkend="page-table">显示一个页的整体布局,这里每页有5部分 。
987
+ <xref linkend="page-table">为一个页的整体布局,每页有5部分 。
988
988
</para>
989
989
990
990
<table tocentry="1" id="page-table">
@@ -1019,7 +1019,7 @@ Item
1019
1019
<entry>24 bytes long. Contains general information about the page, including
1020
1020
free space pointers.</entry>
1021
1021
-->
1022
- <entry>24字节长整型。包含关于页的一般信息,包含自由空间指针 。</entry>
1022
+ <entry>24字节长整型。包含关于页的一般信息,包括空闲空间指针 。</entry>
1023
1023
</row>
1024
1024
1025
1025
<row>
@@ -1037,7 +1037,7 @@ free space pointers.</entry>
1037
1037
<entry>The unallocated space. New item pointers are allocated from the start
1038
1038
of this area, new items from the end.</entry>
1039
1039
-->
1040
- <entry>未分配空间。从这个区域开始分配新项指针,或从结尾分配新项指针 </entry>
1040
+ <entry>未分配空间。从这个区域开始分配新项指针,从结尾开始分配新项。 </entry>
1041
1041
</row>
1042
1042
1043
1043
<row>
@@ -1054,7 +1054,7 @@ of this area, new items from the end.</entry>
1054
1054
<entry>Index access method specific data. Different methods store different
1055
1055
data. Empty in ordinary tables.</entry>
1056
1056
-->
1057
- <entry>索引访问方法专用数据。不同方法存储不同的数据。普通表里为空 。</entry>
1057
+ <entry>索引访问方法专用数据。不同方法存储不同的数据。对于普通表该区域为空 。</entry>
1058
1058
</row>
1059
1059
1060
1060
</tbody>
@@ -1094,20 +1094,19 @@ data. Empty in ordinary tables.</entry>
1094
1094
<para>
1095
1095
每页的前24个字节构成一个页头(PageHeaderData)。
1096
1096
在<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>,
1100
1100
和<structfield>pd_special</structfield>)。
1101
- 这些包含分别为从页开始到未分配空间的开始,到未分配空间的结束 ,
1102
- 专用空间的开始的偏移字节数。下边页头的2字节 ,pd_pagesize_version,
1101
+ 这些字段分别表示从页开始位置至未分配空间的开始,未分配空间的结束 ,
1102
+ 专用空间的开始处的偏移字节数。页头中随后的2字节 ,pd_pagesize_version,
1103
1103
存储页大小和版本指示符。 从<productname>PostgreSQL</productname> 8.3开始版本编号是4;
1104
1104
<productname>PostgreSQL</productname> 8.1和8.2使用版本编号3;
1105
1105
<productname>PostgreSQL</productname> 8.0使用版本编号2;
1106
1106
<productname>PostgreSQL</productname> 7.3和7.4使用版本编号1;
1107
- 先前发布版本使用版本编号0。(在大多数这些版本中,基本的页布局和头格式没有变化,但是堆布局有行头.)
1108
- 页面大小是基本上只存在一个交叉检查;在安装的版本中,
1109
- 这里不支持多于一页大小的。最后一个字段是个提示,显示是否整理页,
1110
- 可能是有利的。它跟踪在页上最旧的未修整的XMAX。
1107
+ 先前发布版本使用版本编号0。(在大多数这些版本中,基本的页布局和头格式没有变化,但是堆的行头有变化.)
1108
+ 页面的大小基本上只用于交叉检查;在安装的版本中,
1109
+ 不支持多种页面大小。最后一个字段是个提示,显示是否整理页可能是有利的,它跟踪该页上最旧的未整理的XMAX。
1111
1110
</para>
1112
1111
1113
1112
<table tocentry="1" id="pageheaderdata-table">
@@ -1141,7 +1140,7 @@ data. Empty in ordinary tables.</entry>
1141
1140
to this page</entry>
1142
1141
-->
1143
1142
<entry>8字节</entry>
1144
- <entry>LSN: 该页上xlog日志记录变化的最后字节的下一字节 </entry>
1143
+ <entry>LSN: 该页上最后的变化对应的xlog记录的最后字节的下一字节 </entry>
1145
1144
</row>
1146
1145
<row>
1147
1146
<entry>pd_tli</entry>
@@ -1151,7 +1150,7 @@ data. Empty in ordinary tables.</entry>
1151
1150
<entry>TimeLineID of last change (only its lowest 16 bits)</entry>
1152
1151
-->
1153
1152
<entry>2字节</entry>
1154
- <entry>最后变化的时间线ID (仅其最低16位)</entry>
1153
+ <entry>最后变化对应的时间线ID (仅其最低16位)</entry>
1155
1154
</row>
1156
1155
<row>
1157
1156
<entry>pd_flags</entry>
@@ -1167,7 +1166,7 @@ data. Empty in ordinary tables.</entry>
1167
1166
<entry>Offset to start of free space</entry>
1168
1167
-->
1169
1168
<entry>2字节</entry>
1170
- <entry>到自由空间开始的偏移量 </entry>
1169
+ <entry>到空闲空间开始处的偏移量 </entry>
1171
1170
</row>
1172
1171
<row>
1173
1172
<entry>pd_upper</entry>
@@ -1177,7 +1176,7 @@ data. Empty in ordinary tables.</entry>
1177
1176
<entry>Offset to end of free space</entry>
1178
1177
-->
1179
1178
<entry>2字节</entry>
1180
- <entry>到自由空间结尾的偏移量 </entry>
1179
+ <entry>到空闲空间结尾处的偏移量 </entry>
1181
1180
</row>
1182
1181
<row>
1183
1182
<entry>pd_special</entry>
@@ -1187,7 +1186,7 @@ data. Empty in ordinary tables.</entry>
1187
1186
<entry>Offset to start of special space</entry>
1188
1187
-->
1189
1188
<entry>2字节</entry>
1190
- <entry>到专用空间开始的偏移量 </entry>
1189
+ <entry>到专用空间开始处的偏移量 </entry>
1191
1190
</row>
1192
1191
<row>
1193
1192
<entry>pd_pagesize_version</entry>
@@ -1197,7 +1196,7 @@ data. Empty in ordinary tables.</entry>
1197
1196
<entry>Page size and layout version number information</entry>
1198
1197
-->
1199
1198
<entry>2字节</entry>
1200
- <entry>页大小和版本编号布局信息 </entry>
1199
+ <entry>页大小和布局版本号信息 </entry>
1201
1200
</row>
1202
1201
<row>
1203
1202
<entry>pd_prune_xid</entry>
@@ -1247,14 +1246,13 @@ data. Empty in ordinary tables.</entry>
1247
1246
</para>
1248
1247
-->
1249
1248
<para>
1250
- 下面的页头是项标识符 (<type>ItemIdData</type>),每个需要4字节 。
1249
+ 紧挨着页头的是项标识符 (<type>ItemIdData</type>),每个4字节 。
1251
1250
一个项标识符包含一个到项开始的字节偏移,
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>,是由页号和项标识符索引组成的。
1258
1256
</para>
1259
1257
1260
1258
<!--
@@ -1268,8 +1266,8 @@ data. Empty in ordinary tables.</entry>
1268
1266
</para>
1269
1267
-->
1270
1268
<para>
1271
- 项本身存储在从未分配的空间的结尾向后分配的空间 。确切的结构取决于包含什么表。
1272
- 表和序列两都使用一个名为 <type>HeapTupleHeaderData</type>的结构,下面描述。
1269
+ 项本身从未分配空间的结尾处开始反向存储 。确切的结构取决于包含什么表。
1270
+ 表和序列两者都使用一个名为 <type>HeapTupleHeaderData</type>的结构,下面描述。
1273
1271
</para>
1274
1272
1275
1273
<!--
@@ -1285,10 +1283,10 @@ data. Empty in ordinary tables.</entry>
1285
1283
</para>
1286
1284
-->
1287
1285
<para>
1288
- 最后这段是 <quote>特殊段</quote>其包含想存放的任何访问方法 。
1289
- 例如,b-tree索引存储连接页左右的兄弟,以及相应的索引结构的一些其它数据 。
1290
- 普通的表根本没有使用特殊段。
1291
- (通过设置<structfield>pd_special</>等于页大小来表示)
1286
+ 最后的段是 <quote>特殊段</quote>,其可以包含任何想存放访问方法 。
1287
+ 例如,b-tree索引存储指向该页左右兄弟的连接,以及相应索引结构的一些其它数据 。
1288
+ 普通表不使用特殊段
1289
+ (通过设置<structfield>pd_special</>等于页大小来表示)。
1292
1290
</para>
1293
1291
1294
1292
<!--
@@ -1319,17 +1317,16 @@ data. Empty in ordinary tables.</entry>
1319
1317
</para>
1320
1318
-->
1321
1319
<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位图才存在 。
1328
1326
如果它存在,它就开始于固定头的后面,占用足够的字节,每数据列一位。
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得到恰当的对齐)
1333
1330
</para>
1334
1331
1335
1332
<table tocentry="1" id="heaptupleheaderdata-table">
@@ -1382,7 +1379,7 @@ data. Empty in ordinary tables.</entry>
1382
1379
<entry>insert and/or delete CID stamp (overlays with t_xvac)</entry>
1383
1380
-->
1384
1381
<entry>4字节</entry>
1385
- <entry>插入和/或 删除 CID戳(使用t_xvac覆盖)</entry>
1382
+ <entry>插入和/或删除 CID戳(使用t_xvac覆盖)</entry>
1386
1383
</row>
1387
1384
<row>
1388
1385
<entry>t_xvac</entry>
@@ -1412,7 +1409,7 @@ data. Empty in ordinary tables.</entry>
1412
1409
<entry>number of attributes, plus various flag bits</entry>
1413
1410
-->
1414
1411
<entry>2字节</entry>
1415
- <entry>字段个数,加上各种标志位 </entry>
1412
+ <entry>字段个数,以及各种标志位 </entry>
1416
1413
</row>
1417
1414
<row>
1418
1415
<entry>t_infomask</entry>
@@ -1422,7 +1419,7 @@ data. Empty in ordinary tables.</entry>
1422
1419
<entry>various flag bits</entry>
1423
1420
-->
1424
1421
<entry>2字节</entry>
1425
- <entry>各种标志位数 </entry>
1422
+ <entry>各种标志位 </entry>
1426
1423
</row>
1427
1424
<row>
1428
1425
<entry>t_hoff</entry>
@@ -1464,11 +1461,11 @@ data. Empty in ordinary tables.</entry>
1464
1461
</para>
1465
1462
-->
1466
1463
<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>中 。
1472
1469
</para>
1473
1470
<!--
1474
1471
<para>
@@ -1487,12 +1484,12 @@ data. Empty in ordinary tables.</entry>
1487
1484
</para>
1488
1485
-->
1489
1486
<para>
1490
- 要读取数据你需要逐次检查每个属性。首先检查字段是否为NULL依据NULL位图。
1491
- 如果是,跳到下一个。 然后确定你已经右对齐。如果字段是固定宽度的字段 ,
1492
- 那么所有的字节简单的放置。 如果它是变长的字段(attlen = -1)
1487
+ 要读取数据你需要逐次检查每个属性。首先依据NULL位图检查字段是否为NULL,
1488
+ 如果是,跳到下一个, 然后确定你已经右对齐;如果字段是固定宽度的 ,
1489
+ 那么所有的字节被简单地放置, 如果它是变长的字段(attlen = -1)
1493
1490
那么它是一个更复杂的位。所有变长数据类型共享通用的头结构<type>struct varlena</type>,
1494
1491
其包括存储值的总长度和一些标志位。
1495
- 依赖这些标志,数据可能是行内或在一个 <acronym>TOAST</>表;它也可能是压缩的 。
1492
+ 依赖这些标志,可以判断数据是行内或在一个 <acronym>TOAST</>表,也可能是压缩的 。
1496
1493
(参阅<xref linkend="storage-toast">)
1497
1494
</para>
1498
1495
</sect1>
0 commit comments