3 ms·
The PostgreSQL parser is available as a C library. C - https://github.com/lfittl/libpg_query https://github.com/lfittl/libpg_query Ruby - https://github.com/l
by j_s 9y ago
The PostgreSQL parser is available as a C library.
C - https://github.com/lfittl/libpg_query https://github.com/lfittl/libpg_query
Ruby - https://github.com/lfittl/pg_query https://github.com/lfittl/pg_query
Go - https://github.com/lfittl/pg_query_go https://github.com/lfittl/pg_query_go
Node - https://github.com/zhm/pg-query-parser https://github.com/zhm/pg-query-parser
Python - https://github.com/alculquicondor/psqlparse https://github.com/alculquicondor/psqlparse
- saurik 9y agoThe output of explain is not "parse this SQL statement and show me what it means" but "given this SQL statement, how will it be executed on this database (which is affected by the table's stored statistics and takes into account any indexes)". I am thereby not sure how these query parsing libraries are relevant.
- j_s 9y agoThanks for taking the time to comment (?). Never-before-on-the-HN-front-page tools for working with PostgreSQL queries seemed relevant to me; this info may help a few others.
- lfittl 9y agoThanks for the shout-out - I'm the author of the base library you listed that can be used to work with the Postgres parser (libpg_query). That said, the tool being discussed here (pev) is used to interpret EXPLAIN plans, which libpg_query doesn't give you, as its only concerned with the parsing stage, not the planning stage. In order to plan a query you'll need more information from the actual database, including table statistics, config settings and the size of the underlying table :)