Repository navigation
SQL GunYu v0.4.0
We are excited to announce the release of SQL GunYu v0.4.0! 🎉
This release marks a major architectural milestone, introducing the v2 unified public analysis contract, full production-grade PostgreSQL 16 & 17 support with HypoPG what-if analysis, a completely refactored MySQL whole-query cost optimizer & index recommendation engine, thread-safe bounded LRU caching with singleflight deduplication, and an out-of-the-box Docker demo & soak test suite.
🚨 Breaking Changes & Migration Guide
1. Go Module Path Renamed
The official module path has migrated to GitHub:
- Old:
git.imgo.tv/ft/sql-gunyu - New:
github.com/mgtv-tech/sql-gunyu
To update your project:
go get github.com/mgtv-tech/sql-gunyu@v0.4.02. Unified Public Analysis Contract (v2)
- Replaced dialect-specific report formats with a unified
pkg/analysis.Reportmodel across both MySQL and PostgreSQL. - Standardized canonical JSON serialization adhering to our OpenAPI 3.0 specification.
3. Standardized 5-Level Numeric Severity Scale
Diagnostic issue severity now follows a standardized integer enum:
1:INFO2:NOTICE3:WARNING4:ERROR5:CRITICAL
4. Build Requirements
- Go Toolchain: Requires Go 1.22+.
- Dialect CGO Requirements:
- MySQL: Pure Go (
CGO_ENABLED=0). - PostgreSQL: Requires CGO (
CGO_ENABLED=1) due tolibpg_queryAST parser bindings.
- MySQL: Pure Go (
🚀 Key Highlights & New Features
🐬 MySQL Whole-Query Cost Optimizer & Index Advisor
- Phased Agent Lifecycle: Implemented lazy metadata and EXPLAIN loading. Static audits run purely in memory without initiating live database connections.
- Whole-Query Work & Cost Accounting:
- Top-N sorting with
LIMIT, prefix-first vs. order-first index tradeoff evaluation, andSQL_CALC_FOUND_ROWSoverhead tracking. - Subquery modeling for multi-table/nested
EXISTS, semi-join materialization, andFirstMatch. - Distinguishes streaming vs. temporary table
GROUP BYand aggregation costs.
- Top-N sorting with
- Cost-Driven Index Recommendation: Automatically synthesizes, ranks, and prunes candidate B-tree indexes, retaining transparent evaluation evidence (
evaluated_baseline_best,evaluated_improved). - Broad Compatibility: Verified across MySQL 5.7.44, 8.0.45, 8.0.46, 8.4.10, and 8.4.13.
🐘 PostgreSQL 16 & 17 Engine
- Full Production Pipeline: 193 static and EXPLAIN-based diagnostic rules (
pkg/postgresql/). - HypoPG What-If Index Advisor: Session-isolated hypothetical index creation and plan evaluation with strict zero-residue catalog cleanup and automated safety audits.
- Source Coverage Ledger: Comprehensive dialect mapping covering 1,997 test cases.
⚡ Infrastructure, Concurrency & Security
- Thread-Safe Caching: Generic bounded LRU cache with snapshot fingerprinting and
singleflightdeduplication under high concurrency. - Strict Read-Only Boundary: Enforces read-only database operations (
EXPLAINwithoutANALYZE). Never executes caller SQL or recommended DDL on target servers. - 0 Data Races: Verified with
go test -raceacross all packages.
🧪 Soak Testing, Demos & Documentation
- Docker MySQL Demo: Turn-key containerized demo with interactive Web UI (
examples/docker_mysql). - Endurance Testing: 90-minute MySQL Soak stress test (
tests/soak/mysql). - Documentation: Full bilingual (English & Simplified Chinese) documentation, developer guides, rule manuals, and quality qualification reports.
🛠 Bug Fixes
- Fixed missing EXPLAIN details and relation binding across subqueries and virtual tables.
- Fixed correlated scalar subquery evaluation and covering index projection calculations.
- Fixed legacy EXPLAIN decoding under MySQL 5.7.
- Handled partial candidate index failures gracefully in the HypoPG what-if pipeline.
📚 Documentation & Reference
- Release Documentation: v0.4.0 Release Notes
- Qualification & Quality Gates: v0.4.0 Test Report
- Interactive Demo: Docker MySQL Quickstart
- API Reference: OpenAPI 3.0 Spec
Full Changelog: v0.3.1...v0.4.0