QueryPlanner

public struct QueryPlanner

A structure responsible for planning and optimizing database queries.

QueryPlanner provides statistical information about indexes and shards to assist in query execution planning.

  • Properties:
    • indexStats: A dictionary containing statistics for each index, where the key is the index name and the value is an IndexStat object.
    • shardStats: An array of ShardStat objects representing statistics for each shard in the database.
  • Undocumented

    Declaration

    Swift

    public let indexStats: [String : IndexStat]
  • Undocumented

    Declaration

    Swift

    public let shardStats: [ShardStat]
  • Initializes a new instance of the QueryPlanner class.

    Declaration

    Swift

    public init(indexStats: [String : IndexStat], shardStats: [ShardStat])

    Parameters

    indexStats

    A dictionary containing statistics for each index, where the key is the index name and the value is an IndexStat object.

    shardStats

    An array of ShardStat objects representing statistics for each shard.

  • Optimizes the execution plan for a query based on the provided collection, predicates, and available indexes.

    Declaration

    Swift

    public func optimize(
        collection: String,
        predicates: [(field: String, op: QueryOperator)],
        availableIndexes: [String]
    ) -> ExecutionPlan

    Parameters

    collection

    The name of the collection to query.

    predicates

    An array of tuples representing the query predicates, where each tuple contains:

    availableIndexes

    A list of available indexes for the collection.

    Return Value

    An ExecutionPlan object representing the optimized query execution plan.