Skip to main content

PostgreSQL Wire Protocol Simulator

Visualize the PostgreSQL wire protocol with an interactive simulator. Step through TLS negotiation, StartupMessage, SCRAM authentication, simple queries, extended queries, RowDescription, DataRow streams, ErrorResponse, COPY, and ReadyForQuery.

Category: Database

What You Will Learn

  • Visualize PostgreSQL frontend and backend protocol messages
  • Understand StartupMessage, AuthenticationSASL, and ReadyForQuery
  • Compare simple query and extended query protocol flows
  • See how RowDescription and DataRow messages encode result sets
  • Learn how COPY streams bulk data over the wire

Topics covered: postgresql, postgres, database, wire-protocol, networking, sql, backend, educational, interactive

// simulator

PostgreSQL Wire Protocol Simulator

Visualize the PostgreSQL wire protocol with an interactive simulator. Step through TLS negotiation, StartupMessage, SCRAM authentication, simple queries, extended queries, RowDescription, DataRow streams, ErrorResponse, COPY, and ReadyForQuery.

Supported byDigitalOceanDevDojoSMTPfastQuizAPIBecome a sponsor
PostgreSQL v3 protocol
frontend/backend messages

Watch every byte between a Postgres client and server.

Step through connection startup, SCRAM authentication, simple queries, prepared statements, row streaming, errors, and COPY. The lab shows what drivers actually send over the wire.

Round trips
4.0

protocol turns

Wire bytes
571 B

4 client, 6 server messages

Estimated latency
169 ms

42 ms network baseline

Decode work
10 ms

3 rows modeled

Startup and authentication

SSL negotiation, startup parameters, SCRAM challenge, session settings, ready state.

psql "postgres://[email protected]:5432/app"
Client
Wire
Server
STARTStartup packets have no type byte.
DDataRow messages carry one row each.
ZReadyForQuery ends the exchange.
Message inspector

Client to server

SSL
Ask for TLS8 B

The client can ask whether the server accepts SSL before sending startup parameters.

Payload shape
length: 8
magic: 0x04D2162F
no type byte
Frame sketch
type
length
payload
SSL
8
Int32 length=8, Int32 code=80877103
Lab controls
Rows returned
3
Network latency
42 ms
Driver mental model

Always wait for Z

ReadyForQuery is the connection boundary. It tells a pooler whether the session is idle, inside a transaction, or stuck in a failed transaction.

Rows are framed

Each DataRow carries field lengths, so clients can decode NULLs, text values, and binary values without guessing delimiters.

Prepared queries split work

Parse and Bind separate SQL shape from values, which helps reuse plans and keeps parameter values out of string concatenation.

How the PostgreSQL wire protocol works

Startup

  • SSLRequest: the client may ask whether the server accepts TLS before sending startup parameters.
  • StartupMessage: carries protocol version, user, database, and session options.
  • ReadyForQuery: marks the connection as safe for the next command.

Query execution

  • Simple query: sends one SQL string and receives metadata, rows, completion, and ready state.
  • Extended query: splits work into Parse, Bind, Describe, Execute, and Sync.
  • COPY: switches into a streaming mode for bulk import or export.

Why it matters

  • Connection poolers need transaction state from ReadyForQuery.
  • Drivers use RowDescription to decode text and binary values correctly.
  • Prepared statements reduce SQL injection risk and can reduce parse overhead.

Try next

Sponsored
Carbon Ads
$ cd /games
// share