Skip to main content

Compare / TiDB parser

TiDB parser alternative: GoSQLX compared

The TiDB parser (github.com/pingcap/tidb/pkg/parser) is the MySQL-compatible parser of the TiDB database, written in Go.

Approach
yacc-generated MySQL-compatible grammar from the TiDB project
Dialect
MySQL (TiDB flavour)
CGo required
No

Pick TiDB parser when

  • You target MySQL or TiDB and want TiDB-specific syntax and its AST visitors.
  • You are building tooling around TiDB and want to match how the database itself parses SQL.

Pick GoSQLX when

  • You need dialects beyond MySQL.
  • You want a self-contained module with formatting, linting and security scanning included.
  • You want to avoid importing a subpackage of a database server module.

Parse speed, measured

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-11-28 · TiDB parser v0.0.0-20261015143638-7193401b6746. Lower is faster.

QueryGoSQLXTiDB parser
Simple SELECT992 ns2,819 ns
SELECT with WHERE, ORDER BY, LIMIT2,644 ns7,317 ns
Two-table JOIN3,556 ns8,782 ns
GROUP BY with HAVING2,659 ns6,595 ns
IN subquery2,289 ns6,292 ns
Common table expression3,290 ns9,327 ns
Window function2,128 ns6,173 ns
Multi-JOIN analytical query9,279 ns22,004 ns
INSERT VALUES1,739 ns3,948 ns
UPDATE with WHERE1,535 ns4,039 ns
DELETE with WHERE963 ns2,347 ns

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. Results vary by query, so check the rows that resemble your workload.

Full table, methodology and reproduce steps: competitor benchmarks. Source: benchmarks/compare/results/latest.json, commit 1990a11.

What GoSQLX offers

Pure Go with no CGo, 8 dialects, 30 built-in lint rules, a formatter, a SQL injection scanner, an LSP server and an MCP server. Requires Go 1.26+.

Full feature matrix