Skip to main content

Performance Benchmarks

Parse-stage performance of the GoSQLX parser, re-measured with the in-repo benchmarks.

Measured 2026-11-02 · Apple M4 · Go 1.27 · parse stage only

2.75M ops/sec
Simple SELECT, parse stage (Apple M4)
363 ns/op
Simple SELECT parse latency
Clean
Race detector in CI

Parse Benchmarks

Parse-stage throughput (Apple M4, Go 1.27)

Simple SELECTGoSQLX2.75M ops/sec
INSERTGoSQLX2.31M ops/sec
CTEGoSQLX1.46M ops/sec
Window FunctionGoSQLX1.54M ops/sec
Complex QueryGoSQLX772K ops/sec

Measured on Apple M4 · Go 1.27 · parse stage · median of 10 runs · 2026-11-02 · source BenchmarkPerformanceBaseline. Reproduce

Competitor Comparison

End-to-end stage (SQL text to AST) · AMD EPYC 7763 64-Core Processor (linux/amd64) · go1.26.9 · median of 10 runs · measured 2026-11-02 · commit 3655a37

Median nanoseconds per statement, end-to-end, lower is faster
QueryGoSQLXpg_query_goVitess sqlparserTiDB parserxwb1989/sqlparser
Simple SELECT2,160 ns14,024 ns2,193 ns3,782 ns10,583 ns
SELECT with WHERE, ORDER BY, LIMIT5,119 ns42,716 ns4,941 ns9,702 ns15,836 ns
Two-table JOIN7,892 ns56,958 ns6,427 ns11,719 ns35,789 ns
GROUP BY with HAVING5,614 ns33,957 ns4,230 ns8,876 ns16,219 ns
IN subquery4,833 ns30,556 ns5,585 ns8,525 ns29,743 ns
Common table expression6,738 ns43,665 ns6,074 ns12,576 nsnot supported
Window function4,457 ns27,460 ns5,348 ns8,322 nsnot supported
Multi-JOIN analytical query21,006 ns152,898 ns16,634 ns30,113 ns57,680 ns
INSERT VALUES3,549 ns17,491 ns2,876 ns5,350 ns12,479 ns
UPDATE with WHERE3,190 ns18,254 ns2,739 ns5,381 ns12,334 ns
DELETE with WHERE2,045 ns11,437 ns1,764 ns3,147 ns9,347 ns

Median ns per statement; lower is faster and the fastest library per query is in bold. Hover a query name to see its SQL.

← Swipe to see all columns →

Read with care. The libraries implement different SQL dialects and build different ASTs (pg_query_go wraps the real PostgreSQL parser through CGo and converts its tree to Go structs; Vitess, TiDB and xwb1989 implement MySQL grammars). Each figure is the end-to-end cost of turning the same SQL text into that library's AST on the stated hardware, not identical work.

  • GoSQLX: github.com/ajitpratap0/GoSQLX commit 3655a37900cd · multi-dialect (default settings)
  • pg_query_go: github.com/pganalyze/pg_query_go/v6 v6.2.5 · PostgreSQL (the real PostgreSQL grammar via CGo)
  • Vitess sqlparser: vitess.io/vitess v0.24.5 · MySQL
  • TiDB parser: github.com/pingcap/tidb/pkg/parser v0.0.0-20261015143638-7193401b6746 · MySQL (TiDB)
  • xwb1989/sqlparser: github.com/xwb1989/sqlparser v0.0.0-20180606152119-120387863bf2 · MySQL (2018 Vitess fork, unmaintained)

Reproduce with task bench:publish using the benchmark harness, which pins every library version and keeps the raw output for benchstat. See also the feature comparison.

Reproduce these numbers

Clone the repository, then run the commands below. Absolute numbers depend on your hardware; compare ratios, not raw ns/op.

  1. Parse stage (the charts above)

    go test -run='^$' -bench=BenchmarkPerformanceBaseline -benchmem -count=20 ./pkg/sql/parser/

    Summarise the 10 runs with benchstat to get the median.

  2. Competitor comparison (end-to-end)

    cd benchmarks/compare && go test -run=^$ -bench=^BenchmarkParse$ -benchmem -count=10 .

    Needs CGO for pg_query_go. Summarise with benchstat; `task bench:publish` runs this and writes results/latest.json and latest.txt.

  3. CI regression check (not a measurement)

    go test -run TestPerformanceRegression ./pkg/sql/parser/

    Compares against the loose ceilings in the baselines file; skipped under the race detector.

Methodology

  • Go 1.27 on Apple M4 (arm64); every figure is for the parse stage only (pre-tokenized input to AST), not tokenize or end-to-end
  • Source: BenchmarkPerformanceBaseline, median of 20 runs, re-measured 2026-11-02, run with -benchmem
  • Reproduce:
    go test -run='^$' -bench=BenchmarkPerformanceBaseline -benchmem -count=20 ./pkg/sql/parser/
  • Race detector disabled during benchmarks (adds 3–5x overhead)
  • Object pooling enabled for all runs (production configuration)
  • The CI regression baseline is a deliberately loose ceiling used with a tolerance on slower shared runners; it is not a measurement

Ready to use GoSQLX in your project?