SOAR (SQL Optimizer And Rewriter): Installation, Configuration, and Practical Use Cases
This article introduces Xiaomi's open‑source SOAR tool, explains how to download and install the binary or source versions, walks through quick‑start commands, details key YAML configuration options and output formats, and describes four typical usage scenarios for SQL optimization and rewriting.
On October 20th, Xiaomi open‑sourced SOAR (SQL Optimizer And Rewriter), a Go‑based tool that checks SQL quality, generates evaluation reports, and helps prevent problematic SQL from reaching production.
Installation : SOAR provides pre‑compiled binaries for various operating systems on GitHub Releases; advanced users can download the source code and compile it as shown in the accompanying screenshots.
Quick Start : After installation, no additional configuration is required—simply run the provided command to produce a Markdown‑formatted SQL review report, which can be used to improve the SQL statements.
Configuration : SOAR uses a YAML configuration file. Most users only need to set a few parameters such as online-dsn , test-dsn , and log-output . Important settings include specifying database environments (online and test) and the allow-online-as-test flag to prevent accidental use of the production database as a test environment.
Output Formats : Besides the default Markdown, SOAR can output results in HTML or JSON. It supports 15 report types (e.g., SQL rewrite, EXPLAIN analysis, fingerprinting, beautification) that can be listed via a command.
Help & Community : For additional configuration details, refer to the project documentation. Issues can be submitted on GitHub, and real‑time assistance is available on Gitter.
Use Cases :
Scenario 1 – Both online and test environments are available; SOAR provides full recommendations, index analysis, EXPLAIN, PROFILE, and comprehensive SQL rewriting.
Scenario 2 – No online environment, only a test environment; SOAR creates a test database from DDL and performs optimization.
Scenario 3 – Neither environment is configured; SOAR operates in a degraded mode, offering heuristic suggestions and limited rewriting, suitable for local linting.
Scenario 4 – Only an online environment is configured and allowed as test; this is discouraged due to potential risks.
References: YAML specification, SOAR GitHub issues, and Gitter community links are provided for further reading.
DevOps Cloud Academy
Exploring industry DevOps practices and technical expertise.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.