Skip to content

[DE-973] Query plan caching #609

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions core/src/main/java/com/arangodb/model/AqlQueryOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -354,6 +355,10 @@ public Boolean getStream() {
return stream;
}

public Boolean getUsePlanCache() {
return usePlanCache;
}

public void setAllPlans(Boolean allPlans) {
this.allPlans = allPlans;
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand All @@ -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<String> getRules() {
return getOptions().getOptimizer().getRules();
Expand Down
19 changes: 19 additions & 0 deletions core/src/main/java/com/arangodb/model/ExplainAqlQueryOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<String> getRules() {
return getOptions().getOptimizer().getRules();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down