[SERVER-85596] Avoid unnecessary BSON allocations in IndexScan getStats() Created: 23/Jan/24  Updated: 31/Jan/24

Status: In Code Review
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Ben Shteinfeld Assignee: Hana Pearlman
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-85418 Investigate large_indexed_ins ineffic... Closed
Assigned Teams:
Query Optimization
Participants:

 Description   

As part of SERVER-85418, we found that there are many allocations as part of pickBestPlan, which ends up calling getStats() on the PlanStage root. The purpose of this is to get the statistics and produce the score of the plan tree in order to invoke the plan ranker.

The classic IndexScan execution stage invokes toBSON on the bounds as part of getStats(), but as part as I can tell, this is only necessary for explain and is not necessary for calculating the plan's score. In the LargeIndexedIn genny workload, this contributes to a large number (90%+) of allocations in the workload. If we confirm that this field is only used in the explain path, we should avoid doing this work as part of the regular multi-planning codepath. I suspect this will have a positive performance benefit.


Generated at Thu Feb 08 06:58:08 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.