pub struct CompiledQuery {
pub sql: String,
pub param_names: Vec<String>,
pub params: Vec<QueryParam>,
pub shape: ShapeDescriptor,
pub warnings: Vec<String>,
pub inference_plan: Option<InferencePlan>,
pub tags: Vec<String>,
pub mutates: bool,
pub analyze_paths: Option<Vec<ShapePathAlias>>,
pub shape_id: Arc<str>,
}Expand description
The output of a successful PyQL compilation. Immutable and safe to cache and reuse across requests.
Fields§
§sql: StringPostgreSQL SQL string ready for execution.
param_names: Vec<String>Ordered parameter names matching $1, $2, … in the SQL. The client uses this to map kwargs to positional arguments.
params: Vec<QueryParam>Typed bound parameters — populated at execution time, empty after compilation.
shape: ShapeDescriptorOpaque shape handle — consumed by the Rust deserializer.
warnings: Vec<String>Non-fatal warnings produced during compilation.
inference_plan: Option<InferencePlan>Set when the query requires a pre-execution model call.
Every schema-qualified table ("schema.table") this statement reads
from or writes to — see ir::tags::collect_tags. For a SELECT, the
set of tags to cache this result under; for an INSERT/UPDATE/DELETE,
the set of tags a cache layer must invalidate after the write commits.
mutates: boolTrue when executing this statement writes to any of tags. Lets a
cache layer act on the invalidation duty described above without
re-parsing the SQL to guess whether a write happened.
analyze_paths: Option<Vec<ShapePathAlias>>Some only for analyze <query> — the shape-path↔SQL-alias map an
analyze execution needs to correlate Postgres’s EXPLAIN plan
nodes back to the query’s own shape (see analyze module). None
for every other query, which doesn’t pay for this extra shape walk.
shape_id: Arc<str>This query’s stable shape id — see crate::shape_id and shape_id().
Computed once at compile time; fill it with derive_shape_id if you
ever build a CompiledQuery outside compile_uncached.
Implementations§
Source§impl CompiledQuery
impl CompiledQuery
Sourcepub fn shape_id(&self) -> Arc<str> ⓘ
pub fn shape_id(&self) -> Arc<str> ⓘ
This query’s stable shape id — see crate::shape_id.
Independent of the values bound to it, which is what makes it safe as a metric label: a query run a million times with different parameters reports one label value, not a million.
Precomputed rather than derived per call. Every execution reports this
label, and deriving it meant Debug-formatting the entire shape tree
into a throwaway String and hashing it — measured at 3.65 µs per
execution on a 20-field shape, all of it repeated work, since a
CompiledQuery is immutable.
Trait Implementations§
Source§impl Clone for CompiledQuery
impl Clone for CompiledQuery
Auto Trait Implementations§
impl Freeze for CompiledQuery
impl RefUnwindSafe for CompiledQuery
impl Send for CompiledQuery
impl Sync for CompiledQuery
impl Unpin for CompiledQuery
impl UnsafeUnpin for CompiledQuery
impl UnwindSafe for CompiledQuery
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.