diff --git a/src/main/java/com/actiontech/dble/statistic/trace/TraceResult.java b/src/main/java/com/actiontech/dble/statistic/trace/TraceResult.java index 6ff243ae96..62a7d2c4c5 100644 --- a/src/main/java/com/actiontech/dble/statistic/trace/TraceResult.java +++ b/src/main/java/com/actiontech/dble/statistic/trace/TraceResult.java @@ -285,7 +285,7 @@ public void setResponseTime(boolean isSuccess, long time, long timeMs) { schema, sql, sqlType, currentSession.getShardingService().getTxId(), examinedRows, sqlRows, netOutBytes, resultSize, requestEnd, requestEndMs, new ArrayList(tableList)); StatisticManager.getInstance().push(f); - if (isDetailTrace) { + if (isDetailTrace && getOverAllMilliSecond() > SlowQueryLog.getInstance().getSlowTime()) { SlowQueryLog.getInstance().putSlowQueryLog(currentSession.getShardingService(), this.clone()); } if (LOGGER.isDebugEnabled()) { @@ -453,6 +453,10 @@ public SqlTraceType getType() { return this.type; } + public double getOverAllMilliSecond() { + return (double) (this.requestEnd - this.requestStart) / 1000000000; + } + public String getOverAllSecond() { double milliSecond = (double) (this.requestEnd - this.requestStart) / 1000000000; return String.format("%.6f", milliSecond);