Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Persistent Version Store Size Metric #1075

Open
jacobgexigo opened this issue Oct 14, 2024 · 1 comment
Open

Add Persistent Version Store Size Metric #1075

jacobgexigo opened this issue Oct 14, 2024 · 1 comment

Comments

@jacobgexigo
Copy link

All databases on Azure SQL Database default to ADR enabled and Read Committed Snapshot enabled so their Persistent Version Store can be highly volatile and can grow to consume all free space in a database if there is a high number of changes to the data. It would be nice to see in the Checks section, the size of the PVS either raw or as a % of the max size. We are currently running this as a custom alert on our side but would be great to have it consolidated here as well.

This is the code we use to determine:
;WITH DBSize
AS(
SELECT DB_NAME() DBName,
CAST(SUM(CAST(FILEPROPERTY(name, 'SpaceUsed') AS FLOAT) * 8192.) / 1024 / 1024 AS FLOAT) AS UsedInMB
FROM sys.database_files
WHERE type_desc = 'ROWS'
)
SELECT DB_NAME(database_id) AS database_name, (persistent_version_store_size_kb / 1024.) AS persistent_version_store_size_mb, cte.UsedInMB, (persistent_version_store_size_kb / 1024.)*100/cte.UsedInMB PVSPercentage
FROM sys.dm_tran_persistent_version_store_stats ps
JOIN DBSize cte ON cte.DBName = DB_NAME(database_id)
WHERE persistent_version_store_size_kb > 0 AND database_id = db_id()

Also, Microsoft has confirmed that any database in an elastic pool with a long running query can cause another database in the pool to pause flushing the PVS, letting it grow indefinitely until finished.

@DavidWiseman
Copy link
Collaborator

Thanks for the suggestion. I'm considering enabling ADR on one of our environments at some point - If I do I'll be interested in capturing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants