Skip to main content

Performance Benchmarks

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

Measured 2026-10-22 · Apple M4 · Go 1.27 · parse stage only

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

Parse Benchmarks

Parse-stage throughput (Apple M4, Go 1.27)

Simple SELECTGoSQLX2.87M ops/sec
INSERTGoSQLX2.46M ops/sec
CTEGoSQLX1.55M ops/sec
Window FunctionGoSQLX1.58M ops/sec
Complex QueryGoSQLX810K ops/sec

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

Competitor Comparison

End-to-end stage (SQL text to AST) · AMD EPYC 9V74 80-Core Processor (linux/amd64) · go1.26.9 · median of 10 runs · measured 2026-10-22 · commit e9c5db9

Median nanoseconds per statement, end-to-end, lower is faster
QueryGoSQLXpg_query_goVitess sqlparserTiDB parserxwb1989/sqlparser
Simple SELECT2,138 ns10,811 ns1,587 ns2,801 ns7,897 ns
SELECT with WHERE, ORDER BY, LIMIT4,439 ns32,990 ns3,626 ns7,218 ns11,826 ns
Two-table JOIN6,919 ns43,528 ns4,700 ns8,535 ns25,931 ns
GROUP BY with HAVING4,818 ns25,832 ns3,090 ns6,572 ns12,192 ns
IN subquery4,076 ns23,527 ns3,977 ns6,279 ns21,828 ns
Common table expression5,829 ns33,530 ns4,415 ns9,158 nsnot supported
Window function4,062 ns21,010 ns3,903 ns6,022 nsnot supported
Multi-JOIN analytical query18,293 ns116,213 ns12,305 ns21,303 ns42,654 ns
INSERT VALUES3,185 ns13,373 ns2,202 ns3,914 ns9,105 ns
UPDATE with WHERE2,641 ns14,108 ns2,044 ns3,922 ns9,033 ns
DELETE with WHERE1,772 ns8,876 ns1,343 ns2,312 ns6,736 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 e9c5db91a8ed · 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-10-22, 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?