/** * Query Planner - Cost-Based Index Selection * * Analyzes queries and selects the optimal index to use. * Uses cardinality estimation and index statistics to minimize query cost. */ import type { IndexConfig } from './index-types.js'; export interface QueryPredicate { field: string; operator: 'eq' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'range' | 'contains' | 'startsWith'; value?: any; values?: any[]; } export interface IndexScoreboard { indexName: string; indexType: string; fields: string[]; score: number; coverage: number; estimatedRows: number; cost: number; } export declare class QueryPlanner { /** * Analyze a predicate and select the best index. */ static planQuery(predicates: QueryPredicate[], indexes: IndexConfig[]): IndexScoreboard | null; /** * Score how well an index covers the given predicates. */ private static scoreIndex; /** * Explain the query plan (for debugging). */ static explainPlan(predicates: QueryPredicate[], indexes: IndexConfig[], selectedIndex?: IndexScoreboard): string; } /** * Compound query builder for multi-field searches. */ export declare class CompoundQuery { private predicates; private fields; /** * Add a predicate for a field. */ addPredicate(field: string, operator: QueryPredicate['operator'], value: any): this; /** * Get all predicates. */ getPredicates(): QueryPredicate[]; /** * Get fields involved in this query. */ getFields(): string[]; /** * Find best index for this compound query. */ planWith(indexes: IndexConfig[]): IndexScoreboard | null; } /** * Index recommendation engine - suggests indexes to create. */ export declare class IndexRecommender { /** * Analyze query patterns and recommend indexes. */ static recommendIndexes(queries: QueryPredicate[][]): IndexConfig[]; } //# sourceMappingURL=query-planner.d.ts.map