Skip to content

PostgreSQL's Extended Query Protocol Support in ProxySQL #5018

@rahim-kanji

Description

@rahim-kanji

Most modern PostgreSQL drivers (libpq, the JDBC/ODBC clients, etc.) use Extended Query wire protocol by default. It breaks a single SQL statement into multiple wire-level messages (Parse, Bind, Describe, Execute, Close, Sync), enabling better performance, improves security, and resource utilization.
Currently, ProxySQL only supports simple Query message protocol for PostgreSQL. Without support for the Extended Query Protocol, ProxySQL is not fully compatible with many applications that rely on prepared statements.

Adding support for the Extended Query Protocol would unlock several key benefits for ProxySQL users:

Benefits:

Performance Improvements through Pipelining:

  • Clients can send Parse, Bind, Execute, and Sync messages back-to-back without waiting for a response between each step.
  • This reduces network round-trips and lowers query latency.

Reuse parsed plans:

  • Parsed query plans can be reused across multiple executions with different parameters.
  • This reduces CPU overhead on the backend server and improves throughput.

Improved Driver Compatibility:

  • Enables ProxySQL to seamlessly support most PostgreSQL client libraries that default to extended protocol mode (e.g., JDBC, psycopg2, libpq).
  • Reduces friction when integrating ProxySQL into existing PostgreSQL deployments.

Enhanced Security:

  • Parameter values are transmitted separately from SQL statements, reducing the risk of SQL injection attacks.
  • Promotes safer coding practices through the use of bind parameters.

Efficient Connection Pooling:

  • Enables ProxySQL to properly handle prepared statements without “pinning” backend connections to clients.
  • Allow effective multiplexing and reuse of backend connections, improving scalability.

Apply Query Rules

  • Enable routing, filtering, and transformation of parameterized queries.
  • Provide granular control over query handling.

Sub-issues

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions