diff --git a/executor/adapter.go b/executor/adapter.go index dc1c2f7109ccf..1964b4a7a66d6 100644 --- a/executor/adapter.go +++ b/executor/adapter.go @@ -839,8 +839,9 @@ func (a *ExecStmt) LogSlowQuery(txnTS uint64, succ bool, hasMoreResults bool) { costTime := time.Since(sessVars.StartTime) + sessVars.DurationParse threshold := time.Duration(atomic.LoadUint64(&cfg.Log.SlowThreshold)) * time.Millisecond enable := cfg.Log.EnableSlowLog - // if the level is Debug, print slow logs anyway - if (!enable || costTime < threshold) && level > zapcore.DebugLevel { + // if the level is Debug, or trace is enabled, print slow logs anyway + force := level <= zapcore.DebugLevel || trace.IsEnabled() + if (!enable || costTime < threshold) && !force { return } var sql stringutil.StringerFunc