Skip to content

Releases

v0.4.0

Choose a tag to compare

@ikenchina ikenchina released this 28 Nov 04:52

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.0

2. Unified Public Analysis Contract (v2)

  • Replaced dialect-specific report formats with a unified pkg/analysis.Report model 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: INFO
  • 2: NOTICE
  • 3: WARNING
  • 4: ERROR
  • 5: 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 to libpg_query AST parser bindings.

🚀 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, and SQL_CALC_FOUND_ROWS overhead tracking.
    • Subquery modeling for multi-table/nested EXISTS, semi-join materialization, and FirstMatch.
    • Distinguishes streaming vs. temporary table GROUP BY and aggregation costs.
  • 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 singleflight deduplication under high concurrency.
  • Strict Read-Only Boundary: Enforces read-only database operations (EXPLAIN without ANALYZE). Never executes caller SQL or recommended DDL on target servers.
  • 0 Data Races: Verified with go test -race across 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


Full Changelog: v0.3.1...v0.4.0