Skip to content

Commit e679c6b

Browse files
committed
update service restart DMV query and comment when running in Azure SQL DB
1 parent f968cf1 commit e679c6b

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

index_usage_stats.sql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
--Discover indexes that aren't helping reads but still hurting writes
22
--Does not show tables that have never been written to
33

4+
--Cleared when SQL Server restarts. This DMV returns the service start time for both SQL Server and Azure SQL DB.
5+
SELECT sqlserver_start_time FROM sys.dm_os_sys_info;
6+
GO
7+
48
SELECT DatabaseName = d.name
59
, s.object_id
610
, TableName = ' [' + sc.name + '].[' + o.name + ']'
@@ -55,6 +59,4 @@ and is_unique_constraint = 0
5559

5660
order by user_seeks + user_scans + user_lookups asc, s.user_updates desc; --most useless indexes show up first
5761

58-
59-
SELECT servicename, status_desc, last_startup_time FROM sys.dm_server_services;
6062
GO

missing indexes.sql

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
--TODO Set current database context to desired database.
22

33
--Execute this version of the script for the current desired database context only.
4-
--Look below for an all-databases version that cannot build the CREATE statement.
4+
--Look below for an all-databases version, but it cannot build the CREATE statement.
55
--Demo lab script to generate a missing index suggestion: toolbox\lab - missing index setup demo.sql
66

7+
--Cleared when SQL Server restarts. This DMV returns the service start time for both SQL Server and Azure SQL DB.
8+
select sqlserver_start_time from sys.dm_os_sys_info;
9+
GO
10+
711
SELECT
812
mid.statement
913
/* --This block SQL 2017+ only
@@ -55,11 +59,6 @@ and mid.database_id = db_id()
5559
--order by avg_user_impact * avg_total_user_cost desc;
5660
order by create_index_statement;
5761

58-
59-
SELECT servicename, status_desc, last_startup_time FROM sys.dm_server_services;
60-
GO
61-
62-
6362
/*
6463
6564
--All databases

0 commit comments

Comments
 (0)