explaingit

xiaomi/soar

8,774GoAudience · ops devopsComplexity · 3/5LicenseSetup · moderate

TLDR

Command-line tool from Xiaomi that analyzes MySQL SQL statements and automatically suggests performance improvements, index recommendations, and query rewrites without needing to manually read execution plans.

Mindmap

mindmap
  root((SOAR))
    What it does
      Analyzes SQL queries
      Suggests indexes
      Rewrites SQL
    Features
      EXPLAIN parser
      Index recommendations
      SQL formatting
      ALTER merge
    Custom rules
      Team SQL conventions
      Auto correction
    Platforms
      Linux
      Mac
      Windows partial
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Run a slow MySQL query through SOAR to get specific index recommendations and a plain-English EXPLAIN breakdown

USE CASE 2

Use SOAR's SQL formatter to normalize and compress query strings in a codebase for readability

USE CASE 3

Merge multiple ALTER TABLE statements targeting the same table into one command to avoid repeated table locks during schema changes

Tech stack

GoMySQL

Getting it running

Difficulty · moderate Time to first run · 30min

Requires a running MySQL instance to connect to for EXPLAIN analysis and index suggestion.

Apache 2.0, use freely in any commercial or private project, just retain the copyright notice.

In plain English

SOAR stands for SQL Optimizer And Rewriter. It is a command-line tool, built by Xiaomi's database team, that analyzes MySQL SQL statements and suggests or applies improvements automatically. It was designed to help developers and database administrators write better-performing queries without needing to manually trace every execution plan. The tool works by examining submitted SQL and applying a set of heuristic optimization rules. For queries that could benefit from additional indexes, SOAR can suggest multi-column index structures covering SELECT, INSERT, UPDATE, and DELETE operations. It can also parse the output of MySQL's EXPLAIN command and translate the technical details into a more readable explanation, making it easier to understand why a query is running slowly. Beyond optimization advice, SOAR can reformat and compress SQL for readability, generate a fingerprint (a normalized version of the statement with literal values removed), and merge multiple ALTER TABLE statements targeting the same table into one, which avoids the cost of repeated table locking during schema changes. Custom rewrite rules are also supported, so teams can encode their own SQL conventions and have SOAR flag or automatically correct statements that violate them. The README and most of the linked documentation are written in Chinese. A separate English README file is available in the repository. The tool runs on Linux and Mac, with Windows supported in principle though not fully tested. It is released under the Apache 2.0 license.

Copy-paste prompts

Prompt 1
I have a slow MySQL SELECT with multiple JOINs, show me the SOAR command to analyze it and explain the index recommendations it gives
Prompt 2
How do I use SOAR to merge several ALTER TABLE statements on the same table into a single operation to reduce locking?
Prompt 3
Set up a SOAR custom rewrite rule that flags any SQL query missing a WHERE clause in an UPDATE or DELETE statement
Open on GitHub → Explain another repo

← xiaomi on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.