diff --git a/core/src/main/java/com/arangodb/model/AqlQueryOptions.java b/core/src/main/java/com/arangodb/model/AqlQueryOptions.java index f51f419b2..6b223b82d 100644 --- a/core/src/main/java/com/arangodb/model/AqlQueryOptions.java +++ b/core/src/main/java/com/arangodb/model/AqlQueryOptions.java @@ -236,6 +236,7 @@ public static final class Options implements Cloneable { private Long spillOverThresholdMemoryUsage; private Long spillOverThresholdNumRows; private Boolean stream; + private Boolean usePlanCache; @JsonInclude @JsonAnyGetter @@ -354,6 +355,10 @@ public Boolean getStream() { return stream; } + public Boolean getUsePlanCache() { + return usePlanCache; + } + public void setAllPlans(Boolean allPlans) { this.allPlans = allPlans; } @@ -446,6 +451,10 @@ public void setStream(Boolean stream) { this.stream = stream; } + public void setUsePlanCache(Boolean usePlanCache) { + this.usePlanCache = usePlanCache; + } + @Override public Options clone() { try { @@ -961,6 +970,11 @@ public Boolean getStream() { return getOptions().getStream(); } + @JsonIgnore + public Boolean getUsePlanCache() { + return getOptions().getUsePlanCache(); + } + /** * @param stream Specify true and the query will be executed in a streaming fashion. The query result is not * stored on @@ -983,6 +997,20 @@ public AqlQueryOptions stream(final Boolean stream) { return this; } + /** + * @param usePlanCache Set this option to true to utilize a cached query plan or add the execution plan of this + * query to the cache if it’s not in the cache yet. Otherwise, the plan cache is bypassed + * (introduced in v3.12.4). + * Query plan caching can reduce the total time for processing queries by avoiding to parse, + * plan, and optimize queries over and over again that effectively have the same execution plan + * with at most some changes to bind parameter values. + * @return this + */ + public AqlQueryOptions usePlanCache(final Boolean usePlanCache) { + getOptions().setUsePlanCache(usePlanCache); + return this; + } + @JsonIgnore public Collection getRules() { return getOptions().getOptimizer().getRules(); diff --git a/core/src/main/java/com/arangodb/model/ExplainAqlQueryOptions.java b/core/src/main/java/com/arangodb/model/ExplainAqlQueryOptions.java index 4d4d2f511..60d82f51e 100644 --- a/core/src/main/java/com/arangodb/model/ExplainAqlQueryOptions.java +++ b/core/src/main/java/com/arangodb/model/ExplainAqlQueryOptions.java @@ -554,6 +554,11 @@ public Boolean getStream() { return getOptions().getStream(); } + @JsonIgnore + public Boolean getUsePlanCache() { + return getOptions().getUsePlanCache(); + } + /** * @param stream Specify true and the query will be executed in a streaming fashion. The query result is not * stored on @@ -576,6 +581,20 @@ public ExplainAqlQueryOptions stream(final Boolean stream) { return this; } + /** + * @param usePlanCache Set this option to true to utilize a cached query plan or add the execution plan of this + * query to the cache if it’s not in the cache yet. Otherwise, the plan cache is bypassed + * (introduced in v3.12.4). + * Query plan caching can reduce the total time for processing queries by avoiding to parse, + * plan, and optimize queries over and over again that effectively have the same execution plan + * with at most some changes to bind parameter values. + * @return this + */ + public ExplainAqlQueryOptions usePlanCache(final Boolean usePlanCache) { + getOptions().setUsePlanCache(usePlanCache); + return this; + } + @JsonIgnore public Collection getRules() { return getOptions().getOptimizer().getRules(); diff --git a/test-functional/src/test/java/com/arangodb/model/AqlQueryOptionsTest.java b/test-functional/src/test/java/com/arangodb/model/AqlQueryOptionsTest.java index 39e9c1c43..c779464a1 100644 --- a/test-functional/src/test/java/com/arangodb/model/AqlQueryOptionsTest.java +++ b/test-functional/src/test/java/com/arangodb/model/AqlQueryOptionsTest.java @@ -15,11 +15,13 @@ void cloneable() { AqlQueryOptions options = new AqlQueryOptions() .cache(true) .stream(true) + .usePlanCache(true) .rules(rules) .shardIds("a", "b"); AqlQueryOptions clone = options.clone(); assertThat(clone.getCache()).isEqualTo(options.getCache()); assertThat(clone.getStream()).isEqualTo(options.getStream()); + assertThat(clone.getUsePlanCache()).isEqualTo(options.getUsePlanCache()); assertThat(clone.getRules()) .isEqualTo(options.getRules()) .isNotSameAs(options.getRules());