pub struct N1QueryTracker { /* private fields */ }Expand description
Tracks lazy load queries for N+1 detection.
Implementations§
Source§impl N1QueryTracker
impl N1QueryTracker
Sourcepub fn with_threshold(self, threshold: usize) -> Self
pub fn with_threshold(self, threshold: usize) -> Self
Set the threshold for N+1 warnings.
A warning is emitted when the number of lazy loads for a single relationship reaches this threshold.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if detection is enabled.
Sourcepub fn record_load(
&mut self,
parent_type: &'static str,
relationship: &'static str,
)
pub fn record_load( &mut self, parent_type: &'static str, relationship: &'static str, )
Record a lazy load query.
This should be called whenever a lazy relationship is loaded. When the count for a (parent_type, relationship) pair reaches the threshold, a warning is emitted.
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Reset all counts and call sites.
Call this at the start of a new request or transaction scope.
Sourcepub fn count_for(
&self,
parent_type: &'static str,
relationship: &'static str,
) -> usize
pub fn count_for( &self, parent_type: &'static str, relationship: &'static str, ) -> usize
Get the current count for a specific relationship.
Sourcepub fn call_sites(&self) -> &[CallSite]
pub fn call_sites(&self) -> &[CallSite]
Get all call sites (for debugging).
Trait Implementations§
Source§impl Debug for N1QueryTracker
impl Debug for N1QueryTracker
Auto Trait Implementations§
impl Freeze for N1QueryTracker
impl RefUnwindSafe for N1QueryTracker
impl Send for N1QueryTracker
impl Sync for N1QueryTracker
impl Unpin for N1QueryTracker
impl UnsafeUnpin for N1QueryTracker
impl UnwindSafe for N1QueryTracker
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).