You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by sh...@apache.org on 2026/10/01 08:16:16 UTC
(asterixdb) branch master updated: [NO ISSUE][COMP] Don't cache CLUSTER BY plans with a drawn seed
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git
The following commit(s) were added to refs/heads/master by this push:
new 2742ec0025 [NO ISSUE][COMP] Don't cache CLUSTER BY plans with a drawn seed
2742ec0025 is described below
commit 2742ec00254cbeda6497d9ebffdcd7b6e20fa93c
Author: Shahrzad Shirazi <Sh...@couchbase.com>
AuthorDate: Wed Sep 30 23:06:01 2026 -0700
[NO ISSUE][COMP] Don't cache CLUSTER BY plans with a drawn seed
A statement can opt out of the plan cache during rewriting
by setting compiler.query.plan.cache=false on its own
MetadataProvider. A K-Means CLUSTER BY with no 'seed' does
this: it draws a seed at rewrite time, so its plan is only
valid for that run.
The opt-out never took effect. resolveQueryPlanCacheKey()
runs before rewriteCompileQuery(), so the key is built while
the cache is still enabled. The key keeps its own copy of
the config, so setting the property afterwards doesn't
change it. compileCacheMissResult() then caches the plan
whenever the key is non-null. On the next run the rewrite
draws a new seed, but compileQuery() uses the cached plan,
so the first seed is reused every time.
The miss path now checks isIgnoreCache() again after
compiling. The key is still resolved first, because
rewriting runs inside rewriteCompileQuery() and moving the
lookup after it would mean splitting that path. The hit path
needs no change: a statement that opts out is never stored,
so it can never be found. Putting the seed in the key
wouldn't help either, since it's drawn fresh each run.
Any other rewrite that sets this property per statement now
has the same effect: it skips storing the plan but still
pays for the lookup.
Ext-ref: MB-73589
Generated-by: Claude Opus 5.5 <no...@anthropic.com>
Change-Id: I4003de47c906f84bce686cadb6fc0c020d2f26b0
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/21955
Reviewed-by: Rithwik Koul <ri...@couchbase.com>
Reviewed-by: Murtadha Hubail <mh...@apache.org>
Tested-by: Shahrzad Shirazi <sh...@ucr.edu>
---
.../main/java/org/apache/asterix/app/translator/QueryTranslator.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
index 3826f8376b..f1cd96b8db 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
@@ -6117,7 +6117,9 @@ public class QueryTranslator extends AbstractLangTranslator implements IStatemen
final JobSpecification jobSpec = rewriteCompileQuery(hcc, metadataProvider, query, null, stmtParams,
requestParameters, resultMetadata, null);
final CompiledPlan compiledPlan = apiFramework.getLastCompiledPlan();
- if (cacheKey == null || compiledPlan == null) {
+ // the key is resolved before rewriting, but a rewrite can opt this statement out of the cache (e.g. a
+ // CLUSTER BY whose seed was drawn at compile time), so the plan must not be cached under that key
+ if (cacheKey == null || compiledPlan == null || isIgnoreCache(metadataProvider, requestParameters)) {
return new CacheMissResult(jobSpec, null);
}
final Set<Warning> warnings = new LinkedHashSet<>();