-
Type: Task
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Query Planning
-
None
-
Fully Compatible
-
QO 2022-04-04
-
0
Each entry in the SBE plan cache, in addition to the cached SBE plan itself, holds some debug info that is necessary to correctly populate the logs, system.profile, and so on. At the moment, when a query uses a cached plan, it will copy the debug info out of the cache. I believe that copy happens here.
Since the debug info is read-only, theoretically all queries using a cache entry could share the same DebugInfoSBE object rather than making their own copy. They can't just keep a reference or raw pointer, because after looking up the entry in the cache, that plan cache entry could subsequently be evicted and the reference/pointer would become invalid. Instead, each query could hold the debug info by std::shared_ptr. That way, the lifetime of the debug info would be extended after the corresponding plan cache entry is destroyed until all queries relying upon the debug info complete.