Bỏ qua đến nội dung
DevOps Lab
Hub
AWS
GCP
GitOps
PostgreSQL
Hub
/
PostgreSQL
/
Luồng xử lý
PostgreSQL — Diagram luồng (INSERT / UPDATE / DELETE / MVCC)
Port từ tài liệu HTML gốc — điều hướng bằng các tab phía trên.
🏗️ Kiến trúc tổng quan
📥 INSERT Flow
✏️ UPDATE Flow
🗑️ DELETE Flow
🧬 MVCC Tuple
PostgreSQL — Kiến trúc nội bộ tổng quan
5 lớp chính từ Client đến Disk
L1: Frontline
L2: SQL Processing
L3: Shared Memory
L4: Auxiliary Workers
L5: Disk Storage
NEW
LAYER 1 — FRONTLINE: Connection Handlers
Web / App
Client
pgbouncer
Connection Pooler
Postmaster
Listener Daemon
Backend Process 1
fork() from Postmaster
Backend Process 2
fork() from Postmaster
. . .
1 connection = 1 process
Stats Collector
pg_stat_activity
Syslogger
pg_log / CSV logs
LAYER 2 — SQL PROCESSING PIPELINE (bên trong mỗi Backend Process)
Parser
SQL → Parse Tree
Analyzer / Rewrite
Query Tree (QT)
Planner / Optimizer
Plan Tree
Executor
Thực thi truy vấn
Transaction Manager
Gán xid, SNAPSHOT
Lock Manager
Row / Table / Page locks
System Catalog
pg_class, pg_attribute...
Type System
pg_type, casts, I/O
LAYER 3 — SHARED MEMORY (được chia sẻ giữa các Backend Processes)
Shared Buffers
Data cache (8KB pages)
WAL Buffers
Write-Ahead Log cache
CLOG
Commit Log (xid status)
Subtrans
Sub-transaction map
Free Space Map
FSM — page trống
Visibility Map
VM — all-visible
Lock Table
Shared lock structures
ProcArray
Active transaction list
LAYER 4 — AUXILIARY WORKERS (background processes)
Checkpointer
Shared → Disk
Background Writer
Dirty page evict
WAL Writer
WAL → Disk
Autovacuum
Dead tuples cleanup
WAL Sender
Replication
Stats Collector
pg_stat_* views
Logical Replication
pgoutput plugin
Parallel Workers
Parallel query exec
LAYER 5 — DISK STORAGE
Data Files
pg_data/base/ (Heap + Index)
WAL Files
pg_data/pg_wal/ (Transaction log)
WAL Archive
PITR / Streaming Replication
postgresql.conf
shared_buffers, wal_level...
pg_hba.conf
Authentication config
NEW