当前位置:网站首页>Introduction to the internal structure of the data directory of PostgreSQL
Introduction to the internal structure of the data directory of PostgreSQL
2022-07-07 02:21:00 【happytree001】
One 、 Everything is Oid
stay Linux Everything in the book is a document , stay postgresql It's all about Oid.
1.1 What is? Oid
Object identifier(Oid), Object identifier . stay postgresql Inside , All database objects pass through the corresponding Oid Conduct management .
typedef unsigned int Oid;
Oid In the code is a 4 Unsigned integer of bytes .
1.2 database Oid
[email protected]:~$ /usr/local/pgsql/bin/psql
psql (14.2)
Type "help" for help.
postgres=# select datname,oid from pg_database where datname='test';
datname | oid
---------+-------
test | 16384
(1 row)
postgres=#
[email protected]:~$ ls /usr/local/pgsql/data/base/ -l
total 24
drwx------ 2 postgres postgres 4096 Jun 6 14:38 1
drwx------ 2 postgres postgres 4096 Jun 6 14:38 12971
drwx------ 2 postgres postgres 4096 Jul 4 12:50 12972
drwx------ 2 postgres postgres 4096 Jun 7 12:19 16384
drwx------ 2 postgres postgres 4096 Jun 11 02:01 24577
drwx------ 2 postgres postgres 4096 Jul 4 12:50 40960
1.3 surface Oid
[email protected]:~$ /usr/local/pgsql/bin/psql test
psql (14.2)
Type "help" for help.
test=# create table stu (name varchar(32), age int, sex char(2));
CREATE TABLE
test=# \dS+ stu
Table "public.stu"
Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description
--------+-----------------------+-----------+----------+---------+----------+-------------+--------------+-------------
name | character varying(32) | | | | extended | | |
age | integer | | | | plain | | |
sex | character(2) | | | | extended | | |
Access method: heap
test=# select oid,relname from pg_class where relname = 'stu';
oid | relname
-------+---------
49152 | stu
(1 row)
test=#
[email protected]:~$ ls /usr/local/pgsql/data/base/16384/49152 -hal
-rw------- 1 postgres postgres 0 Jul 4 12:57 /usr/local/pgsql/data/base/16384/49152
Two 、 and MySQL contrast
database | Database storage | Table is stored | Coding impact |
---|---|---|---|
postgresql | The directory name is the corresponding Oid( Numbers ) | The file name is the corresponding Oid ( Numbers ) | Just a number , Unaffected |
mysql | The directory name is database name ( character string ) | The file name is the table name ( character string ) | be affected |
postgresql and mysql All use the database as a directory , The corresponding table is under the corresponding directory , Easy to find and manage .
3、 ... and 、 Data directory structure
[email protected]:/# tree /usr/local/pgsql/data/ -L 1
/usr/local/pgsql/data/
|-- PG_VERSION
|-- base
|-- global
|-- pg_commit_ts
|-- pg_dynshmem
|-- pg_hba.conf
|-- pg_ident.conf
|-- pg_logical
|-- pg_multixact
|-- pg_notify
|-- pg_replslot
|-- pg_serial
|-- pg_snapshots
|-- pg_stat
|-- pg_stat_tmp
|-- pg_subtrans
|-- pg_tblspc
|-- pg_twophase
|-- pg_wal
|-- pg_xact
|-- postgresql.auto.conf
|-- postgresql.conf
|-- postmaster.opts
`-- postmaster.pid
17 directories, 7 files
name | describe |
---|---|
PG_VERSION | pg Server master version number file |
base/ | All database directories are under this directory |
global/ | Database cluster wide tables ( such as pg_database, similar mysql Of performance_schema) |
pg_commit_ts/ | Timestamp data submitted by the transaction |
pg_dynshmem/ | Files used in the dynamic shared memory subsystem |
pg_hba.conf | control pg Client authentication configuration file |
pg_ident.conf | pg User mapping file |
pg_logical/ | Logically decoded status data |
pg_multixact/ | Multi transaction status data |
pg_notify/ | Listen/Notify Status data |
pg_replslot/ | Copy slot data |
pg_serial/ | Information about committed serializable transactions |
pg_snapshots/ | Snapshot information |
pg_stat/ | Permanent file of statistical subsystem |
pg_stat_tmp/ | Temporary files of statistical subsystem |
pg_subtrans/ | Sub transaction status data |
pg_tblspc/ | Symbolic links to tablespaces |
pg_twophase/ | The state file of a two-phase transaction |
pg_wal/ | WAL file |
pg_xact/ | Transaction commit status data |
postgresql.auto.conf | Storage use alter system Modified configuration |
postgresql.conf | The configuration file |
postmaster.opts | Record the command line options of the last time the server was started |
postmaster.pid | The server pid file |
边栏推荐
- 建議收藏!!Flutter狀態管理插件哪家强?請看島上碼農的排行榜!
- Centos8 install MySQL 8.0 using yum x
- How do I dump SoapClient requests for debugging- How to dump SoapClient request for debug?
- Analyze "C language" [advanced] paid knowledge [i]
- ROS learning (21) robot slam function package -- installation and testing of orbslam
- go swagger使用
- 云原生混部最后一道防线:节点水位线设计
- Stm32f4 --- general timer update interrupt
- The last line of defense of cloud primary mixing department: node waterline design
- Zhang Ping'an: accelerate cloud digital innovation and jointly build an industrial smart ecosystem
猜你喜欢
Blackfly S USB3工业相机:缓冲区处理
[paper reading | deep reading] anrl: attributed network representation learning via deep neural networks
STM32F4---通用定时器更新中断
Analyze "C language" [advanced] paid knowledge [II]
Jacob Steinhardt, assistant professor of UC Berkeley, predicts AI benchmark performance: AI has made faster progress in fields such as mathematics than expected, but the progress of robustness benchma
ROS learning (25) rviz plugin
Flir Blackfly S 工业相机:通过外部触发实现多摄像头同步拍摄
豆瓣平均 9.x,分布式领域的 5 本神书!
[paper reading | deep reading] rolne: improving the quality of network embedding with structural role proximity
Flir Blackfly S 工业相机 介绍
随机推荐
豆瓣平均 9.x,分布式领域的 5 本神书!
使用Ceres进行slam必须要弄清楚的几个类和函数
张平安:加快云上数字创新,共建产业智慧生态
Data connection mode in low code platform (Part 1)
ZABBIX 5.0: automatically monitor Alibaba cloud RDS through LLD
CISP-PTE实操练习讲解(二)
[paper reading | deep reading] rolne: improving the quality of network embedding with structural role proximity
微服务架构介绍
The GPG keys listed for the "MySQL 8.0 community server" repository are already ins
投资的再思考
How to use strings as speed templates- How to use String as Velocity Template?
新一代云原生消息队列(一)
组合导航:中海达iNAV2产品描述及接口描述
Tiflash source code reading (IV) design and implementation analysis of tiflash DDL module
老板被隔离了
What to do when encountering slow SQL? (next)
张平安:加快云上数字创新,共建产业智慧生态
The mega version model of dall-e MINI has been released and is open for download
强化学习如何用于医学影像?埃默里大学最新《强化学习医学影像分析》综述,阐述最新RL医学影像分析概念、应用、挑战与未来方向
建议收藏!!Flutter状态管理插件哪家强?请看岛上码农的排行榜!