import { Query, Sort } from "@peerbit/indexer-interface";
import { type DeferredPromise } from "p-defer";
export interface QueryIndexPlanner {
    columnsToIndexes: Map<string, {
        results: {
            used: number;
            avg: number;
            times: number[];
            indexKey: string;
            created: () => boolean;
            creationPromiseDeferred: DeferredPromise<void>;
        }[];
    }>;
}
type StmtStats = Map<string, QueryIndexPlanner>;
export declare const flattenQuery: (props?: {
    query: Query[];
    sort?: Sort[] | Sort;
}) => Generator<{
    query: Query[];
    sort?: Sort[] | Sort;
} | undefined>;
export declare class PlannableQuery {
    query: Query[];
    sort: Sort[];
    constructor(props: {
        query: Query[];
        sort?: Sort[] | Sort;
    });
    get key(): string;
}
export type PlanningSession = ReturnType<QueryPlanner["scope"]>;
export declare class QueryPlanner {
    readonly props: {
        exec: (query: string) => Promise<any> | any;
    };
    stats: StmtStats;
    pendingIndexCreation: Map<string, Promise<void>>;
    constructor(props: {
        exec: (query: string) => Promise<any> | any;
    });
    stop(): Promise<void>;
    scope(query: PlannableQuery): {
        beforePrepare: () => Promise<void>;
        resolveIndex: (tableName: string, columns: string[]) => string;
        perform: <T>(fn: () => Promise<T>) => Promise<T>;
    };
}
export {};
//# sourceMappingURL=query-planner.d.ts.map