Commit 0c5f43d
Preserve decimal precision in sp_PressureDetector size/memory GB math
Several size/memory columns that carry a _gb suffix were computed with
bigint-only arithmetic, forcing integer division to truncate sub-GB
values to 0. On Azure Basic/S0 tiers or small tempdb files this
reported 0 GB where the real value was 0.5 GB, hiding the very
condition the check is meant to surface.
Sites fixed:
- tempdb min/max size_gb and growth_increment_gb (line ~2287)
- database_size_out_gb Azure + on-prem paths (line ~2586/2603)
- physical_memory_available_gb and virtual_memory_available_gb from
RING_BUFFER_RESOURCE_MONITOR shreds (line ~2657)
- max_server_memory_gb from sys.configurations (line ~2942)
For each, changed the divisor literals from 1024 / 1024 to 1024.0 /
1024.0 so the expression promotes to decimal, and wrapped the output
in CONVERT(decimal(19, 2), ...) to keep a sensible display precision.
Separately, tempdb growth columns now filter out is_percent_growth = 1
rows via CASE WHEN — percent-growth files store the percentage in
mf.growth, not a page count, so the old * 8 math produced meaningless
GB numbers for them. Percent-growth in tempdb is a legacy
misconfiguration anyway, and surfacing a wrong GB is worse than
surfacing NULL.
max_server_memory_gb also needed an explicit CONVERT(bigint, ...)
around c.value_in_use because sys.configurations.value_in_use is
sql_variant and won't implicitly convert to decimal.
Verified on SQL Server 2022:
tempdb min/max_size_gb: 1.00 (was 1)
max_server_memory_gb: 90.00 (was 90)
total_database_size_gb: 244.65 (was 244)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent ca2dbd8 commit 0c5f43d
1 file changed
Lines changed: 32 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2284 | 2284 | | |
2285 | 2285 | | |
2286 | 2286 | | |
2287 | | - | |
| 2287 | + | |
2288 | 2288 | | |
2289 | | - | |
| 2289 | + | |
| 2290 | + | |
| 2291 | + | |
| 2292 | + | |
2290 | 2293 | | |
2291 | | - | |
| 2294 | + | |
2292 | 2295 | | |
2293 | | - | |
| 2296 | + | |
2294 | 2297 | | |
2295 | 2298 | | |
2296 | 2299 | | |
| |||
2576 | 2579 | | |
2577 | 2580 | | |
2578 | 2581 | | |
2579 | | - | |
| 2582 | + | |
2580 | 2583 | | |
2581 | | - | |
| 2584 | + | |
| 2585 | + | |
2582 | 2586 | | |
2583 | | - | |
2584 | | - | |
2585 | | - | |
2586 | | - | |
| 2587 | + | |
| 2588 | + | |
| 2589 | + | |
| 2590 | + | |
| 2591 | + | |
| 2592 | + | |
| 2593 | + | |
2587 | 2594 | | |
2588 | 2595 | | |
2589 | 2596 | | |
| |||
2593 | 2600 | | |
2594 | 2601 | | |
2595 | 2602 | | |
2596 | | - | |
| 2603 | + | |
2597 | 2604 | | |
2598 | | - | |
| 2605 | + | |
| 2606 | + | |
2599 | 2607 | | |
2600 | | - | |
2601 | | - | |
2602 | | - | |
2603 | | - | |
| 2608 | + | |
| 2609 | + | |
| 2610 | + | |
| 2611 | + | |
| 2612 | + | |
| 2613 | + | |
| 2614 | + | |
2604 | 2615 | | |
2605 | 2616 | | |
2606 | 2617 | | |
| |||
2654 | 2665 | | |
2655 | 2666 | | |
2656 | 2667 | | |
2657 | | - | |
| 2668 | + | |
2658 | 2669 | | |
2659 | | - | |
| 2670 | + | |
2660 | 2671 | | |
2661 | 2672 | | |
2662 | 2673 | | |
| |||
2944 | 2955 | | |
2945 | 2956 | | |
2946 | 2957 | | |
2947 | | - | |
2948 | | - | |
| 2958 | + | |
| 2959 | + | |
2949 | 2960 | | |
2950 | 2961 | | |
2951 | 2962 | | |
2952 | | - | |
| 2963 | + | |
2953 | 2964 | | |
2954 | 2965 | | |
2955 | 2966 | | |
| |||
0 commit comments