Data cache memory usage
Job details
Name: |
Data cache memory usage |
Platform: |
Sqlserver |
Category: |
Performance |
Description: |
Collects data cache memory usage per database (for top 10 databases). |
Long description: |
Collects data cache memory usage per database (for top 10 databases). |
Version: |
2 |
Default schedule: |
0 * * * |
Requires engine install: |
Yes |
Compatibility tag: |
.[type=‘instance’ & databasetype=‘sqlserver’]/instance[maj_version > ‘2008′ & hasengine=‘YES’ & (engine_edition = ‘Microsoft SQL Server’ |
engine_edition = ‘Azure SQL Managed Instance’)] |
Parameters
Name |
Default value |
Description |
history threshold |
7 |
The number of days the statistics are hold in the history table. |
memory threshold |
100 |
This procedure is automatically disabled if the amount of memory allocated to the MS SQL Server is higher than this parameter value (in GB). This is because it takes too many resources to read from dynamic performance view sys.dm_os_buffer_descriptors. |
Job Summary
- Purpose: The purpose of this job is to monitor and analyze data cache memory usage in databases.
- Why: Monitoring data cache usage is crucial for performance tuning. It helps identify potential bottlenecks and ensures efficient memory allocation across databases. By tracking execution statistics and maintaining historical data, the system can optimize memory usage and performance, specifically within Microsoft SQL Server environments.
- Manual Checking: You can check this manually by querying the tables this job interacts with and reviewing the stored procedure’s operations.
Job Description and Dependencies
- This monitoring job involves collecting, aggregating, and analyzing the data cache memory usage per database, specifically for the top 10 databases by size.
- It creates several tables:
- “db_cache_mem_usage_tab” stores individual records of cache size per database.
- “db_cache_mem_usage_tab_aggr” aggregates these records over different periods of the day to provide an average, maximum, and minimum usage statistics.
- “db_cache_mem_usage_exec_histr” captures execution history of this data collection, including the start and end times, and total duration.
- The job has dependencies on:
- Its own procedure named “db_cache_mem_usage_proc”.
- Tables used for storing historical statistical data and their aggregated data.
- Automatically disables if memory allocated to SQL Server is over a configured threshold to avoid performance degradation when reading from memory-intensive dynamic views.
Implementation
- The primary component of this job is the stored procedure “db_cache_mem_usage_proc”.
- It checks memory thresholds and decides whether to proceed with data collection.
- Executes data collection for cache usage stats, aggregates these stats across different times of the day, and captures execution details.
- Inserts new data into the historical and aggregated tables and cleans up data older than a specified threshold.
- Logs execution details such as duration and memory usage to help with future performance tuning.
Upgrades and Maintenance
- The job defines steps for upgrading from previous versions.
- Includes altering the stored procedure to adapt to new performance insights or memory configurations.
- New parameters or alterations in existing parameters are addressed, ensuring the job remains relevant to current database configurations and practices.
Reporting and Visualization
- The job includes a report template detailing various presentations of data:
- Visualization of total instance memory and data cache usage over time.
- Historical visualizations showing daily average usages and variations.
- Detailed tables and charts depict historical execution stats, emphasizing changes and trends that could inform capacity planning and performance adjustments.
Operational Context
- This job is scheduled to run at regular intervals (configurable), and the frequency can be adjusted based on the instance size and performance impact.
- Ideal for database environments where memory usage can significantly influence overall performance, specifically in systems with substantial data throughput and storage requirements.
Overall, this job is essential in maintaining optimal database performance through proactive monitoring and analysis of crucial memory usage metrics.