#[cfg(feature = "perf-attribution")]
use crate::db::executor::ScalarExecutePhaseAttribution;
use crate::{
db::{
DbSession, EntityResponse, LoadQueryResult, PagedGroupedExecutionWithTrace,
PagedLoadExecutionWithTrace, PersistedRow, Query, QueryError, QueryTracePlan,
access::AccessStrategy,
commit::CommitSchemaFingerprint,
cursor::{
CursorPlanError, decode_optional_cursor_token, decode_optional_grouped_cursor_token,
},
diagnostics::ExecutionTrace,
executor::{
ExecutionFamily, GroupedCursorPage, LoadExecutor, PreparedExecutionPlan,
SharedPreparedExecutionPlan,
},
query::builder::{
PreparedFluentAggregateExplainStrategy, PreparedFluentProjectionStrategy,
},
query::explain::{
ExplainAggregateTerminalPlan, ExplainExecutionNodeDescriptor, ExplainPlan,
},
query::{
intent::{CompiledQuery, PlannedQuery, StructuralQuery},
plan::{AccessPlannedQuery, QueryMode, VisibleIndexes},
},
},
error::InternalError,
model::entity::EntityModel,
traits::{CanisterKind, EntityKind, EntityValue, Path},
};
#[cfg(feature = "perf-attribution")]
use candid::CandidType;
use icydb_utils::Xxh3;
#[cfg(feature = "perf-attribution")]
use serde::Deserialize;
use std::{cell::RefCell, collections::HashMap, hash::BuildHasherDefault};
type CacheBuildHasher = BuildHasherDefault<Xxh3>;
const SHARED_QUERY_PLAN_CACHE_METHOD_VERSION: u8 = 1;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub(in crate::db) enum QueryPlanVisibility {
StoreNotReady,
StoreReady,
}
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
pub(in crate::db) struct QueryPlanCacheKey {
cache_method_version: u8,
entity_path: &'static str,
schema_fingerprint: CommitSchemaFingerprint,
visibility: QueryPlanVisibility,
structural_query: crate::db::query::intent::StructuralQueryCacheKey,
}
#[derive(Clone, Debug)]
pub(in crate::db) struct QueryPlanCacheEntry {
logical_plan: AccessPlannedQuery,
prepared_plan: SharedPreparedExecutionPlan,
}
impl QueryPlanCacheEntry {
#[must_use]
pub(in crate::db) const fn new(
logical_plan: AccessPlannedQuery,
prepared_plan: SharedPreparedExecutionPlan,
) -> Self {
Self {
logical_plan,
prepared_plan,
}
}
#[must_use]
pub(in crate::db) const fn logical_plan(&self) -> &AccessPlannedQuery {
&self.logical_plan
}
#[must_use]
pub(in crate::db) fn typed_prepared_plan<E: EntityKind>(&self) -> PreparedExecutionPlan<E> {
self.prepared_plan.typed_clone::<E>()
}
}
pub(in crate::db) type QueryPlanCache =
HashMap<QueryPlanCacheKey, QueryPlanCacheEntry, CacheBuildHasher>;
thread_local! {
static QUERY_PLAN_CACHES: RefCell<HashMap<usize, QueryPlanCache, CacheBuildHasher>> =
RefCell::new(HashMap::default());
}
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub(in crate::db) struct QueryPlanCacheAttribution {
pub hits: u64,
pub misses: u64,
}
impl QueryPlanCacheAttribution {
#[must_use]
const fn hit() -> Self {
Self { hits: 1, misses: 0 }
}
#[must_use]
const fn miss() -> Self {
Self { hits: 0, misses: 1 }
}
}
#[cfg(feature = "perf-attribution")]
#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq)]
pub struct QueryExecutionAttribution {
pub compile_local_instructions: u64,
pub runtime_local_instructions: u64,
pub finalize_local_instructions: u64,
pub response_decode_local_instructions: u64,
pub execute_local_instructions: u64,
pub total_local_instructions: u64,
pub shared_query_plan_cache_hits: u64,
pub shared_query_plan_cache_misses: u64,
}
#[cfg(feature = "perf-attribution")]
#[expect(
clippy::missing_const_for_fn,
reason = "the wasm32 branch reads the runtime performance counter and cannot be const"
)]
fn read_query_local_instruction_counter() -> u64 {
#[cfg(target_arch = "wasm32")]
{
canic_cdk::api::performance_counter(1)
}
#[cfg(not(target_arch = "wasm32"))]
{
0
}
}
#[cfg(feature = "perf-attribution")]
fn measure_query_stage<T, E>(run: impl FnOnce() -> Result<T, E>) -> (u64, Result<T, E>) {
let start = read_query_local_instruction_counter();
let result = run();
let delta = read_query_local_instruction_counter().saturating_sub(start);
(delta, result)
}
impl<C: CanisterKind> DbSession<C> {
#[cfg(feature = "perf-attribution")]
const fn empty_scalar_execute_phase_attribution() -> ScalarExecutePhaseAttribution {
ScalarExecutePhaseAttribution {
runtime_local_instructions: 0,
finalize_local_instructions: 0,
}
}
fn query_plan_cache_scope_id(&self) -> usize {
self.db.cache_scope_id()
}
fn with_query_plan_cache<R>(&self, f: impl FnOnce(&mut QueryPlanCache) -> R) -> R {
let scope_id = self.query_plan_cache_scope_id();
QUERY_PLAN_CACHES.with(|caches| {
let mut caches = caches.borrow_mut();
let cache = caches.entry(scope_id).or_default();
f(cache)
})
}
const fn visible_indexes_for_model(
model: &'static EntityModel,
visibility: QueryPlanVisibility,
) -> VisibleIndexes<'static> {
match visibility {
QueryPlanVisibility::StoreReady => VisibleIndexes::planner_visible(model.indexes()),
QueryPlanVisibility::StoreNotReady => VisibleIndexes::none(),
}
}
#[cfg(test)]
pub(in crate::db) fn query_plan_cache_len(&self) -> usize {
self.with_query_plan_cache(|cache| cache.len())
}
#[cfg(test)]
pub(in crate::db) fn clear_query_plan_cache_for_tests(&self) {
self.with_query_plan_cache(QueryPlanCache::clear);
}
pub(in crate::db) fn query_plan_visibility_for_store_path(
&self,
store_path: &'static str,
) -> Result<QueryPlanVisibility, QueryError> {
let store = self
.db
.recovered_store(store_path)
.map_err(QueryError::execute)?;
let visibility = if store.index_state() == crate::db::IndexState::Ready {
QueryPlanVisibility::StoreReady
} else {
QueryPlanVisibility::StoreNotReady
};
Ok(visibility)
}
pub(in crate::db) fn cached_query_plan_entry_for_authority(
&self,
authority: crate::db::executor::EntityAuthority,
schema_fingerprint: CommitSchemaFingerprint,
query: &StructuralQuery,
) -> Result<(QueryPlanCacheEntry, QueryPlanCacheAttribution), QueryError> {
let visibility = self.query_plan_visibility_for_store_path(authority.store_path())?;
let cache_key =
QueryPlanCacheKey::for_authority(authority, schema_fingerprint, visibility, query);
{
let cached = self.with_query_plan_cache(|cache| cache.get(&cache_key).cloned());
if let Some(entry) = cached {
return Ok((entry, QueryPlanCacheAttribution::hit()));
}
}
let visible_indexes = Self::visible_indexes_for_model(authority.model(), visibility);
let plan = query.build_plan_with_visible_indexes(&visible_indexes)?;
let entry = QueryPlanCacheEntry::new(
plan.clone(),
SharedPreparedExecutionPlan::from_plan(authority, plan),
);
self.with_query_plan_cache(|cache| {
cache.insert(cache_key, entry.clone());
});
Ok((entry, QueryPlanCacheAttribution::miss()))
}
#[cfg(test)]
pub(in crate::db) fn query_plan_cache_key_for_tests(
authority: crate::db::executor::EntityAuthority,
schema_fingerprint: CommitSchemaFingerprint,
visibility: QueryPlanVisibility,
query: &StructuralQuery,
cache_method_version: u8,
) -> QueryPlanCacheKey {
QueryPlanCacheKey::for_authority_with_method_version(
authority,
schema_fingerprint,
visibility,
query,
cache_method_version,
)
}
pub(in crate::db) fn cached_structural_plan_for_authority(
&self,
authority: crate::db::executor::EntityAuthority,
schema_fingerprint: CommitSchemaFingerprint,
query: &StructuralQuery,
) -> Result<AccessPlannedQuery, QueryError> {
let (entry, _) =
self.cached_query_plan_entry_for_authority(authority, schema_fingerprint, query)?;
Ok(entry.logical_plan().clone())
}
fn with_query_visible_indexes<E, T>(
&self,
query: &Query<E>,
op: impl FnOnce(
&Query<E>,
&crate::db::query::plan::VisibleIndexes<'static>,
) -> Result<T, QueryError>,
) -> Result<T, QueryError>
where
E: EntityKind<Canister = C>,
{
let visibility = self.query_plan_visibility_for_store_path(E::Store::PATH)?;
let visible_indexes = Self::visible_indexes_for_model(E::MODEL, visibility);
op(query, &visible_indexes)
}
fn cached_structural_plan_for_entity<E>(
&self,
query: &StructuralQuery,
) -> Result<AccessPlannedQuery, QueryError>
where
E: EntityKind<Canister = C>,
{
self.cached_structural_plan_for_authority(
crate::db::executor::EntityAuthority::for_type::<E>(),
crate::db::schema::commit_schema_fingerprint_for_entity::<E>(),
query,
)
}
pub(in crate::db::session) fn cached_prepared_query_plan_for_entity<E>(
&self,
query: &StructuralQuery,
) -> Result<(PreparedExecutionPlan<E>, QueryPlanCacheAttribution), QueryError>
where
E: EntityKind<Canister = C>,
{
let (entry, attribution) = self.cached_query_plan_entry_for_authority(
crate::db::executor::EntityAuthority::for_type::<E>(),
crate::db::schema::commit_schema_fingerprint_for_entity::<E>(),
query,
)?;
Ok((entry.typed_prepared_plan::<E>(), attribution))
}
pub(in crate::db) fn compile_query_with_visible_indexes<E>(
&self,
query: &Query<E>,
) -> Result<CompiledQuery<E>, QueryError>
where
E: EntityKind<Canister = C>,
{
let plan = self.cached_structural_plan_for_entity::<E>(query.structural())?;
Ok(Query::<E>::compiled_query_from_plan(plan))
}
pub(in crate::db) fn planned_query_with_visible_indexes<E>(
&self,
query: &Query<E>,
) -> Result<PlannedQuery<E>, QueryError>
where
E: EntityKind<Canister = C>,
{
let plan = self.cached_structural_plan_for_entity::<E>(query.structural())?;
Ok(Query::<E>::planned_query_from_plan(plan))
}
pub(in crate::db) fn explain_query_with_visible_indexes<E>(
&self,
query: &Query<E>,
) -> Result<ExplainPlan, QueryError>
where
E: EntityKind<Canister = C>,
{
self.with_query_visible_indexes(query, |query, visible_indexes| {
query.explain_with_visible_indexes(visible_indexes)
})
}
pub(in crate::db) fn query_plan_hash_hex_with_visible_indexes<E>(
&self,
query: &Query<E>,
) -> Result<String, QueryError>
where
E: EntityKind<Canister = C>,
{
self.with_query_visible_indexes(query, |query, visible_indexes| {
query.plan_hash_hex_with_visible_indexes(visible_indexes)
})
}
pub(in crate::db) fn explain_query_execution_with_visible_indexes<E>(
&self,
query: &Query<E>,
) -> Result<ExplainExecutionNodeDescriptor, QueryError>
where
E: EntityValue + EntityKind<Canister = C>,
{
self.with_query_visible_indexes(query, |query, visible_indexes| {
query.explain_execution_with_visible_indexes(visible_indexes)
})
}
pub(in crate::db) fn explain_query_execution_text_with_visible_indexes<E>(
&self,
query: &Query<E>,
) -> Result<String, QueryError>
where
E: EntityValue + EntityKind<Canister = C>,
{
self.with_query_visible_indexes(query, |query, visible_indexes| {
query.explain_execution_text_with_visible_indexes(visible_indexes)
})
}
pub(in crate::db) fn explain_query_execution_json_with_visible_indexes<E>(
&self,
query: &Query<E>,
) -> Result<String, QueryError>
where
E: EntityValue + EntityKind<Canister = C>,
{
self.with_query_visible_indexes(query, |query, visible_indexes| {
query.explain_execution_json_with_visible_indexes(visible_indexes)
})
}
pub(in crate::db) fn explain_query_execution_verbose_with_visible_indexes<E>(
&self,
query: &Query<E>,
) -> Result<String, QueryError>
where
E: EntityValue + EntityKind<Canister = C>,
{
self.with_query_visible_indexes(query, |query, visible_indexes| {
query.explain_execution_verbose_with_visible_indexes(visible_indexes)
})
}
pub(in crate::db) fn explain_query_prepared_aggregate_terminal_with_visible_indexes<E, S>(
&self,
query: &Query<E>,
strategy: &S,
) -> Result<ExplainAggregateTerminalPlan, QueryError>
where
E: EntityValue + EntityKind<Canister = C>,
S: PreparedFluentAggregateExplainStrategy,
{
self.with_query_visible_indexes(query, |query, visible_indexes| {
query
.explain_prepared_aggregate_terminal_with_visible_indexes(visible_indexes, strategy)
})
}
pub(in crate::db) fn explain_query_bytes_by_with_visible_indexes<E>(
&self,
query: &Query<E>,
target_field: &str,
) -> Result<ExplainExecutionNodeDescriptor, QueryError>
where
E: EntityValue + EntityKind<Canister = C>,
{
self.with_query_visible_indexes(query, |query, visible_indexes| {
query.explain_bytes_by_with_visible_indexes(visible_indexes, target_field)
})
}
pub(in crate::db) fn explain_query_prepared_projection_terminal_with_visible_indexes<E>(
&self,
query: &Query<E>,
strategy: &PreparedFluentProjectionStrategy,
) -> Result<ExplainExecutionNodeDescriptor, QueryError>
where
E: EntityValue + EntityKind<Canister = C>,
{
self.with_query_visible_indexes(query, |query, visible_indexes| {
query.explain_prepared_projection_terminal_with_visible_indexes(
visible_indexes,
strategy,
)
})
}
fn ensure_scalar_paged_execution_family(family: ExecutionFamily) -> Result<(), QueryError> {
match family {
ExecutionFamily::PrimaryKey => Err(QueryError::invariant(
CursorPlanError::cursor_requires_explicit_or_grouped_ordering_message(),
)),
ExecutionFamily::Ordered => Ok(()),
ExecutionFamily::Grouped => Err(QueryError::invariant(
"grouped queries execute via execute(), not page().execute()",
)),
}
}
fn ensure_grouped_execution_family(family: ExecutionFamily) -> Result<(), QueryError> {
match family {
ExecutionFamily::Grouped => Ok(()),
ExecutionFamily::PrimaryKey | ExecutionFamily::Ordered => Err(QueryError::invariant(
"grouped execution requires grouped logical plans",
)),
}
}
pub fn execute_query<E>(&self, query: &Query<E>) -> Result<EntityResponse<E>, QueryError>
where
E: PersistedRow<Canister = C> + EntityValue,
{
let mode = query.mode();
let (plan, _) = self.cached_prepared_query_plan_for_entity::<E>(query.structural())?;
self.execute_query_dyn(mode, plan)
}
#[cfg(feature = "perf-attribution")]
#[doc(hidden)]
pub fn execute_query_result_with_attribution<E>(
&self,
query: &Query<E>,
) -> Result<(LoadQueryResult<E>, QueryExecutionAttribution), QueryError>
where
E: PersistedRow<Canister = C> + EntityValue,
{
let (compile_local_instructions, plan_and_cache) = measure_query_stage(|| {
self.cached_prepared_query_plan_for_entity::<E>(query.structural())
});
let (plan, cache_attribution) = plan_and_cache?;
let (execute_local_instructions, result) = measure_query_stage(|| {
if query.has_grouping() {
self.execute_grouped_plan_with_trace(plan, None)
.map(|(page, trace)| {
let next_cursor = page
.next_cursor
.map(|token| {
let Some(token) = token.as_grouped() else {
return Err(
QueryError::grouped_paged_emitted_scalar_continuation(),
);
};
token.encode().map_err(|err| {
QueryError::serialize_internal(format!(
"failed to serialize grouped continuation cursor: {err}"
))
})
})
.transpose()?;
Ok::<(LoadQueryResult<E>, ScalarExecutePhaseAttribution, u64), QueryError>(
(
LoadQueryResult::Grouped(PagedGroupedExecutionWithTrace::new(
page.rows,
next_cursor,
trace,
)),
Self::empty_scalar_execute_phase_attribution(),
0,
),
)
})?
} else {
match query.mode() {
QueryMode::Load(_) => {
let (rows, phase_attribution, response_decode_local_instructions) = self
.load_executor::<E>()
.execute_with_phase_attribution(plan)
.map_err(QueryError::execute)?;
Ok::<(LoadQueryResult<E>, ScalarExecutePhaseAttribution, u64), QueryError>(
(
LoadQueryResult::Rows(rows),
phase_attribution,
response_decode_local_instructions,
),
)
}
QueryMode::Delete(_) => {
let result = self.execute_query_dyn(query.mode(), plan)?;
Ok((
LoadQueryResult::Rows(result),
Self::empty_scalar_execute_phase_attribution(),
0,
))
}
}
}
});
let (result, execute_phase_attribution, response_decode_local_instructions) = result?;
let total_local_instructions =
compile_local_instructions.saturating_add(execute_local_instructions);
Ok((
result,
QueryExecutionAttribution {
compile_local_instructions,
runtime_local_instructions: execute_phase_attribution.runtime_local_instructions,
finalize_local_instructions: execute_phase_attribution.finalize_local_instructions,
response_decode_local_instructions,
execute_local_instructions,
total_local_instructions,
shared_query_plan_cache_hits: cache_attribution.hits,
shared_query_plan_cache_misses: cache_attribution.misses,
},
))
}
#[doc(hidden)]
pub fn execute_query_result<E>(
&self,
query: &Query<E>,
) -> Result<LoadQueryResult<E>, QueryError>
where
E: PersistedRow<Canister = C> + EntityValue,
{
if query.has_grouping() {
return self
.execute_grouped(query, None)
.map(LoadQueryResult::Grouped);
}
self.execute_query(query).map(LoadQueryResult::Rows)
}
#[doc(hidden)]
pub fn execute_delete_count<E>(&self, query: &Query<E>) -> Result<u32, QueryError>
where
E: PersistedRow<Canister = C> + EntityValue,
{
if !query.mode().is_delete() {
return Err(QueryError::unsupported_query(
"delete count execution requires delete query mode",
));
}
let plan = self
.compile_query_with_visible_indexes(query)?
.into_prepared_execution_plan();
self.with_metrics(|| self.delete_executor::<E>().execute_count(plan))
.map_err(QueryError::execute)
}
pub(in crate::db) fn execute_query_dyn<E>(
&self,
mode: QueryMode,
plan: PreparedExecutionPlan<E>,
) -> Result<EntityResponse<E>, QueryError>
where
E: PersistedRow<Canister = C> + EntityValue,
{
let result = match mode {
QueryMode::Load(_) => self.with_metrics(|| self.load_executor::<E>().execute(plan)),
QueryMode::Delete(_) => self.with_metrics(|| self.delete_executor::<E>().execute(plan)),
};
result.map_err(QueryError::execute)
}
pub(in crate::db) fn execute_load_query_with<E, T>(
&self,
query: &Query<E>,
op: impl FnOnce(LoadExecutor<E>, PreparedExecutionPlan<E>) -> Result<T, InternalError>,
) -> Result<T, QueryError>
where
E: PersistedRow<Canister = C> + EntityValue,
{
let (plan, _) = self.cached_prepared_query_plan_for_entity::<E>(query.structural())?;
self.with_metrics(|| op(self.load_executor::<E>(), plan))
.map_err(QueryError::execute)
}
pub fn trace_query<E>(&self, query: &Query<E>) -> Result<QueryTracePlan, QueryError>
where
E: EntityKind<Canister = C>,
{
let compiled = self.compile_query_with_visible_indexes(query)?;
let explain = compiled.explain();
let plan_hash = compiled.plan_hash_hex();
let (executable, _) =
self.cached_prepared_query_plan_for_entity::<E>(query.structural())?;
let access_strategy = AccessStrategy::from_plan(executable.access()).debug_summary();
let execution_family = match query.mode() {
QueryMode::Load(_) => Some(executable.execution_family().map_err(QueryError::execute)?),
QueryMode::Delete(_) => None,
};
Ok(QueryTracePlan::new(
plan_hash,
access_strategy,
execution_family,
explain,
))
}
pub(crate) fn execute_load_query_paged_with_trace<E>(
&self,
query: &Query<E>,
cursor_token: Option<&str>,
) -> Result<PagedLoadExecutionWithTrace<E>, QueryError>
where
E: PersistedRow<Canister = C> + EntityValue,
{
let plan = self
.cached_prepared_query_plan_for_entity::<E>(query.structural())?
.0;
Self::ensure_scalar_paged_execution_family(
plan.execution_family().map_err(QueryError::execute)?,
)?;
let cursor_bytes = decode_optional_cursor_token(cursor_token)
.map_err(QueryError::from_cursor_plan_error)?;
let cursor = plan
.prepare_cursor(cursor_bytes.as_deref())
.map_err(QueryError::from_executor_plan_error)?;
let (page, trace) = self
.with_metrics(|| {
self.load_executor::<E>()
.execute_paged_with_cursor_traced(plan, cursor)
})
.map_err(QueryError::execute)?;
let next_cursor = page
.next_cursor
.map(|token| {
let Some(token) = token.as_scalar() else {
return Err(QueryError::scalar_paged_emitted_grouped_continuation());
};
token.encode().map_err(|err| {
QueryError::serialize_internal(format!(
"failed to serialize continuation cursor: {err}"
))
})
})
.transpose()?;
Ok(PagedLoadExecutionWithTrace::new(
page.items,
next_cursor,
trace,
))
}
pub(in crate::db) fn execute_grouped<E>(
&self,
query: &Query<E>,
cursor_token: Option<&str>,
) -> Result<PagedGroupedExecutionWithTrace, QueryError>
where
E: PersistedRow<Canister = C> + EntityValue,
{
let (page, trace) = self.execute_grouped_page_with_trace(query, cursor_token)?;
let next_cursor = page
.next_cursor
.map(|token| {
let Some(token) = token.as_grouped() else {
return Err(QueryError::grouped_paged_emitted_scalar_continuation());
};
token.encode().map_err(|err| {
QueryError::serialize_internal(format!(
"failed to serialize grouped continuation cursor: {err}"
))
})
})
.transpose()?;
Ok(PagedGroupedExecutionWithTrace::new(
page.rows,
next_cursor,
trace,
))
}
fn execute_grouped_page_with_trace<E>(
&self,
query: &Query<E>,
cursor_token: Option<&str>,
) -> Result<(GroupedCursorPage, Option<ExecutionTrace>), QueryError>
where
E: PersistedRow<Canister = C> + EntityValue,
{
let plan = self
.cached_prepared_query_plan_for_entity::<E>(query.structural())?
.0;
self.execute_grouped_plan_with_trace(plan, cursor_token)
}
fn execute_grouped_plan_with_trace<E>(
&self,
plan: PreparedExecutionPlan<E>,
cursor_token: Option<&str>,
) -> Result<(GroupedCursorPage, Option<ExecutionTrace>), QueryError>
where
E: PersistedRow<Canister = C> + EntityValue,
{
Self::ensure_grouped_execution_family(
plan.execution_family().map_err(QueryError::execute)?,
)?;
let cursor = decode_optional_grouped_cursor_token(cursor_token)
.map_err(QueryError::from_cursor_plan_error)?;
let cursor = plan
.prepare_grouped_cursor_token(cursor)
.map_err(QueryError::from_executor_plan_error)?;
self.with_metrics(|| {
self.load_executor::<E>()
.execute_grouped_paged_with_cursor_traced(plan, cursor)
})
.map_err(QueryError::execute)
}
}
impl QueryPlanCacheKey {
fn for_authority(
authority: crate::db::executor::EntityAuthority,
schema_fingerprint: CommitSchemaFingerprint,
visibility: QueryPlanVisibility,
query: &StructuralQuery,
) -> Self {
Self::for_authority_with_method_version(
authority,
schema_fingerprint,
visibility,
query,
SHARED_QUERY_PLAN_CACHE_METHOD_VERSION,
)
}
fn for_authority_with_method_version(
authority: crate::db::executor::EntityAuthority,
schema_fingerprint: CommitSchemaFingerprint,
visibility: QueryPlanVisibility,
query: &StructuralQuery,
cache_method_version: u8,
) -> Self {
Self {
cache_method_version,
entity_path: authority.entity_path(),
schema_fingerprint,
visibility,
structural_query: query.structural_cache_key(),
}
}
}