https://github.com/percona/pmm-agent/pull/146 added benchmarks for PostgreSQL query parser and a long sysbench-generated query example. Parsing that long query takes 800ms and 245MB on my machine. Quick profiling shows that most of that time is spent not on cgo function doing SQL-to-JSON-AST conversion, but on Go side doing JSON decoding.
We should improve performance and memory consumption.
As an idea, we can try to decode into map[string]json.RawMessage and work with that map step-by-step instead of decoding the whole AST in a single pass.
Alternatively, we may want to generate decoders for all github.com/lfittl/pg_query_go/nodes types with https://github.com/mailru/easyjson, https://github.com/francoispqt/gojay or something else.