[#4974] Egh... Beginner's mistake :-(
This commit is contained in:
parent
56b94db805
commit
830dff74e8
@ -229,7 +229,11 @@ public abstract class AbstractDatabase implements Database {
|
||||
|
||||
@Override
|
||||
public void executeEnd(ExecuteContext ctx) {
|
||||
if (((StopWatch) ctx.data("org.jooq.util.AbstractDatabase.watch")).split() > 5 * 1000 * 1000 * 1000)
|
||||
StopWatch watch = (StopWatch) ctx.data("org.jooq.util.AbstractDatabase.watch");
|
||||
|
||||
if (watch.split() > 5L * 1000 * 1000 * 1000) {
|
||||
watch.splitWarn("Slow SQL");
|
||||
|
||||
log.warn(
|
||||
"Slow SQL",
|
||||
"jOOQ Meta executed a slow query (slower than 5 seconds)"
|
||||
@ -237,6 +241,7 @@ public abstract class AbstractDatabase implements Database {
|
||||
+ "Please report this bug here: https://github.com/jOOQ/jOOQ/issues/new\n\n"
|
||||
+ formatted(ctx.query()),
|
||||
new SQLPerformanceWarning());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -124,6 +124,24 @@ public final class StopWatch {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Split the time and warn log a message, if trace logging is enabled
|
||||
*/
|
||||
public void splitWarn(String message) {
|
||||
log.warn(message, splitMessage(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Split the time and warn log a message if the split time exceeds a
|
||||
* certain threshold and if trace logging is enabled
|
||||
*/
|
||||
public void splitWarn(String message, long thresholdNano) {
|
||||
String splitMessage = splitMessage(thresholdNano);
|
||||
|
||||
if (splitMessage != null)
|
||||
log.warn(message, splitMessage);
|
||||
}
|
||||
|
||||
public long split() {
|
||||
return System.nanoTime() - start;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user