Presentation is loading. Please wait.

Presentation is loading. Please wait.

Insight into the SQL Server Buffer Cache

Similar presentations


Presentation on theme: "Insight into the SQL Server Buffer Cache"— Presentation transcript:

1 Insight into the SQL Server Buffer Cache
Ed Pollack Sr. Database Administrator Autotask

2 Agenda SQL Server Memory Management What is the buffer cache?
Quick review of data pages and related topics. How can we view what is in memory? Page life expectancy & buffer cache hit ratio Other useful queries/tips Questions/Conclusion

3 SQL Server Buffer Cache
Data Pages: StorageMemoryDatabase Engine Reads from disk as needed. Retains data for as long as needed/possible. Purpose is to optimize speed of data retrieval. Nomenclature: Cache = Memory Demo: sys.dm_os_sys.info

4 What is a Data Page? 1 page = 8kb of data.
To read or write data, it must be read into memory. Clean page: Has not been changed in cache. Dirty page: Has been written in cache, but not to storage. Checkpoint: Dirty pages are written to disk. This is automatic and frequent based on recovery interval.

5 Cache Cleanup Pages are read into cache when:
They are needed by the SQL Server Database Engine. Pages are removed from cache when: They age out. Memory pressure forces them out. They become irrelevant/unneeded

6 Movement of Pages Through Memory

7 What Can We Dig Out of the Cache?
Demo! Overall usage Usage by: Database Table Index Percentage of each:

8 Memory Pressure What happens when our memory is not enough?
Purge data from cache prematurely. Read more data from storage. SQL Server waits for data to be read. Cache reuse is reduced. Typical causes? Bad queries or inefficient processes Not enough memory

9 More Metrics! Demo! Usage by database with empty vs. used space
Usage by table with empty vs. used space Dirty vs. clean pages Dirty vs. clean pages by index

10 Page Life Expectancy How long (in seconds) will a page stay in cache unused before being removed? What is a good value? Not 300! That is silly! We need metrics: Data usage & throughput App performance & growth Demo!

11 Buffer Cache Hit Ratio What percentage of page requests are fulfilled from the buffer cache, rather than from storage? This is a comparison of logical reads vs. physical reads. Is a lagging indicator and not good for alerting! Demo!

12 Conclusion Buffer cache knowledge = app performance knowledge!
Can identify poorly performing areas of an app. Aids capacity planning. Can help with alerting/monitoring.

13 Questions???

14 Contact Info & Links Ed SQL Shack SQL Server Central SQL Saturday Albany (2018) Thank you!!!


Download ppt "Insight into the SQL Server Buffer Cache"

Similar presentations


Ads by Google