You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SET @dsql = @dsql +N' COALESCE((SELECT SUM (on_disk_size / 1024.0 / 1024) FROM '+QUOTENAME(@DatabaseName) +N'.sys.column_store_dictionaries dict WHERE dict.partition_id = ps.partition_id),0) AS reserved_dictionary_MB ';
1476
-
ELSE
1477
-
SET @dsql = @dsql +N' 0 AS reserved_dictionary_MB ';
1478
-
1516
+
'+CASEWHEN @SQLServerProductVersion NOTLIKE'9%'THENN'par.data_compression_desc 'ELSEN'null as data_compression_desc 'END+ N'
1517
+
';
1479
1518
1480
1519
SET @dsql = @dsql + N'
1481
1520
FROM '+QUOTENAME(@DatabaseName) + N'.sys.dm_db_partition_stats AS ps
@@ -1484,9 +1523,6 @@ BEGIN TRY
1484
1523
AND so.is_ms_shipped = 0 /*Exclude objects shipped by Microsoft*/
1485
1524
AND so.type <> ''TF'' /*Exclude table valued functions*/
1486
1525
JOIN '+QUOTENAME(@DatabaseName) + N'.sys.schemas AS s ON s.schema_id = so.schema_id
1487
-
LEFT JOIN '+QUOTENAME(@DatabaseName) +N'.sys.dm_db_index_operational_stats('
1488
-
+CAST(@DatabaseID ASNVARCHAR(10)) + N', NULL, NULL,NULL) AS os ON
1489
-
ps.object_id=os.object_id and ps.index_id=os.index_id and ps.partition_number=os.partition_number
1490
1526
OUTER APPLY (SELECT st.lock_escalation_desc
1491
1527
FROM '+QUOTENAME(@DatabaseName) + N'.sys.tables st
1492
1528
WHERE st.object_id = ps.object_id
@@ -1506,7 +1542,75 @@ BEGIN TRY
1506
1542
le.lock_escalation_desc,
1507
1543
'+CASEWHEN @SQLServerProductVersion NOTLIKE'9%'THENN'par.data_compression_desc 'ELSEN'null as data_compression_desc 'END+ N'
1508
1544
ORDER BY ps.object_id, ps.index_id, ps.partition_number
1509
-
OPTION ( RECOMPILE );
1545
+
/*OPTION ( RECOMPILE );*/
1546
+
OPTION ( RECOMPILE , min_grant_percent = 1);
1547
+
1548
+
SET @d = CONVERT(VARCHAR(19), GETDATE(), 121)
1549
+
RAISERROR (N''start getting data into #dm_db_index_operational_stats at %s.'',0,1, @d) WITH NOWAIT;
1550
+
1551
+
insert into #dm_db_index_operational_stats
1552
+
(
1553
+
database_id
1554
+
, object_id
1555
+
, index_id
1556
+
, partition_number
1557
+
, hobt_id
1558
+
, leaf_insert_count
1559
+
, leaf_delete_count
1560
+
, leaf_update_count
1561
+
, range_scan_count
1562
+
, singleton_lookup_count
1563
+
, forwarded_fetch_count
1564
+
, lob_fetch_in_pages
1565
+
, lob_fetch_in_bytes
1566
+
, row_overflow_fetch_in_pages
1567
+
, row_overflow_fetch_in_bytes
1568
+
, row_lock_count
1569
+
, row_lock_wait_count
1570
+
, row_lock_wait_in_ms
1571
+
, page_lock_count
1572
+
, page_lock_wait_count
1573
+
, page_lock_wait_in_ms
1574
+
, index_lock_promotion_attempt_count
1575
+
, index_lock_promotion_count
1576
+
, page_latch_wait_count
1577
+
, page_latch_wait_in_ms
1578
+
, page_io_latch_wait_count
1579
+
, page_io_latch_wait_in_ms
1580
+
)
1581
+
1582
+
select os.database_id
1583
+
, os.object_id
1584
+
, os.index_id
1585
+
, os.partition_number
1586
+
, os.hobt_id
1587
+
, os.leaf_insert_count
1588
+
, os.leaf_delete_count
1589
+
, os.leaf_update_count
1590
+
, os.range_scan_count
1591
+
, os.singleton_lookup_count
1592
+
, os.forwarded_fetch_count
1593
+
, os.lob_fetch_in_pages
1594
+
, os.lob_fetch_in_bytes
1595
+
, os.row_overflow_fetch_in_pages
1596
+
, os.row_overflow_fetch_in_bytes
1597
+
, os.row_lock_count
1598
+
, os.row_lock_wait_count
1599
+
, os.row_lock_wait_in_ms
1600
+
, os.page_lock_count
1601
+
, os.page_lock_wait_count
1602
+
, os.page_lock_wait_in_ms
1603
+
, os.index_lock_promotion_attempt_count
1604
+
, os.index_lock_promotion_count
1605
+
, os.page_latch_wait_count
1606
+
, os.page_latch_wait_in_ms
1607
+
, os.page_io_latch_wait_count
1608
+
, os.page_io_latch_wait_in_ms
1609
+
from '+QUOTENAME(@DatabaseName) +N'.sys.dm_db_index_operational_stats('+CAST(@DatabaseID ASNVARCHAR(10)) +', NULL, NULL,NULL) AS os
1610
+
OPTION ( RECOMPILE , min_grant_percent = 1);
1611
+
1612
+
SET @d = CONVERT(VARCHAR(19), GETDATE(), 121)
1613
+
RAISERROR (N''finished getting data into #dm_db_index_operational_stats at %s.'',0,1, @d) WITH NOWAIT;
0 commit comments