Description
postgresparser is a pure-Go PostgreSQL query parser. It reads SQL and returns a structured intermediate representation that lists the tables, columns, joins, filters, CTEs, subqueries and parameters a query uses, without running the query. It handles DML such as SELECT, INSERT, UPDATE, DELETE and MERGE, and DDL such as CREATE TABLE with its constraints, CREATE INDEX, ALTER TABLE, TRUNCATE and COMMENT ON. It supports recursive CTEs, all join types, subqueries in select, from, where and having clauses, and set operations such as UNION and INTERSECT. Because it has no cgo dependency, you can build it with a plain go build command for Alpine containers, Lambda, ARM and scratch images. The README says most queries parse in 70 to 350 microseconds with SLL prediction mode. Typical uses it lists include query linting, dependency and lineage extraction, migration tooling, audit logging, query rewriting and index advice. The project is open source and hosted on GitHub.…
Highlights
- Extracts tables, columns, joins and CTEs
- Parses SELECT, INSERT, UPDATE, DELETE and MERGE
- Parses CREATE, ALTER and DROP statements
- Pure Go with no cgo dependency
- Structured IR with no query execution
Ratings & Reviews
No ratings yet
Be the first to rate Postgresparser.
People also visit
Postgresparser FAQ
What is postgresparser?
A Go library that parses PostgreSQL SQL into a structured representation of the tables, columns and clauses it touches, without running the query.
Does it need cgo?
No. The README says it is pure Go, so it builds with go build wherever CGO_ENABLED=0 is required.
What can I build with it?
The README lists query linting, dependency extraction, migration tooling, audit logging, query rewriting and index advisors.
How fast is it?
The README says most queries parse in 70 to 350 microseconds with SLL prediction mode.
What are the best Postgresparser alternatives?
Popular alternatives to Postgresparser include Slowql, Collector and Tables To Go. See all Postgresparser alternatives












