The Wire Protocol
summary
Postgres uses Protocol version 3 with messages framed as a 1‑byte type plus a 4‑byte length (length excludes the type byte); startup packet includes protocol=3, database, user and an extensions list. Connection setup supports SSLRequest TLS or direct TLS from v17, SCRAM and cleartext (used e.g. by LDAP), and the server sends backend key data used for query cancellation via a separate TCP cancel request that today uses a 4‑byte secret token (planned to be enlarged). Queries use simple or extended flow (Parse/Bind/Describe/Execute then Sync), COPY has in/out/both modes, and replication runs over the same wire with start_replication entering a copy_both mode that streams WAL chunks; Wireshark is recommended for tracing.
AI-written summary · about
chapters (8)
- 0:00Introduction to Wire Protocol
- 12:23Query Protocols Overview
- 29:26Copy Protocol for Data Transfer
- 34:02Replication Protocol Basics
- 39:22Query Cancellation Mechanism
- 41:30Connection Pooling Considerations
- 43:38Protocol Extensibility Plans
- 46:45Q&A Session
related talks
47mThe PostgreSQL Protocol: The Good, the Bad and the Future
35mBeyond JSON: Improving inter-app communication
22mSecuring Postgres with streaming replication
42mlesser known Superpower of Postgres Logical Replication
31mPast, Present, and Future: Logical Decoding and Replication in PostgreSQL
30mPostgreSQL Network Filter for EnvoyProxy
59mEnvoy & Service Mesh for Databases: What the Future Holds
29mLogical replication theory and concepts
