PostgreSQL physical file ing
We know that in PG, each relation, that is, the table, has several fork mappings. "MAIN" fork is used to store the data in the master table, "FSM" fork is used to manage the free space, and "visibility" fork is used to store the Visual View.
Then how does PG manage the fork of each table and correspond to relfileno in pg_class? There are two types: Regular tables and system tables.
1. Regular table
Suppose I have a table named "tab_mvcc_test", which is in the S database. Therefore, we must first find the database directory. Query pg_database to obtain the oid as "12896 ".
Go to the base directory and find the corresponding database directory. The "12896" directory is what we want.
Then, from pg_class, we can find that the relfilenode of "tab_mvcc_test" is "16483 ".
Next we enter the database directory "12896", and then list one of the three files mentioned below. The Free Space Mapping File is suffixed with "_ fsm. Visibility map is suffixed with "vm.
The primary table data file without a suffix also stores the index data.
2. System Table
In addition, for system catalog tables such as pg_class, its refileno is "0". Why? PG cannot process system tables like regular tables. This is a bit like "chicken or egg". Because system tables are used to manage regular tables.
PG puts these catalog tables in a file for management and maps oid and relfileno. This file is the famous "pg_filenode.map". The file size is 512, which is the size of an OS disk sector.
PG performs alignment and uses the RelMapFile structure to correspond to it in the source code. The struct size is 62*8 + 4*4 = 496 + 16 = 512. That is to say, this file can store a maximum of 62 system catalog table records.
Because of the importance of this file, it is aligned with the disk sector size to reduce the probability of File crash.
Let's take a look at pg_filenode.map DUMP and see what data is in it:
The data in the first circle is the magic data word in the PG file header. Which catalog table does the data in the second circle correspond? We can calculate that the "4eb" decimal data is "1259", which is exactly the oid of pg_class.
The subsequent "3172" corresponds to 12658. It is relfilenode. Perfect match.
The file is as follows:
The number of records is exactly 14, which is matched with the number "000e" between the two red circles in the figure above. This file also stores the index file filenode corresponding to these system tables.
------------------------------------ Lili split line ------------------------------------
Install PostgreSQL 6.3 on yum in CentOS 9.3
PostgreSQL cache details
Compiling PostgreSQL on Windows
Configuration and installation of LAPP (Linux + Apache + PostgreSQL + PHP) Environment in Ubuntu
Install and configure phppgAdmin on Ubuntu
Install PostgreSQL9.3 on CentOS
Configure a Streaming Replication cluster in PostgreSQL
How to install PostgreSQL 7/6 and phpPgAdmin in CentOS 5/6. 4
------------------------------------ Lili split line ------------------------------------
PostgreSQL details: click here
PostgreSQL: click here
This article permanently updates the link address: