In this
article describing dmv sys.dm_os_memory_cache_hash_tables, column "buckets_max_length" is defined to mean "Maximum number
of cache entries in a bucket."
From this description, I would infer that the threshold for desired maximum number of entries in a particular cache would be calculated as (buckets_count * buckets_max_length). Following this logic, running the following query on my system yields the results
shown below:
SELECT name as cache_name
, buckets_count as buckets
, buckets_max_length as entries_per_bucket
, (buckets_count * buckets_max_length) as max_entries_for_cache
FROM sys.dm_os_memory_cache_hash_tables
WHERE [type] IN ('CACHESTORE_SQLCP', 'CACHESTORE_OBJCP', 'CACHESTORE_PHDR');
-- RESULTS --
cache_name buckets entries_per_bucket max_entries_for_cache
Object Plans 40009 4 160036
SQL Plans 40009 7 280063
Bound Trees 4001 24 96024
However, in
this article on SQL Caching, the description given in the section titled "Local Memory Pressure" regarding the calculation of an upper boundary on cache entries is as follows:
"In addition to memory pressure occurring when the total amount of memory reaches a particular limit, SQL Server also indicates memory
pressure when the number of plans in a store exceeds four times the hash table size for that store, regardless of the actual size of the plans."
This definition is re-referenced in
this recent hotfix article for SQL Server, where it is stated:
"The maximum number of entries that a plan cache can hold is four times of the buckets count."
While this definition is consistent with my assumption above for the "Object Plans" cache, which has a buckets_max_length = 4, it is inconsitent for other caches with other defined max_length values, leading me to question my very sanity.
:)
Can someone help me clear up the real intended meaning AND internal use of buckets_max_length? I'd like to be able to detect when internal caches might be under pressure due to too many entries or to much space used, and getting a clear understanding
of this dmv would help.