diff --git a/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java b/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java index 1cbfa9d3e..c4195f0be 100644 --- a/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java +++ b/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java @@ -500,15 +500,15 @@ public class DatabaseConfig { /** * Set to true to enable bind capture required for query plan capture. */ - private boolean collectQueryPlans; + private boolean queryPlanEnable; /** * The default threshold in micros for collecting query plans. */ - private long collectQueryPlanThresholdMicros = Long.MAX_VALUE; + private long queryPlanThresholdMicros = Long.MAX_VALUE; /** - * Set to true to enable automatic query plan capture. + * Set to true to enable automatic periodic query plan capture. */ private boolean queryPlanCapture; private long queryPlanCapturePeriodSecs = 60 * 10; // 10 minutes @@ -2813,8 +2813,8 @@ public class DatabaseConfig { dumpMetricsOptions = p.get("dumpMetricsOptions", dumpMetricsOptions); queryPlanTTLSeconds = p.getInt("queryPlanTTLSeconds", queryPlanTTLSeconds); slowQueryMillis = p.getLong("slowQueryMillis", slowQueryMillis); - collectQueryPlans = p.getBoolean("collectQueryPlans", collectQueryPlans); - collectQueryPlanThresholdMicros = p.getLong("collectQueryPlanThresholdMicros", collectQueryPlanThresholdMicros); + queryPlanEnable = p.getBoolean("queryPlan.enable", queryPlanEnable); + queryPlanThresholdMicros = p.getLong("queryPlan.thresholdMicros", queryPlanThresholdMicros); queryPlanCapture = p.getBoolean("queryPlan.capture", queryPlanCapture); queryPlanCapturePeriodSecs = p.getLong("queryPlan.capturePeriodSecs", queryPlanCapturePeriodSecs); queryPlanCaptureMaxTimeMillis = p.getLong("queryPlan.captureMaxTimeMillis", queryPlanCaptureMaxTimeMillis); @@ -3188,29 +3188,32 @@ public class DatabaseConfig { /** * Return true if query plan capture is enabled. */ - public boolean isCollectQueryPlans() { - return collectQueryPlans; + public boolean isQueryPlanEnable() { + return queryPlanEnable; } /** * Set to true to enable query plan capture. */ - public void setCollectQueryPlans(boolean collectQueryPlans) { - this.collectQueryPlans = collectQueryPlans; + public void setQueryPlanEnable(boolean queryPlanEnable) { + this.queryPlanEnable = queryPlanEnable; } /** * Return the query plan collection threshold in microseconds. */ - public long getCollectQueryPlanThresholdMicros() { - return collectQueryPlanThresholdMicros; + public long getQueryPlanThresholdMicros() { + return queryPlanThresholdMicros; } /** * Set the query plan collection threshold in microseconds. + *

+ * Queries executing slower than this will have bind values captured such that later + * the query plan can be captured and reported. */ - public void setCollectQueryPlanThresholdMicros(long collectQueryPlanThresholdMicros) { - this.collectQueryPlanThresholdMicros = collectQueryPlanThresholdMicros; + public void setQueryPlanThresholdMicros(long queryPlanThresholdMicros) { + this.queryPlanThresholdMicros = queryPlanThresholdMicros; } /** diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/InternalConfiguration.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/InternalConfiguration.java index 56ea7589a..8cbbbfa4b 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/InternalConfiguration.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/InternalConfiguration.java @@ -617,10 +617,10 @@ public class InternalConfiguration { } public QueryPlanManager initQueryPlanManager(TransactionManager transactionManager) { - if (!config.isCollectQueryPlans()) { + if (!config.isQueryPlanEnable()) { return QueryPlanManager.NOOP; } - long threshold = config.getCollectQueryPlanThresholdMicros(); + long threshold = config.getQueryPlanThresholdMicros(); return new CQueryPlanManager(transactionManager, threshold, queryPlanLogger(databasePlatform.getPlatform()), extraMetrics); } diff --git a/ebean-core/src/test/java/io/ebean/config/ServerConfigTest.java b/ebean-core/src/test/java/io/ebean/config/ServerConfigTest.java index b23ccdbb6..f93c18d26 100644 --- a/ebean-core/src/test/java/io/ebean/config/ServerConfigTest.java +++ b/ebean-core/src/test/java/io/ebean/config/ServerConfigTest.java @@ -72,10 +72,11 @@ public class ServerConfigTest { props.setProperty("enabledL2Regions", "r0,users,orgs"); props.setProperty("caseSensitiveCollation", "false"); props.setProperty("loadModuleInfo", "true"); - props.setProperty("collectQueryPlanThresholdMicros", "10000"); props.setProperty("forUpdateNoKey", "true"); props.setProperty("defaultServer", "false"); + props.setProperty("queryPlan.enable", "true"); + props.setProperty("queryPlan.thresholdMicros", "10000"); props.setProperty("queryPlan.capture", "true"); props.setProperty("queryPlan.capturePeriodSecs", "42"); props.setProperty("queryPlan.captureMaxTimeMillis", "560"); @@ -102,7 +103,6 @@ public class ServerConfigTest { assertEquals(PlatformConfig.DbUuid.BINARY, serverConfig.getPlatformConfig().getDbUuid()); assertEquals(JsonConfig.DateTime.MILLIS, serverConfig.getJsonDateTime()); assertEquals(JsonConfig.Date.MILLIS, serverConfig.getJsonDate()); - assertEquals(10000, serverConfig.getCollectQueryPlanThresholdMicros()); assertEquals("r0,users,orgs", serverConfig.getEnabledL2Regions()); @@ -111,6 +111,8 @@ public class ServerConfigTest { assertEquals(4, serverConfig.getBackgroundExecutorSchedulePoolSize()); assertEquals(98, serverConfig.getBackgroundExecutorShutdownSecs()); + assertTrue(serverConfig.isQueryPlanEnable()); + assertEquals(10000, serverConfig.getQueryPlanThresholdMicros()); assertTrue(serverConfig.isQueryPlanCapture()); assertEquals(42, serverConfig.getQueryPlanCapturePeriodSecs()); assertEquals(560, serverConfig.getQueryPlanCaptureMaxTimeMillis()); @@ -154,8 +156,9 @@ public class ServerConfigTest { assertEquals(JsonConfig.Date.ISO8601, serverConfig.getJsonDate()); assertTrue(serverConfig.getPlatformConfig().isCaseSensitiveCollation()); assertTrue(serverConfig.isAutoLoadModuleInfo()); - assertEquals(Long.MAX_VALUE, serverConfig.getCollectQueryPlanThresholdMicros()); + assertFalse(serverConfig.isQueryPlanEnable()); + assertEquals(Long.MAX_VALUE, serverConfig.getQueryPlanThresholdMicros()); assertFalse(serverConfig.isQueryPlanCapture()); assertEquals(600, serverConfig.getQueryPlanCapturePeriodSecs()); assertEquals(10000L, serverConfig.getQueryPlanCaptureMaxTimeMillis()); diff --git a/ebean-core/src/test/resources/ebean.properties b/ebean-core/src/test/resources/ebean.properties index 953d2c720..aa1210739 100644 --- a/ebean-core/src/test/resources/ebean.properties +++ b/ebean-core/src/test/resources/ebean.properties @@ -27,8 +27,8 @@ datasource.default=h2 ebean.dumpMetricsOnShutdown=true ebean.dumpMetricsOptions=sql,hash -#ebean.collectQueryPlanThresholdMicros=1000 -ebean.collectQueryPlans=true +#ebean.queryPlan.thresholdMicros=1000 +ebean.queryPlan.enable=true ebean.autoReadOnlyDataSource=true #datasource.h2-ro.url=jdbc:h2:mem:tests