-
Type: Task
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
Query Optimization
-
Minor Change
-
QO 2023-06-12
-
128
The code for the SBE plan cache's BudgetEstimator currently looks like this:
struct BudgetEstimator { /** * This estimator function is called when an entry is added or removed to LRU cache in order to * make sure the total plan cache size does not exceed the maximum size. */ size_t operator()(const sbe::PlanCacheKey& key, const std::shared_ptr<const PlanCacheEntry>& entry) { // TODO: SERVER-73649 include size of underlying query shape and size of int_32 key hash in // total size estimation. return entry->estimatedEntrySizeBytes; } };
That is, we are only considering the size of the PlanCacheEntry as counting towards the plan cache's memory budget. However, the keys themselves can get quite large – they encode a query shape which can get large, in addition to a bunch of other flags and index descriminators and such. The fact that we are not considering the size of the key means we are underestimating the memory being used by the SBE plan cache, and potentially using more memory than allowed by the planCacheSize parameter configuration.
Original description
Currently, SBE Plan cache budget estimations only track the size of the query plans. To be most accurate, we should also track the size of the hashed key and the underlying query shape (from which the hash is generated). This should be completed before before or in tandem with SERVER-73659
- is related to
-
SERVER-73659 Account for size of KVMap in LRUKeyValue cache memory budget tracking
- Closed
-
SERVER-77976 Patch for calculation of SbePlanCache size estimation and improve testing
- Closed
- related to
-
SERVER-76574 Improve LRUKeyValue to avoid storing keys twice
- Closed