Execution plans
mikegoatly opened this issue · 0 comments
mikegoatly commented
Given the work that went into v6 to optimise the query execution paths, having a way to visualize the order that each query part was executed in would help:
- Explain how queries are executed, including the weightings that were calculated for each part
- Spot any obvious improvements that could be made to the execution order.
Conceptually similar to SQL Server's actual execution plan generation, this would be opt-in when queries are executed against an index:
var results = this.index.Search("\"two three four\"", QueryExecutionOptions.IncludeExecutionPlan);
var executionPlan = results.GetExecutionPlan();
A execution plan would be a hierarchical tree of the query parts, including timing details and scoring breakdowns. For example:
You can see that:
- 1 "CHANGE" was executed first because it had the lowest weighting of the two intersecting queries, matching 3 documents
- 2 The "THE" query part was executed second, and had its results pre-filtered to the 3 documents already matched for the intersection
- 3 The results from the AND operators were intersected, resulting in 3 matches
- 4 "WORLD" was executed fourth, returning 14 documents
- 5 lastly, unioning (ORing) the two parts of the query together resulted in 17 document matches