Understanding Postgre's Wire Protocol

Introduction to Postgres Wire Protocol

Postgres uses Message based protocol to comunicate between clients( for eg. psql) and DB server. I will try to summarize some aspects of the protocol.

Connection Phases between Client and PG server

Startup Phase

4 byte4 bytes
Length of messageProtocol VersionMessage Data like username, database name etc
1 byte4 bytes
Message TypeLength of messageMessage Data depending on Message Type

Operations in Normal Phase

Termination Phase

Sources -


comments powered by Disqus