From d981af626c8cbf0480b91f918f3b786e456f5ba2 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Sirois Date: Fri, 30 Jan 2026 17:16:38 +0400 Subject: [PATCH] feat: expose considered indexes --- src/remote/optimization.ts | 1 + src/remote/query-optimizer.ts | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/src/remote/optimization.ts b/src/remote/optimization.ts index f2d7d46..05fd6ab 100644 --- a/src/remote/optimization.ts +++ b/src/remote/optimization.ts @@ -28,6 +28,7 @@ export const LiveQueryOptimization = z.discriminatedUnion("state", [ costReductionPercentage: z.number(), indexRecommendations: z.array(IndexRecommendation), indexesUsed: z.array(z.string()), + consideredIndexes: z.array(IndexRecommendation).optional(), explainPlan: z.custom(), optimizedExplainPlan: z.custom(), }), diff --git a/src/remote/query-optimizer.ts b/src/remote/query-optimizer.ts index 39e29db..e63248b 100644 --- a/src/remote/query-optimizer.ts +++ b/src/remote/query-optimizer.ts @@ -429,6 +429,7 @@ export class QueryOptimizer extends EventEmitter { costReductionPercentage, indexRecommendations, indexesUsed, + consideredIndexes: mapConsideredIndexes(result), explainPlan, optimizedExplainPlan: result.explainPlan, }; @@ -512,6 +513,7 @@ export class QueryOptimizer extends EventEmitter { costReductionPercentage, indexRecommendations, indexesUsed, + consideredIndexes: mapConsideredIndexes(result), explainPlan, optimizedExplainPlan: result.explainPlan, }; @@ -582,6 +584,12 @@ function mapIndexRecommandations( }); } +function mapConsideredIndexes( + result: Extract, +): IndexRecommendation[] { + return Array.from(result.triedIndexes.values()); +} + type PercentageDifference = number; export function costDifferencePercentage(