#[non_exhaustive]pub struct SqlProjectionHint {
pub database: DatabaseType,
pub projection_template: String,
pub estimated_reduction_percent: u32,
pub reads_only_document: bool,
}Expand description
SQL projection hint for database-specific field projection optimization.
When a type has a large JSONB payload, the compiler can generate SQL that projects only the requested fields, reducing network payload and JSON deserialization overhead.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.database: DatabaseTypeDatabase type — typed to prevent silent typos (e.g. "postgresq") that
would cause adapters to silently ignore the hint.
projection_template: StringThe projection SQL template.
Example for PostgreSQL:
jsonb_build_object('id', data->>'id', 'email', data->>'email')
estimated_reduction_percent: u32Estimated reduction in payload size (percentage 0-100).
reads_only_document: boolThe template reads nothing but the row’s JSONB document (data), so the read may be
paged before it is projected and each returned row’s document detoasted once (#1554).
false, the default, when the template also reads a native column or a computed
expression (a vector distance): the paged subquery exposes only the document, so such
a read keeps the single-SELECT shape. Set by the projection generator, which is the
only thing that knows what it emitted; never inferred from the SQL text.
Implementations§
Source§impl SqlProjectionHint
impl SqlProjectionHint
Sourcepub const fn new(
database: DatabaseType,
projection_template: String,
estimated_reduction_percent: u32,
) -> Self
pub const fn new( database: DatabaseType, projection_template: String, estimated_reduction_percent: u32, ) -> Self
Creates a new SqlProjectionHint.
Sourcepub const fn reading_only_the_document(self) -> Self
pub const fn reading_only_the_document(self) -> Self
The same hint, declaring that its template reads only the row’s JSONB document
(reads_only_document).
Trait Implementations§
Source§impl Clone for SqlProjectionHint
impl Clone for SqlProjectionHint
Source§impl Debug for SqlProjectionHint
impl Debug for SqlProjectionHint
Source§impl<'de> Deserialize<'de> for SqlProjectionHint
impl<'de> Deserialize<'de> for SqlProjectionHint
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for SqlProjectionHint
Source§impl PartialEq for SqlProjectionHint
impl PartialEq for SqlProjectionHint
Source§impl Serialize for SqlProjectionHint
impl Serialize for SqlProjectionHint
impl StructuralPartialEq for SqlProjectionHint
Auto Trait Implementations§
impl Freeze for SqlProjectionHint
impl RefUnwindSafe for SqlProjectionHint
impl Send for SqlProjectionHint
impl Sync for SqlProjectionHint
impl Unpin for SqlProjectionHint
impl UnsafeUnpin for SqlProjectionHint
impl UnwindSafe for SqlProjectionHint
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.