SOAR
SOAR(SQL Optimizer And Rewriter)是一个对SQL进行优化和改写的自动化工具。 由小米人工智能与云平台的数据库团队开发与维护。
功能特点跨平台支持(支持Linux, Mac环境,Windows环境理论上也支持,不过未全面测试)
目前只支持 MySQL 语法族协议的SQL优化
支持基于启发式算法的语句优化
支持复杂查询的多列索引优化(UPDATE, INSERT, DELETE, SELECT)
支持EXPLAIN信息丰富解读
支持SQL指纹、压缩和美化
支持同一张表多条ALTER请求合并
支持自定义规则的SQL改写
使用方法下载 https://github.com/XiaoMi/soar/releases soar.windows-amd64 并修改文件名为 soar.exe,,放在soar文件夹
进入soar目录,cmd命令行输入,soar -version,输出如下信息,则安装成功
3.输入soar -h 获取帮助信息Usage of soar:
-allow-charsets string
AllowCharsets (default "utf8,utf8mb4")
-allow-collates string
AllowCollates
-allow-drop-index
AllowDropIndex, 允许输出删除重复索引的建议
-allow-engines string
AllowEngines (default "innodb")
-allow-online-as-test
AllowOnlineAsTest, 允许线上环境也可以当作测试环境 (default true)
-alsologtostderr
log to standard error as well as files
-blacklist string
指定 blacklist 配置文件的位置,文件中的 SQL 不会被评审。一行一条SQL,可以是指纹,也可
以是正则
-check-config
Check configs
-cleanup-test-database
单次运行清理历史1小时前残余的测试库。
-column-not-allow-type string
ColumnNotAllowType (default "boolean")
-config string
Config file path
-delimiter string
Delimiter, SQL分隔符 (default ";")
-drop-test-temporary
DropTestTemporary, 是否清理测试环境产生的临时库表 (default true)
-dry-run
是否在预演环境执行 (default true)
-explain
Explain, 是否开启Explain执行计划分析 (default true)
-explain-format string
ExplainFormat [json, traditional] (default "traditional")
-explain-max-filtered float
ExplainMaxFiltered, filtered大于该配置给出警告 (default 100)
-explain-max-keys int
ExplainMaxKeyLength, 最大key_len (default 3)
-explain-max-rows int
ExplainMaxRows, 最大扫描行数警告 (default 10000)
-explain-min-keys int
ExplainMinPossibleKeys, 最小possible_keys警告
-explain-sql-report-type string
ExplainSQLReportType [pretty, sample, fingerprint] (default "pretty")
-explain-type string
ExplainType [exte