最后把 PostgreSQL 的关键部件串成一张关系图:
应用 SQL
│
▼
事务边界(BEGIN / COMMIT / ROLLBACK)
│
▼
MVCC 快照 ------------------------┐
│ │
├── 决定当前事务能看见哪一版行 │
└── 与隔离级别一起工作 │
│
锁系统 ---------------------------┤
│ │
├── 表锁 │
└── 行锁 │
▼
规划器 / 执行器
│
├── 读统计信息(ANALYZE)
├── 选计划(Seq/Index/Bitmap)
├── 选连接(Nested/Hash/Merge)
└── 真正访问表和索引
│
├── 表:存档案正文
├── 索引:存目录卡
└── JSONB:存附页
后台维护
├── VACUUM:清旧版本、推进可见性
├── ANALYZE:更新统计
└── autovacuum:自动做上面两件关键维护如果只记一条主线,请记这条:
PostgreSQL 不是“表 + SQL”这么简单。 它真正的力量,在于:
- 用约束守住数据正确性
- 用索引和规划器守住查询效率
- 用事务、MVCC、锁守住并发一致性
- 用迁移、备份、恢复守住长期演进能力
当你开始从这四层一起看 PostgreSQL,你才算真正入门。
#官方来源链接清单
PostgreSQL Versioning Policy
https://www.postgresql.org/support/versioning/PostgreSQL 18 Documentation 首页
https://www.postgresql.org/docs/current/Creating a New Table
https://www.postgresql.org/docs/current/tutorial-table.htmlConstraints
https://www.postgresql.org/docs/current/ddl-constraints.htmlIndex Types
https://www.postgresql.org/docs/current/indexes-types.htmlIndexes on Expressions
https://www.postgresql.org/docs/current/indexes-expressional.htmlPartial Indexes
https://www.postgresql.org/docs/current/indexes-partial.htmlTransactions
https://www.postgresql.org/docs/current/tutorial-transactions.htmlTransaction Isolation
https://www.postgresql.org/docs/current/transaction-iso.htmlMVCC Introduction
https://www.postgresql.org/docs/current/mvcc-intro.htmlExplicit Locking
https://www.postgresql.org/docs/current/explicit-locking.htmlJoins Between Tables
https://www.postgresql.org/docs/current/tutorial-join.htmlUsing EXPLAIN
https://www.postgresql.org/docs/current/using-explain.htmlStatistics Used by the Planner
https://www.postgresql.org/docs/current/planner-stats.htmlRoutine Vacuuming
https://www.postgresql.org/docs/current/routine-vacuuming.htmlJSON Types
https://www.postgresql.org/docs/current/datatype-json.htmlUpgrading a PostgreSQL Cluster
https://www.postgresql.org/docs/current/upgrading.htmlSQL Dump
https://www.postgresql.org/docs/current/backup-dump.htmlFile System Level Backup
https://www.postgresql.org/docs/current/backup-file.htmlpg_dump
https://www.postgresql.org/docs/current/app-pgdump.htmlpg_restore
https://www.postgresql.org/docs/current/app-pgrestore.htmlpg_basebackup
https://www.postgresql.org/docs/current/app-pgbasebackup.htmlpg_upgrade
https://www.postgresql.org/docs/current/pgupgrade.html