Closed Ilcyb closed 5 years ago
请提供您的soar -print-config
输出
请提供您的
soar -print-config
输出online-dsn: addr: "" schema: information_schema user: "" password: '********' charset: utf8mb4 disable: true test-dsn: addr: "" schema: information_schema user: "" password: '********' charset: utf8mb4 disable: true allow-online-as-test: false drop-test-temporary: true only-syntax-check: false sampling-statistic-target: 100 sampling: false profiling: false trace: false explain: true conn-time-out: 3 query-time-out: 30 delimiter: ; log-level: 3 log-output: /dev/stderr report-type: markdown report-css: "" report-javascript: "" report-title: SQL优化分析报告 markdown-extensions: 94 markdown-html-flags: 0 ignore-rules: - COL.011 rewrite-rules: - delimiter - orderbynull - groupbyconst - dmlorderby - having - star2columns - insertcolumns - distinctstar blacklist: "" max-join-table-count: 5 max-group-by-cols-count: 5 max-distinct-count: 5 max-index-cols-count: 5 max-total-rows: 9999999 max-query-cost: 9999 spaghetti-query-length: 2048 allow-drop-index: false max-in-count: 10 max-index-bytes-percolumn: 767 max-index-bytes: 3072 table-allow-charsets: - utf8 - utf8mb4 table-allow-engines: - innodb max-index-count: 10 max-column-count: 40 index-prefix: idx_ unique-key-prefix: uk_ max-subquery-depth: 5 max-varchar-length: 1024 explain-sql-report-type: pretty explain-type: extended explain-format: traditional explain-warn-select-type: - "" explain-warn-access-type: - ALL explain-max-keys: 3 explain-min-keys: 0 explain-max-rows: 10000 explain-warn-extra: - Using temporary - Using filesort explain-max-filtered: 100 explain-warn-scalability: - O(n) show-warnings: false show-last-query-cost: false query: "" list-heuristic-rules: false list-rewrite-rules: false list-test-sqls: false list-report-types: false verbose: false dry-run: true max-pretty-sql-length: 1024
一般指定了数据库但是没有 EXPLAIN 和 INDEX 优化信息往往是数据库连接异常所致。可以修改一下 logout 和 loglevel,看一下日志里的信息。
从提供的配置文件看,您未创建配置文件,命令行参数也未指定-online-dsn, -test-dsn,所以-print-config的输出中online-dsn和test-dsn输出的都为空。
另外提示一下,如果用户名或密码中有特殊字符需要通过配置文件配置,命令行中不支持存在特殊字符的账号和密码。
从提供的配置文件看,您未创建配置文件,命令行参数也未指定-online-dsn, -test-dsn,所以-print-config的输出中online-dsn和test-dsn输出的都为空。
另外提示一下,如果用户名或密码中有特殊字符需要通过配置文件配置,命令行中不支持存在特殊字符的账号和密码。
指定了-test-dsn的时候也不会去连接数据库给出建议
online-dsn:
addr: ""
schema: information_schema
user: ""
password: '********'
charset: utf8mb4
disable: true
test-dsn:
addr: 192.168.10.10:3306
schema: puzzle
user: root
password: '********'
charset: utf8mb4
disable: false
allow-online-as-test: false
drop-test-temporary: true
only-syntax-check: false
sampling-statistic-target: 100
sampling: false
profiling: false
trace: false
explain: true
conn-time-out: 3
query-time-out: 30
delimiter: ;
log-level: 3
log-output: /dev/stderr
report-type: text
report-css: ""
report-javascript: ""
report-title: SQL优化分析报告
markdown-extensions: 94
markdown-html-flags: 0
ignore-rules:
- COL.011
rewrite-rules:
- delimiter
- orderbynull
- groupbyconst
- dmlorderby
- having
- star2columns
- insertcolumns
- distinctstar
blacklist: ""
max-join-table-count: 5
max-group-by-cols-count: 5
max-distinct-count: 5
max-index-cols-count: 5
max-total-rows: 9999999
max-query-cost: 9999
spaghetti-query-length: 2048
allow-drop-index: false
max-in-count: 10
max-index-bytes-percolumn: 767
max-index-bytes: 3072
table-allow-charsets:
- utf8
- utf8mb4
table-allow-engines:
- innodb
max-index-count: 10
max-column-count: 40
index-prefix: idx_
unique-key-prefix: uk_
max-subquery-depth: 5
max-varchar-length: 1024
explain-sql-report-type: pretty
explain-type: extended
explain-format: traditional
explain-warn-select-type:
- ""
explain-warn-access-type:
- ALL
explain-max-keys: 3
explain-min-keys: 0
explain-max-rows: 10000
explain-warn-extra:
- Using temporary
- Using filesort
explain-max-filtered: 100
explain-warn-scalability:
- O(n)
show-warnings: false
show-last-query-cost: false
query: SELECT * FROM products WHERE ppid>12
list-heuristic-rules: false
list-rewrite-rules: false
list-test-sqls: false
list-report-types: false
verbose: false
dry-run: true
max-pretty-sql-length: 1024
如果您只有一个测试环境可以在配置文件中将online-dsn和test-dsn配置为同一个,且将allow-online-as-test配置为true。
如果还是报错可以将log-level设置为7级,看一下日志中的错误信息。
根据文档中给出的-test-dsn和-online-dsn参数来指定了数据库连接字符串,但是给出的结果和我指定连接的数据库没有任何关系,看起来就像只会根据给的sql语句进行分析而不会结合具体的数据库情况