@@ -408,16 +408,19 @@ export class QueryOptimizer extends EventEmitter<EventMap> {
408408 Math . abs ( percentageReduction ) ,
409409 ) ;
410410 if ( costReductionPercentage < MINIMUM_COST_CHANGE_PERCENTAGE ) {
411+ const consideredIndexes = mapConsideredIndexes ( result ) ;
411412 this . onNoImprovements (
412413 recent ,
413414 result . baseCost ,
414415 indexesUsed ,
416+ consideredIndexes ,
415417 explainPlan ,
416418 ) ;
417419 return {
418420 state : "no_improvement_found" ,
419421 cost : result . baseCost ,
420422 indexesUsed,
423+ consideredIndexes,
421424 explainPlan,
422425 } ;
423426 } else {
@@ -429,6 +432,7 @@ export class QueryOptimizer extends EventEmitter<EventMap> {
429432 costReductionPercentage,
430433 indexRecommendations,
431434 indexesUsed,
435+ consideredIndexes : mapConsideredIndexes ( result ) ,
432436 explainPlan,
433437 optimizedExplainPlan : result . explainPlan ,
434438 } ;
@@ -444,6 +448,7 @@ export class QueryOptimizer extends EventEmitter<EventMap> {
444448 recent : OptimizedQuery ,
445449 cost : number ,
446450 indexesUsed : string [ ] ,
451+ consideredIndexes : IndexRecommendation [ ] ,
447452 explainPlan : PostgresExplainStage ,
448453 ) {
449454 this . emit (
@@ -452,6 +457,7 @@ export class QueryOptimizer extends EventEmitter<EventMap> {
452457 state : "no_improvement_found" ,
453458 cost,
454459 indexesUsed,
460+ consideredIndexes,
455461 explainPlan,
456462 } ) ,
457463 ) ;
@@ -512,6 +518,7 @@ export class QueryOptimizer extends EventEmitter<EventMap> {
512518 costReductionPercentage,
513519 indexRecommendations,
514520 indexesUsed,
521+ consideredIndexes : mapConsideredIndexes ( result ) ,
515522 explainPlan,
516523 optimizedExplainPlan : result . explainPlan ,
517524 } ;
@@ -582,6 +589,12 @@ function mapIndexRecommandations(
582589 } ) ;
583590}
584591
592+ function mapConsideredIndexes (
593+ result : Extract < OptimizeResult , { kind : "ok" } > ,
594+ ) : IndexRecommendation [ ] {
595+ return Array . from ( result . triedIndexes . values ( ) ) ;
596+ }
597+
585598type PercentageDifference = number ;
586599
587600export function costDifferencePercentage (
0 commit comments