Instance memory usage
Job details
Name: |
Instance memory usage |
Platform: |
Sqlserver |
Category: |
Performance |
Description: |
Collects total memory usage and data cache memory usage for SQL Server instance. This dbWatch task can be configured to automatically reduce the amount of memory used by the SQL Server instance. |
Long description: |
Collects total memory usage and data cache memory usage for SQL Server instance. This dbWatch task can be configured to automatically reduce the amount of memory used by the SQL Server instance. |
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. |
buffer cache usage threshold |
1000 |
The average value of reads per second before the dbWatch task starts to reduce the memory usage of the SQL Server instance. This parameter is used in combination with the “time threshold” parameter. |
time threshold |
60 |
The amount of minutes which must past before the dbWatch task starts to reduce memory usage by the SQL Server instance if the average value of buffer reads per second stays bellow the “buffer cache usage threshold” value. |
min memory usage |
500 |
The minimum amount of memory (in MB) the SQL Server instance can be reduced to. |
enable memory reduction |
NO |
Enables the dbWatch task to reduce the SQL Server instance memory usage (possible values YES/NO). This parameter will stay enabled for a period of time controlled by the parameter “memory reduction time threshold” (default value: two weeks – 14 days). |
memory reduction steps |
20 |
The amount of memory (in MB) the SQL Server instance will be reduced with when parameters “buffer cache usage threshold” and “time threshold” values are reached. |
max memory usage |
1500 |
The maximum amount of memory to be allocated to SQL Server instance (in MB). |
memory reduction time threshold |
14 |
The number of days the parameter “enable memory reduction” will stay enabled before automatic disableing. |
auto memory configure |
NO |
Auto memory configuration option. If set to “YES“ the task will set the “max server memory (MB)” to a value based on collected statistics over period of time controlled by the parameter “Memory reduction time threshold”. The parameter “enable memory reduction” must be set to “YES“. |
min data cache size |
200 |
The minimum data cache size (in MB) the SQL Server instance can be reduced to when memory reduction is enabled. |
min page life expectancy |
60 |
The minimum value (in minutes) of “Page Life Expectancy” may have for memory reduction to be allowed (when parameter “enable memory reduction” is set to “YES“). |
Job Summary
- Purpose: This dbWatch job monitors and potentially adjusts the memory usage of SQL Server instances, focusing on total memory usage and data cache memory usage. The capability includes auto-adjustments based on pre-configured thresholds to optimize performance and resource utilization.
- Why: Managing memory usage in SQL Server is crucial for maintaining performance and operational efficiency. Memory-related issues can lead to slower application responses and can affect overall server performance. By automating the monitoring and adjustment process, the job aids in maintaining optimal performance without manual intervention, thus reducing downtime and manual workload.
- Manual checking: To manually check memory usage and configurations in SQL Server, the following SQL commands can be issued (For demonstration purposes – exact monitoring logic implementation might vary):
SELECT total_physical_memory_kb, available_physical_memory_kb, total_page_file_kb, available_page_file_kb FROM sys.dm_os_sys_memory;
SELECT name, value, value_in_use, minimum, maximum, is_dynamic, is_advanced FROM sys.configurations WHERE name LIKE '%server memory%';
Job Logic
- This task includes detailed SQL scripts to:
- Create and manage historical data of instance memory usage.
– Periodically check and update memory usage and configurations based on specific thresholds related to buffer cache usage, time intervals, and memory reduction policies.
– Implement automated procedures to adjust ‘max server memory (MB)’ settings in response to observed performance indicators, such as buffer cache thresholds.
- The logic primarily involves:
- Collecting current memory metrics.
– Comparing current data with historical usage to ascertain trends.
– Adjusting SQL Server memory settings if the configured conditions (like memory limits or performance thresholds) are met.
Dependencies and Parameters
- The task configures and relies on multiple dependencies for accurate monitoring and operation:
- Historical memory usage data.
– Last known buffer cache data.
– Procedures for updating memory usage periods.
– Various settings for thresholds such as ‘buffer cache usage threshold’ and ‘time threshold’.
- Parameters include:
- Time and memory usage thresholds.
– Minimum and maximum memory limits.
– Switches to enable or disable memory reduction.
Presentations and Reports
- The task generates various reports and dashboard presentations to illustrate:
- Current and historical memory usage statistics.
– Memory usage trends over time compared to set memory limits.
– Detailed data cache size alongside operational metrics.
– Monitoring periods, memory adjustments, recommended configurations, and other significant parameters influencing system performance.
- Report formats:
- Tabular displays for direct comparison.
Modifications and Upgrades
- Provisions for upgrading the job are included, where scripts adjust and refine:
- Procedure logic based on evolving best practices or additional parameters.
– Enhancements to memory usage calculations or threshold adjustments.
- Upgrade scripts ensure the task is kept up-to-date with the latest configurations and SQL Server features, maintaining compatibility and enhancing functionality with new SQL Server versions.
In summary, this dbWatch task is an essential utility for database administrators who aim to safeguard and optimize the performance of SQL Server environments through effective and efficient memory management strategies.