作者:瀚高PG实验室 (Highgo PG Lab)- 波罗
OID
对象标识符类型Object Identifier Types ,内部使用,并作为系统表的主键;
可以在用户定义的表中使用,默认oid不会添加到 用户自己创建的表里,除非指定 WITH OIDS 或者 default_with_oids 打开,oid是给内部表做标识用的,但不推荐使用;
因为oid本身大小固定的,万一 行数超过了oid 的最大限制数(4 byte int),那就无法插入新行了;
建议将 default_with_oids 设置为off, 建表的时候,如果想使用主键,请自行建立。
oid2name可以获取数据库、对象的OID
Oid2name示例:
[postgres@hgdb01 data]$ oid2name
All databases:
Oid Database Name Tablespace
----------------------------------
73780 bench pg_default
41002 jwdb pg_default
13295 postgres pg_default
13290 template0 pg_default
1 template1 pg_default
16384 testdb pg_default
[postgres@hgdb01 data]$ oid2name testdb
All databases:
Oid Database Name Tablespace
----------------------------------
73780 bench pg_default
41002 jwdb pg_default
13295 postgres pg_default
13290 template0 pg_default
1 template1 pg_default
16384 testdb pg_default
relfilenode
表或索引对象被创建后会生成以relfilenode编号命名的数据文件;
该文件有1G的大小限制,超过1G或生成新的文件(文件名后边加数字编号);
relfilenode标识对象物理位置的数字标号,会随数据存放的变化位置变化而变化;
函数pg_relation_filenode() 可以获得对象的relfilenode;
testdb=# select pg_relation_filenode('sampletbl');
pg_relation_filenode
----------------------
81993
(1 row)
以下表对象’sampletbl’所在的物理路径会包含relfilenode的编号
testdb=# select pg_relation_filepath('sampletbl');
pg_relation_filepath
----------------------
base/16384/81993
(1 row)
OID 与relfilenode的关系
oid 类似于 身份证号,
relfilenode 类似于 户口本上户号,只要人的住址变了,户号就会变
知识点:
When the file size of tables and indexes exceeds 1GB, PostgreSQL creates a new file named like relfilenode.1 and uses it. If the new file has been filled up, next new file named like relfilenode.2 will be created, and so on.
补充说明:
The maximum file size of tables and indexes can be changed using the configuration, option --with-segsize when building PostgreSQL