tempdb Sizing and Contention

Review `tempdb` file sizing, growth, and page contention together. Use moon to track pressure as production workloads change.

2026-09-13 · 2 min read

Why this problem matters

Uneven or frequently growing tempdb files can increase workspace pressure and latency. Contention on allocation pages can appear as PAGELATCH waits.

How to diagnose it

Review file sizes, growth settings, and space use inside tempdb together. Current waiting tasks help confirm whether contention is actually occurring on tempdb pages.

The queries read tempdb file configuration and current space distribution. Waiting tasks and growth events over time should also be evaluated when diagnosing contention.

SELECT name, type_desc,
       size * 8.0 / 1024 AS size_mb,
       growth,
       is_percent_growth,
       physical_name
FROM tempdb.sys.database_files
ORDER BY file_id;

SELECT SUM(user_object_reserved_page_count) * 8.0 / 1024 AS user_objects_mb,
       SUM(internal_object_reserved_page_count) * 8.0 / 1024 AS internal_objects_mb,
       SUM(version_store_reserved_page_count) * 8.0 / 1024 AS version_store_mb
FROM tempdb.sys.dm_db_file_space_usage;

A safe solution approach

Managing data files with equal sizes and growth configuration generally improves predictability. Plan file count and size from measured contention and space demand rather than a copied formula.

Why continuous monitoring matters

tempdb consumption can change rapidly with queries, version stores, and maintenance operations. moon can track trends with low overhead and route pressure alerts to Slack, PagerDuty, or webhooks.

Frequently asked questions

Is one tempdb file required for every processor? Do more files always reduce contention?

No, there is no universal one-file-per-processor rule. Additional files should be considered only in the context of verified allocation contention and balanced file configuration.

How does moon help with this problem?

moon continuously observes SQL Server, PostgreSQL, and MongoDB signals, helping teams evaluate the problem as a trend instead of relying on a one-time check.