Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions install/08_collect_query_stats.sql
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,16 @@ BEGIN
END;

/*
First run detection - collect all queries if this is the first execution
First run detection - collect last 1 hour of queries if this is the first execution
*/
IF NOT EXISTS (SELECT 1/0 FROM collect.query_stats)
AND NOT EXISTS (SELECT 1/0 FROM config.collection_log WHERE collector_name = N'query_stats_collector')
BEGIN
SET @cutoff_time = CONVERT(datetime2(7), '19000101');
SET @cutoff_time = DATEADD(HOUR, -1, SYSDATETIME());

IF @debug = 1
BEGIN
RAISERROR(N'First run detected - collecting all queries from sys.dm_exec_query_stats', 0, 1) WITH NOWAIT;
RAISERROR(N'First run detected - collecting last 1 hour of query stats', 0, 1) WITH NOWAIT;
END;
END;
ELSE
Expand Down
6 changes: 3 additions & 3 deletions install/09_collect_query_store.sql
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,16 @@ BEGIN
END;

/*
First run detection - collect 3 days of history if this is the first execution
First run detection - collect last 1 hour of history if this is the first execution
*/
IF NOT EXISTS (SELECT 1/0 FROM collect.query_store_data)
AND NOT EXISTS (SELECT 1/0 FROM config.collection_log WHERE collector_name = N'query_store_collector')
BEGIN
SET @cutoff_time = TODATETIMEOFFSET(DATEADD(DAY, -3, SYSUTCDATETIME()), 0);
SET @cutoff_time = TODATETIMEOFFSET(DATEADD(HOUR, -1, SYSUTCDATETIME()), 0);

IF @debug = 1
BEGIN
RAISERROR(N'First run detected - collecting last 3 days of Query Store data', 0, 1) WITH NOWAIT;
RAISERROR(N'First run detected - collecting last 1 hour of Query Store data', 0, 1) WITH NOWAIT;
END;
END;
ELSE
Expand Down
6 changes: 3 additions & 3 deletions install/10_collect_procedure_stats.sql
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,16 @@ BEGIN
END;

/*
First run detection - collect all procedures if this is the first execution
First run detection - collect last 1 hour of procedures if this is the first execution
*/
IF NOT EXISTS (SELECT 1/0 FROM collect.procedure_stats)
AND NOT EXISTS (SELECT 1/0 FROM config.collection_log WHERE collector_name = N'procedure_stats_collector')
BEGIN
SET @cutoff_time = CONVERT(datetime2(7), '19000101');
SET @cutoff_time = DATEADD(HOUR, -1, SYSDATETIME());

IF @debug = 1
BEGIN
RAISERROR(N'First run detected - collecting all procedures from sys.dm_exec_procedure_stats', 0, 1) WITH NOWAIT;
RAISERROR(N'First run detected - collecting last 1 hour of procedure stats', 0, 1) WITH NOWAIT;
END;
END;
ELSE
Expand Down
4 changes: 2 additions & 2 deletions install/18_collect_cpu_utilization_stats.sql
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ BEGIN
/*
Collect CPU utilization data from ring buffers
Only collects samples newer than the most recent sample we have
On first run (NULL max_sample_time), looks back 7 days to populate initial data
On first run (NULL max_sample_time), looks back 1 hour to populate initial data
Avoids duplicate collection of same ring buffer events
*/
INSERT INTO
Expand Down Expand Up @@ -156,7 +156,7 @@ BEGIN
SECOND,
-((@current_ms_ticks - t.timestamp) / 1000),
@start_time
) > ISNULL(@max_sample_time, DATEADD(DAY, -7, @start_time))
) > ISNULL(@max_sample_time, DATEADD(HOUR, -1, @start_time))
ORDER BY
t.timestamp DESC
OPTION(RECOMPILE);
Expand Down
6 changes: 3 additions & 3 deletions install/22_collect_blocked_processes.sql
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,17 @@ BEGIN
END;

/*
First run detection - collect 3 days of history if this is the first execution
First run detection - collect last 1 hour of history if this is the first execution
*/
IF NOT EXISTS (SELECT 1/0 FROM collect.blocked_process_xml)
AND NOT EXISTS (SELECT 1/0 FROM config.collection_log WHERE collector_name = N'blocked_process_xml_collector')
BEGIN
SET @minutes_back = 4320; /*3 days*/
SET @minutes_back = 60; /*1 hour*/
SET @cutoff_time = DATEADD(MINUTE, -@minutes_back, SYSUTCDATETIME());

IF @debug = 1
BEGIN
RAISERROR(N'First run detected - collecting last 3 days of blocked process events', 0, 1) WITH NOWAIT;
RAISERROR(N'First run detected - collecting last 1 hour of blocked process events', 0, 1) WITH NOWAIT;
END;
END;

Expand Down
6 changes: 3 additions & 3 deletions install/24_collect_deadlock_xml.sql
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,17 @@ BEGIN
END;

/*
First run detection - collect 3 days of history if this is the first execution
First run detection - collect last 1 hour of history if this is the first execution
*/
IF NOT EXISTS (SELECT 1/0 FROM collect.deadlock_xml)
AND NOT EXISTS (SELECT 1/0 FROM config.collection_log WHERE collector_name = N'deadlock_xml_collector')
BEGIN
SET @minutes_back = 4320; /*3 days*/
SET @minutes_back = 60; /*1 hour*/
SET @cutoff_time = DATEADD(MINUTE, -@minutes_back, SYSUTCDATETIME());

IF @debug = 1
BEGIN
RAISERROR(N'First run detected - collecting last 3 days of deadlock events', 0, 1) WITH NOWAIT;
RAISERROR(N'First run detected - collecting last 1 hour of deadlock events', 0, 1) WITH NOWAIT;
END;
END;

Expand Down
6 changes: 3 additions & 3 deletions install/28_collect_system_health_wrapper.sql
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,16 @@ BEGIN
END;

/*
First run detection - collect 3 days of history if this is the first execution
First run detection - collect last 1 hour of history if this is the first execution
*/
IF NOT EXISTS (SELECT 1/0 FROM config.collection_log WHERE collector_name = N'system_health_collector')
BEGIN
SET @hours_back = 72; /*3 days*/
SET @hours_back = 1; /*1 hour*/
SET @start_date = DATEADD(HOUR, -@hours_back, SYSDATETIMEOFFSET());

IF @debug = 1
BEGIN
RAISERROR(N'First run detected - collecting last 3 days of system health data', 0, 1) WITH NOWAIT;
RAISERROR(N'First run detected - collecting last 1 hour of system health data', 0, 1) WITH NOWAIT;
END;
END;

Expand Down
6 changes: 3 additions & 3 deletions install/29_collect_default_trace.sql
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,17 @@ BEGIN
END;

/*
First run detection - collect all available trace data if this is the first execution
First run detection - collect last 1 hour of trace data if this is the first execution
Ignore CONFIG_CHANGE entries when checking for first run (those are just from enabling the trace)
*/
IF NOT EXISTS (SELECT 1/0 FROM collect.default_trace_events)
AND NOT EXISTS (SELECT 1/0 FROM config.collection_log WHERE collector_name = N'default_trace_collector' AND collection_status = N'SUCCESS')
BEGIN
SET @cutoff_time = CONVERT(datetime2(7), '19000101');
SET @cutoff_time = DATEADD(HOUR, -1, SYSDATETIME());

IF @debug = 1
BEGIN
RAISERROR(N'First run detected - collecting all available default trace events', 0, 1) WITH NOWAIT;
RAISERROR(N'First run detected - collecting last 1 hour of default trace events', 0, 1) WITH NOWAIT;
END;
END;

Expand Down
Loading