提交 77a48f16 编写于 作者: martianzhang's avatar martianzhang

add max_execution_time hint for explain query

  SELECT /*+ MAX_EXECUTION_TIME(1000) */
上级 82efd3c2
...@@ -564,6 +564,11 @@ func (db *Connector) explainQuery(sql string, explainType int, formatType int) s ...@@ -564,6 +564,11 @@ func (db *Connector) explainQuery(sql string, explainType int, formatType int) s
sql, err = db.explainAbleSQL(sql) sql, err = db.explainAbleSQL(sql)
if sql == "" || err != nil { if sql == "" || err != nil {
return sql return sql
} else {
// MySQL 5.7 support MAX_EXECUTION_TIME hint
// ref: https://dev.mysql.com/doc/refman/5.7/en/optimizer-hints.html
re := regexp.MustCompile(`(?i)(^select)(.*)`)
sql = re.ReplaceAllString(sql, "SELECT /*+ MAX_EXECUTION_TIME(1000) */${2}")
} }
// 5.6以上支持 FORMAT=JSON // 5.6以上支持 FORMAT=JSON
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册