icydb_core/db/query/trace.rs
1//! Module: query::trace
2//! Responsibility: lightweight, deterministic trace projections for planned queries.
3//! Does not own: query semantics, plan hashing primitives, or executor routing policy.
4//! Boundary: read-only diagnostics surface assembled at query/session boundaries.
5
6use crate::db::query::explain::ExplainPlan;
7
8///
9/// TraceExecutionStrategy
10///
11/// Trace-surface execution-shape label derived from executor strategy selection.
12/// Keeps high-level route shape visible without exposing executor internals.
13///
14#[derive(Clone, Copy, Debug, Eq, PartialEq)]
15pub enum TraceExecutionStrategy {
16 PrimaryKey,
17 Ordered,
18 Grouped,
19}
20
21///
22/// QueryTracePlan
23///
24/// Lightweight trace payload for one planned query.
25/// Includes plan hash, selected access strategy summary, and logical explain output.
26///
27#[derive(Clone, Debug, Eq, PartialEq)]
28pub struct QueryTracePlan {
29 pub plan_hash: String,
30 pub access_strategy: String,
31 pub execution_strategy: Option<TraceExecutionStrategy>,
32 pub explain: ExplainPlan,
33}
34
35impl QueryTracePlan {
36 #[must_use]
37 pub(in crate::db) const fn new(
38 plan_hash: String,
39 access_strategy: String,
40 execution_strategy: Option<TraceExecutionStrategy>,
41 explain: ExplainPlan,
42 ) -> Self {
43 Self {
44 plan_hash,
45 access_strategy,
46 execution_strategy,
47 explain,
48 }
49 }
50}