Skip to content

Commit 2e73434

Browse files
Merge pull request #717 from erikdarlingdata/fix/hi-clustered-pks
sp_QuickieStore: add clustered PKs to @find_high_impact temp tables
2 parents 0db8641 + 14f65ee commit 2e73434

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

sp_QuickieStore/sp_QuickieStore.sql

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3948,7 +3948,8 @@ BEGIN
39483948
CREATE TABLE
39493949
#hi_plan_stats
39503950
(
3951-
plan_id bigint NOT NULL,
3951+
plan_id bigint NOT NULL
3952+
PRIMARY KEY CLUSTERED,
39523953
total_executions bigint NOT NULL,
39533954
total_cpu_ms decimal(38, 6) NOT NULL,
39543955
min_cpu_ms decimal(38, 6) NULL,
@@ -3971,7 +3972,8 @@ BEGIN
39713972
CREATE TABLE
39723973
#hi_query_stats
39733974
(
3974-
query_hash binary(8) NOT NULL,
3975+
query_hash binary(8) NOT NULL
3976+
PRIMARY KEY CLUSTERED,
39753977
query_count bigint NOT NULL,
39763978
plan_count bigint NOT NULL,
39773979
total_executions bigint NOT NULL,
@@ -4002,6 +4004,7 @@ BEGIN
40024004
#hi_interesting
40034005
(
40044006
query_hash binary(8) NOT NULL
4007+
PRIMARY KEY CLUSTERED
40054008
);
40064009

40074010
CREATE TABLE
@@ -4023,14 +4026,16 @@ BEGIN
40234026
CREATE TABLE
40244027
#hi_primary_window
40254028
(
4026-
query_hash binary(8) NOT NULL,
4029+
query_hash binary(8) NOT NULL
4030+
PRIMARY KEY CLUSTERED,
40274031
primary_window nvarchar(60) NULL
40284032
);
40294033

40304034
CREATE TABLE
40314035
#hi_query_waits
40324036
(
4033-
query_hash binary(8) NOT NULL,
4037+
query_hash binary(8) NOT NULL
4038+
PRIMARY KEY CLUSTERED,
40344039
top_waits nvarchar(max) NULL
40354040
);
40364041

@@ -4046,7 +4051,8 @@ BEGIN
40464051
CREATE TABLE
40474052
#hi_query_identifiers
40484053
(
4049-
query_hash binary(8) NOT NULL,
4054+
query_hash binary(8) NOT NULL
4055+
PRIMARY KEY CLUSTERED,
40504056
query_id_list nvarchar(max) NULL,
40514057
plan_id_list nvarchar(max) NULL,
40524058
object_name nvarchar(500) NULL
@@ -4080,7 +4086,8 @@ BEGIN
40804086
object_name nvarchar(500) NULL,
40814087
query_sql_text nvarchar(max) NULL,
40824088
top_waits nvarchar(max) NULL,
4083-
query_hash binary(8) NOT NULL,
4089+
query_hash binary(8) NOT NULL
4090+
PRIMARY KEY CLUSTERED,
40844091
query_count bigint NOT NULL,
40854092
plan_count bigint NOT NULL,
40864093
query_id_list nvarchar(max) NULL,
@@ -4103,6 +4110,7 @@ BEGIN
41034110
#hi_intervals
41044111
(
41054112
runtime_stats_interval_id bigint NOT NULL
4113+
PRIMARY KEY CLUSTERED
41064114
);
41074115

41084116
SELECT
@@ -4228,7 +4236,7 @@ GROUP BY
42284236
qsrs.plan_id
42294237
HAVING
42304238
SUM(qsrs.count_executions) > 0
4231-
OPTION(RECOMPILE);' + @nc10;
4239+
OPTION(RECOMPILE, HASH JOIN);' + @nc10;
42324240

42334241
IF @debug = 1
42344242
BEGIN

0 commit comments

Comments
 (0)