QueryHint¶
- class aerospike_sdk.aio.operations.query.QueryHint[source]¶
Bases:
objectHint for influencing secondary index selection and query scheduling.
Provide
index_nameas a soft explain hint on the server-led path. To bypass server-led selection and choose the access path yourself, attach an explicit index filter withQueryBuilder.filter()instead.On clusters that support field
44query selection (>= 8.2.0),allow_scans_with_whereandhard_hintset Tier-D WHERE flags on explain.allow_scans_with_whereis tri-state:Noneinherits the Behavior setting (by default the primary-index fallback is allowed),Trueallows the fallback for this query,Falserejects it.Example:
hint = QueryHint( index_name="age_idx", query_duration=QueryDuration.SHORT, ) stream = await ( session.query(dataset) .where("$.age > 30") .with_hint(hint) .execute() )
- Parameters:
index_name (
Optional[str]) – Soft index name hint (field21on explain).query_duration (
Optional[QueryDuration]) – Overrideexpected_durationon the query policy.allow_scans_with_where (
Optional[bool]) – Tri-state override for whether a where-clause query may fall back to a primary-index scan.None(default) inherits the Behavior;Trueallows the fallback,Falserejects it (setsREQUIRE_INDEXon explain).hard_hint (
bool) – Explain flag — requireindex_nameto be selected.
- Raises:
ValueError – If
hard_hintis set withoutindex_name.
See also
- __init__(*, index_name=None, query_duration=None, allow_scans_with_where=None, hard_hint=False)¶