File tree 2 files changed +9
-8
lines changed
2 files changed +9
-8
lines changed Original file line number Diff line number Diff line change 1
1
-- Discover indexes that aren't helping reads but still hurting writes
2
2
-- Does not show tables that have never been written to
3
3
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
+
4
8
SELECT DatabaseName = d .name
5
9
, s .object_id
6
10
, TableName = ' [' + sc .name + ' ].[' + o .name + ' ]'
@@ -55,6 +59,4 @@ and is_unique_constraint = 0
55
59
56
60
order by user_seeks + user_scans + user_lookups asc , s .user_updates desc ; -- most useless indexes show up first
57
61
58
-
59
- SELECT servicename, status_desc, last_startup_time FROM sys .dm_server_services ;
60
62
GO
Original file line number Diff line number Diff line change 1
1
-- TODO Set current database context to desired database.
2
2
3
3
-- 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.
5
5
-- Demo lab script to generate a missing index suggestion: toolbox\lab - missing index setup demo.sql
6
6
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
+
7
11
SELECT
8
12
mid .statement
9
13
/* --This block SQL 2017+ only
@@ -55,11 +59,6 @@ and mid.database_id = db_id()
55
59
-- order by avg_user_impact * avg_total_user_cost desc;
56
60
order by create_index_statement;
57
61
58
-
59
- SELECT servicename, status_desc, last_startup_time FROM sys .dm_server_services ;
60
- GO
61
-
62
-
63
62
/*
64
63
65
64
--All databases
You can’t perform that action at this time.
0 commit comments