How pg_query rewrites, deparses & formats any valid Postgres query
summary
Library exposes a Protobuf-based AST and language bindings that let code walk and mutate real Postgres raw parse trees; implemented rewrites include turning certain OR conditions into UNIONs and materializing scans, yielding large speedups (orders-of-magnitude in the demo). A separate deep deparser and optional pretty‑print mode emits SQL (comments preserved best‑effort via the Postgres scanner) and deparser supports full Postgres syntax including DDL; tests run the full Postgres regression suite.
AI-written summary · about
