Schedule - PGConf.dev 2026

How pg_query rewrites, deparses & formats any valid Postgres query

Date: 2026-05-21
Time: 15:00–15:25
Room: Canfor (1600)
Level: Intermediate
Feedback: Leave feedback

In this talk we'll go into details about how we've extended pg_query, the Postgres parser as a library, to enable new use cases for rewriting Postgres queries.

Rewrites are made possible by two components: a Protobuf-based AST representation derived from Postgres raw parse trees, and language bindings that provide convenience functions for walking and modifying the tree.

We'll also discuss specific examples of where this is useful, for example to turn certain OR queries into UNIONs or materialize scans on a table.

You'll also learn details about the pg_query deparser that supports the complete range of Postgres query syntax (including DDL!), and has an optional format mode that can pretty print the emitted query.

Slides

The following slides have been made available for this session:

Speaker

Keiko Oda
Lukas Fittl