-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathVLFCounts.sql
More file actions
31 lines (24 loc) · 1018 Bytes
/
Copy pathVLFCounts.sql
File metadata and controls
31 lines (24 loc) · 1018 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* Get VLF Counts for all databases on the instance
Ff above 100, shrink LOG file and set Autogrowth higher in MB not %
When VLF under 100 – ignore, between 100 – 200 – you can ignore, but better to fix
When above 400 – it’s getting urgent, so fix it.
When above 600 – slowdowns are happening, but it’s not easy to diagnose these. Fix.
When above 5000, fix now!
*/
CREATE TABLE #VLFInfo (Recoveryunitid int ,FileID int,
FileSize bigint, StartOffset bigint,
FSeqNo bigint, [Status] bigint,
Parity bigint, CreateLSN numeric(38));
CREATE TABLE #VLFCountResults(DatabaseName sysname, VLFCount int);
EXEC sp_MSforeachdb N'Use [?];
INSERT INTO #VLFInfo
EXEC sp_executesql N''DBCC LOGINFO([?])'';
INSERT INTO #VLFCountResults
SELECT DB_NAME(), COUNT(*)
FROM #VLFInfo;
TRUNCATE TABLE #VLFInfo;'
SELECT DatabaseName, VLFCount
FROM #VLFCountResults
ORDER BY VLFCount DESC;
DROP TABLE #VLFInfo;
DROP TABLE #VLFCountResults;