Postgresql体系结构

client连接PostgreSQL过程:

1、客户端发起请求

2、主服务postmaster进程负责服务器是否接受客户端的host通信认证,服务器对客户端进行身份鉴别

3、主服务进程为该客户端单独fork一个客户端工作进程postgres

4、客户端与postgres进程建立通信连接,由postgres进程负责后续所有的客户端请求操作,直至客户端退出后

进程:

Postmaster进程是PG数据库的总控制进程,负责启动和关闭数据库实例,是第一个postgres进程。Postmaster的主进程,还会fork出一些辅助子进程。

BgWriter(后台写)进程

WaLWriter(预写式日志)进程

AutoVAcuum(系统自动清理)

SysLogger(系统日志)进程

PgArch(归档)进程

PgStat(统计数据收集)进程

CheckPoint(检查点)进程

内存:

共享内存区

shared_buffers ---共享缓冲区,它表示数据缓冲区中的数据块的个数,每个数据块的大小是8KB。推荐值:1/4 主机物理内存

wal_buffers --- 日志缓存区的大小 存放WAL数据的内存空间大小,系统默认值是64K

私有内存区

temp_buffers---临时缓冲区 用于存放数据库会话访问临时表数据,系统默认值为8M。

work_mem --- 工作内存或者操作内存。其负责内部的sort和hash操作,合适的work_mem大小能够保证这些操作在内存中进行。

maintenance_work_mem ---维护工作内存 主要是针对数据库的维护操作,主要针对VACUUM,CREATE INDEX,ALTER TABLE ADD FOREIGN KEY等操作。

PGDATA主要目录

drwx------ 6 postgres postgres 54 Mar 29 16:37 base

drwx------ 2 postgres postgres 4096 Mar 30 20:50 global

drwx------ 2 postgres postgres 6 Mar 26 11:26 pg_commit_ts

drwx------ 2 postgres postgres 6 Mar 26 11:26 pg_dynshmem

-rw------- 1 postgres postgres 4760 Mar 26 11:26 pg_hba.conf

-rw------- 1 postgres postgres 1636 Mar 26 11:26 pg_ident.conf

drwx------ 4 postgres postgres 68 Mar 31 16:13 pg_logical

drwx------ 4 postgres postgres 36 Mar 26 11:26 pg_multixact

drwx------ 2 postgres postgres 6 Mar 26 11:26 pg_notify

drwx------ 2 postgres postgres 6 Mar 26 11:26 pg_replslot

drwx------ 2 postgres postgres 6 Mar 26 11:26 pg_serial

drwx------ 2 postgres postgres 6 Mar 26 11:26 pg_snapshots

drwx------ 2 postgres postgres 6 Mar 29 14:29 pg_stat

drwx------ 2 postgres postgres 105 Apr 1 09:17 pg_stat_tmp

drwx------ 2 postgres postgres 18 Mar 26 11:26 pg_subtrans

drwx------ 2 postgres postgres 19 Mar 30 20:41 pg_tblspc

drwx------ 2 postgres postgres 6 Mar 26 11:26 pg_twophase

-rw------- 1 postgres postgres 3 Mar 26 11:26 PG_VERSION

drwx------ 3 postgres postgres 60 Mar 26 11:26 pg_wal

drwx------ 2 postgres postgres 18 Mar 26 11:26 pg_xact

-rw------- 1 postgres postgres 88 Mar 26 11:26 postgresql.auto.conf

-rw------- 1 postgres postgres 28011 Mar 26 11:26 postgresql.conf

-rw------- 1 postgres postgres 33 Mar 29 14:29 postmaster.opts

-rw------- 1 postgres postgres 91 Mar 29 14:29 postmaster.pid

ll base/

drwx------ 2 postgres postgres 8192 Mar 29 16:36 12723

drwx------ 2 postgres postgres 8192 Mar 29 16:37 16393

base:用于存放当前实例下所有的数据库,数字化命名的路径表示各个数据库,每个数字表示数据库的oid

oid2name 展示数据库对应的表空间信息

All databases:
Oid Database Name Tablespace

12723 postgres pg_default

16393 testdb pg_default

pg_commit_ts:事务提交时间戳信息;commit timestamp;

pg_dynshmem:共享内存使用的文件信息;dynamic shared memory;

pg_hba.conf:关于客户端如何访问数据库的配置文件 host based authentication;

pg_logical:数据库逻辑解码的状态数据;

pg_multixact:存放多事务状态数据,共享锁信息;multi transaction;

pg_notify:数据库配置订阅模式的LISTEN/NOTIFY状态数据;

pg_replslot:数据库复制槽信息;replication slot;

pg_serial:已提交的串行化事务信息;serializable;

pg_snapshots:导出的快照信息,内置pg_export_snapshot()函数导出;

pg_stat:统计子系统收集的统计信息;statistics;

pg_stat_tmp:统计子系统收集的临时统计信息;statistics temporary;

pg_subtrans:子事务的转态数据;sub-transactions;

pg_tblspc:表空间的映射,

pg_twophase:两阶段提交事务的状态信息;

PG_VERSION:存放数据库版本信息;

pg_wal:存放数据库的日志文件,类似于Oracle的redo log。write ahead log;

pg_xact:事务提交状态数据,用于控制事务的Multi Version Concurrent Contril;PostgreSQL事务有4种状态:IN_PROGRESS,COMMITED,ABORTED,SUB_COMMITTED;

postgresql.auto.conf:存放通过alter sytem命令修改的参数,

postgresql.conf:数据库配置的参数文件,类似于Oracle的参数文件spfile;

postmaster.opts:记录数据库启动时的选项,options;

postmaster.pid 主进程文件

逻辑结构

DataBase

tablespace

Schema

object

创建一个Database时,这个Database会创建一个名为public的默认Schema,每个Database可以有多个Schema,在这个数据库中创建其他数据库对象时,如果没有指定Schema,都会在public这个Schema中,Schema可以理解为一个数据库中的命名空间,在数据库中创建的所有对象都Schema中创建,一个用户可以从同一个客户端连接中访问不同的Schema,不同的Schema中可以有多个相同的名称的Table、Index、View、Sequence、Function等数据库对象。

相关推荐
hqxstudying31 分钟前
MyBatis 和 MyBatis-Plus对比
java·数据库·mysql·mybatis
DarkAthena1 小时前
AI生成技术报告:GaussDB与openGauss的HTAP功能全面对比
数据库·gaussdb
DemonAvenger2 小时前
高效JOIN操作:多表关联查询技巧与实战经验分享
数据库·mysql·性能优化
小云数据库服务专线3 小时前
GaussDB 数据库架构师修炼(十八) SQL引擎-分布式计划
数据库·数据库架构·gaussdb
秋已杰爱4 小时前
Redis分布式锁
数据库·redis·分布式
haogexiaole11 小时前
Redis优缺点
数据库·redis·缓存
在未来等你11 小时前
Redis面试精讲 Day 27:Redis 7.0/8.0新特性深度解析
数据库·redis·缓存·面试
新法国菜13 小时前
MySql知识梳理之DML语句
数据库·mysql
老华带你飞13 小时前
校园交友|基于SprinBoot+vue的校园交友网站(源码+数据库+文档)
java·数据库·vue.js·spring boot·论文·毕设·校园交友网站
许泽宇的技术分享13 小时前
Text2API与Text2SQL深度对比:自然语言驱动的数据交互革命
数据库·windows·microsoft