Skip to content

Commit ad46d40

Browse files
committed
Refactor SQL queries to remove redundant DISTINCT clauses for improved performance
1 parent 02e56c0 commit ad46d40

File tree

5 files changed

+21
-21
lines changed

5 files changed

+21
-21
lines changed

metrics/defaults/sql/alerts.sql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ with
88

99
-- Filter the data to the relevant metric batch for metrics
1010
metric_value_data as (
11-
select distinct
11+
select
1212
metric_timestamp,
1313
metric_batch,
1414
metric_name,
@@ -31,7 +31,7 @@ group by metric_timestamp, metric_batch, metric_name
3131

3232
-- Filter the data to the relevant metric batch for scores
3333
metric_score_data as (
34-
select distinct
34+
select
3535
metric_timestamp,
3636
metric_batch,
3737
metric_name,
@@ -49,7 +49,7 @@ group by metric_timestamp, metric_batch, metric_name
4949

5050
-- Filter the data to the relevant metric batch for alerts
5151
metric_alert_data as (
52-
select distinct
52+
select
5353
metric_timestamp,
5454
metric_batch,
5555
metric_name,
@@ -67,7 +67,7 @@ group by metric_timestamp, metric_batch, metric_name
6767

6868
-- Rank the score data by recency
6969
metric_score_recency_ranked as (
70-
select distinct
70+
select
7171
metric_timestamp,
7272
metric_batch,
7373
metric_name,
@@ -79,7 +79,7 @@ from
7979

8080
-- Rank the value data by recency
8181
metric_value_recency_ranked as (
82-
select distinct
82+
select
8383
metric_timestamp,
8484
metric_batch,
8585
metric_name,

metrics/defaults/sql/change.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ with
88

99
metric_value_data as
1010
(
11-
select distinct
11+
select
1212
metric_timestamp,
1313
metric_batch,
1414
metric_name,
@@ -38,7 +38,7 @@ group by
3838

3939
metric_change_alert_data as
4040
(
41-
select distinct
41+
select
4242
metric_timestamp,
4343
metric_batch,
4444
metric_name,
@@ -68,7 +68,7 @@ group by
6868

6969
metric_value_recency_ranked as
7070
(
71-
select distinct
71+
select
7272
metric_value_data.metric_timestamp,
7373
metric_value_data.metric_batch,
7474
metric_value_data.metric_name,
@@ -91,7 +91,7 @@ on
9191
-- Snooze any metrics with change alerts in the last {{ change_snooze_n }} values
9292
snoozed_metric_names as
9393
(
94-
select distinct
94+
select
9595
metric_name
9696
from
9797
metric_value_recency_ranked

metrics/defaults/sql/dashboard.sql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Template for generating the input data for the plot job.
55
WITH
66

77
metric_value_data AS (
8-
SELECT DISTINCT
8+
SELECT
99
metric_timestamp,
1010
metric_batch,
1111
metric_name,
@@ -18,7 +18,7 @@ metric_value_data AS (
1818
),
1919

2020
metric_score_data AS (
21-
SELECT DISTINCT
21+
SELECT
2222
metric_timestamp,
2323
metric_batch,
2424
metric_name,
@@ -31,7 +31,7 @@ metric_score_data AS (
3131
),
3232

3333
metric_alert_data AS (
34-
SELECT DISTINCT
34+
SELECT
3535
metric_timestamp,
3636
metric_batch,
3737
metric_name,
@@ -44,7 +44,7 @@ metric_alert_data AS (
4444
),
4545

4646
metric_change_data AS (
47-
SELECT DISTINCT
47+
SELECT
4848
metric_timestamp,
4949
metric_batch,
5050
metric_name,
@@ -67,7 +67,7 @@ metric_value_recency_ranked AS (
6767
),
6868

6969
metric_score_recency_ranked AS (
70-
SELECT DISTINCT
70+
SELECT
7171
metric_timestamp,
7272
metric_batch,
7373
metric_name,

metrics/defaults/sql/llmalert.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ with
66

77
metric_value_data as
88
(
9-
select distinct
9+
select
1010
metric_timestamp,
1111
metric_batch,
1212
metric_name,
@@ -24,7 +24,7 @@ group by metric_timestamp, metric_batch, metric_name
2424

2525
metric_score_data as
2626
(
27-
select distinct
27+
select
2828
metric_timestamp,
2929
metric_batch,
3030
metric_name,
@@ -42,7 +42,7 @@ group by metric_timestamp, metric_batch, metric_name
4242

4343
metric_alert_data as
4444
(
45-
select distinct
45+
select
4646
metric_timestamp,
4747
metric_batch,
4848
metric_name,

metrics/defaults/sql/plot.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Template for generating the input data for the plot job.
55
WITH
66

77
metric_value_data AS (
8-
SELECT DISTINCT
8+
SELECT
99
metric_timestamp,
1010
metric_batch,
1111
metric_name,
@@ -18,7 +18,7 @@ metric_value_data AS (
1818
),
1919

2020
metric_score_data AS (
21-
SELECT DISTINCT
21+
SELECT
2222
metric_timestamp,
2323
metric_batch,
2424
metric_name,
@@ -31,7 +31,7 @@ metric_score_data AS (
3131
),
3232

3333
metric_alert_data AS (
34-
SELECT DISTINCT
34+
SELECT
3535
metric_timestamp,
3636
metric_batch,
3737
metric_name,
@@ -44,7 +44,7 @@ metric_alert_data AS (
4444
),
4545

4646
metric_change_data AS (
47-
SELECT DISTINCT
47+
SELECT
4848
metric_timestamp,
4949
metric_batch,
5050
metric_name,

0 commit comments

Comments
 (0)