暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

postgresql数据文件

原创 Oracle 2022-11-20
404


数据文件
在数据库创建的数据文件对象,如表、索引、视图、函数、序列等都会以文件存储。它们会在创建时被分配一个OID命名,对于大小超过1GB的表数据文件,PostgreSQL会自动将其切分为多个文件来存储,切分出的文件用OID.<顺序号>来命名。不过表文件并不是总是"OID.<顺序号>"命名,实际上真正管理表文件的时pg_class表中的relfilenode字段值,在新创建对象时会在pg_class系统表中插入该表的记录,默认会以OID作为relfilenode值,但经过几次VACUUM、TRUNCATE操作之后,relfilenode值会发生变化。

postgres=# \d
        List of relations
 Schema | Name | Type  |  Owner   
--------+------+-------+----------
 public | test | table | postgres
(1 row)

postgres=# select oid,relfilenode from pg_class where relname = 'test';
  oid  | relfilenode 
-------+-------------
 16384 |       16384
(1 row)

postgres=# truncate test;
TRUNCATE TABLE
postgres=# checkpoint;
CHECKPOINT
postgres=# select oid,relfilenode from pg_class where relname = 'test';
  oid  | relfilenode 
-------+-------------
 16384 |       16399
(1 row)

postgres=# INSERT INTO test(id,name) SELECT n,n || '_francs' from generate_series(1,50000000) n;
INSERT 0 50000000
postgres=# \dt+ test
                    List of relations
 Schema | Name | Type  |  Owner   |  Size   | Description 
--------+------+-------+----------+---------+-------------
 public | test | table | postgres | 2873 MB | 
(1 row)
[postgres@postgresql01 ~]$ ll /pgdata/11.2/data/base/13287/16399*
-rw------- 1 postgres postgres 1073741824 Aug 24 11:11 /pgdata/11.2/data/base/13287/16399
-rw------- 1 postgres postgres 1073741824 Aug 24 11:13 /pgdata/11.2/data/base/13287/16399.1
-rw------- 1 postgres postgres  864206848 Aug 24 11:14 /pgdata/11.2/data/base/13287/16399.2
-rw------- 1 postgres postgres     761856 Aug 24 11:13 /pgdata/11.2/data/base/13287/16399_fsm
-rw------- 1 postgres postgres     8192 Aug 24 11:13 /pgdata/11.2/data/base/13287/16399_vm


原文链接:https://blog.csdn.net/murkey/article/details/106089239

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论