Skip to content

Commit 1abaab4

Browse files
rene-slowenski-checkmkclaude
authored andcommitted
Add Metabase performance graph SQL sources
Version-control the SQL queries backing the Metabase performance dashboards, with a README documenting the data model, the {{product_release}} / {{scenario_name}} template variables, and what each query produces. Each .sql file also carries a short header comment. Covers filter queries (product_releases, scenario_names), CPU/memory/runtime history graphs (backend + UI variants), the per-release drilldowns with fixed-release baselines, and the per-scenario snapshots. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Change-Id: I5365bc9bd8e4053bd9a24e734d6045c96b3b580e
1 parent 0a64266 commit 1abaab4

15 files changed

Lines changed: 705 additions & 0 deletions
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Metabase performance graph queries
2+
3+
The `.sql` files in this folder are the **source queries for the Metabase
4+
performance dashboards**. Each query is pasted into a Metabase question that
5+
renders a graph (or, for a couple of them, populates a dashboard filter). The
6+
files are kept here so the queries are version-controlled and reviewable
7+
alongside the rest of the performance test suite; Metabase itself remains the
8+
place where they are executed and visualised.
9+
10+
## Data model
11+
12+
The queries read from the performance results database (see the parent
13+
[`README.md`](../README.md) for how it is created):
14+
15+
| Table | Purpose |
16+
| ------------ | --------------------------------------------------------------------------------------------------------------------------- |
17+
| `jobs` | One row per CI performance run. `job_name` is prefixed with the release (`3.0.0-…`); `start_timestamp` records when it ran. |
18+
| `tests` | Individual tests belonging to a job. |
19+
| `scenarios` | The performance scenario a test belongs to (the `test_*` function name). |
20+
| `metrics` | Sampled system-resource values per test, e.g. `cpu_info.cpu_percent`, `memory_info.virtual_memory_percent`. |
21+
| `benchmarks` | Timing measurements per test; `metric_name = 'mean'` is the mean runtime in seconds. |
22+
23+
## Metabase template variables
24+
25+
Some queries use Metabase's `{{ … }}` template syntax:
26+
27+
- `{{product_release}}` — text variable holding a release prefix (e.g. `3.0.0`),
28+
matched against `job_name` with `LIKE CONCAT({{product_release}}, '-%')`.
29+
- `{{scenario_name}}` — a field filter that Metabase expands into a boolean
30+
condition selecting one scenario (used by the drilldown queries).
31+
32+
## The queries
33+
34+
**Filter queries** (populate dashboard dropdowns):
35+
36+
- `product_releases.sql` — distinct release prefixes, newest first → `{{product_release}}`.
37+
- `scenario_names.sql` — the selectable performance scenarios → `{{scenario_name}}`.
38+
39+
**History graphs** — trend over the last 6 months for the selected release,
40+
split into backend and UI (`test_performance_ui_*`) variants:
41+
42+
- `cpu_history.sql` / `cpu_history_ui.sql` — average CPU usage.
43+
- `memory_history.sql` / `memory_history_ui.sql` — average memory usage.
44+
- `runtime_history.sql` / `runtime_history_ui.sql` — average test runtime.
45+
46+
**Drilldown graphs** — a single release and scenario, overlaid with fixed
47+
reference baselines for releases `3.0.0` / `2.5.0` / `2.4.0` / `2.3.0`:
48+
49+
- `cpu_history_drilldown.sql`, `memory_history_drilldown.sql`,
50+
`runtime_history_drilldown.sql`.
51+
52+
**Per-scenario snapshots** — the 3 most recent jobs of the selected release,
53+
broken down by scenario:
54+
55+
- `scenario_cpu_usage.sql`, `scenario_memory_usage.sql`,
56+
`scenario_mean_runtime.sql`.
57+
58+
Each file also carries a short header comment describing what it produces.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
-- Backend CPU history graph: average CPU usage per scenario across all jobs of
2+
-- the selected {{product_release}} in the last 6 months. Backend scenarios only
3+
-- (test_*, excluding UI). Divided by 100 for Metabase's percent
4+
-- formatting.
5+
SELECT
6+
j.job_name AS "Job Name",
7+
s.scenario_name AS "Scenario Name",
8+
AVG(m.measured_value) / 100 AS "Average CPU usage (%)"
9+
FROM
10+
jobs j
11+
JOIN tests t ON j.job_id = t.job_id
12+
JOIN metrics m ON t.test_id = m.test_id
13+
JOIN scenarios s ON t.scenario_id = s.scenario_id
14+
WHERE
15+
j.job_name LIKE CONCAT({{product_release}}, '-%')
16+
AND j.start_timestamp >= now() - INTERVAL '6 months'
17+
AND m.metric_name = 'cpu_info.cpu_percent'
18+
AND s.scenario_name LIKE 'test_%'
19+
AND s.scenario_name NOT LIKE 'test_performance_ui_%'
20+
GROUP BY
21+
j.job_name,
22+
s.scenario_name
23+
ORDER BY
24+
j.job_name ASC;
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
-- CPU drilldown graph: for the selected {{product_release}} and single
2+
-- {{scenario_name}}, plots average CPU usage per job and overlays fixed reference
3+
-- baselines for releases 3.0.0/2.5.0/2.4.0/2.3.0 as extra columns. Each baseline
4+
-- is the average of that release's 100 most recent measurements, skipping the
5+
-- single most recent measurement (OFFSET 1) to avoid an in-progress or outlier build. The
6+
-- per-job value and all baselines are divided by 100 for Metabase's percent
7+
-- formatting, consistent with cpu_history.sql.
8+
WITH
9+
baseline300 AS (
10+
SELECT
11+
AVG(measured_value) AS baseline_cpu_usage
12+
FROM
13+
(
14+
SELECT
15+
m.measured_value
16+
FROM
17+
jobs j
18+
JOIN tests t ON j.job_id = t.job_id
19+
JOIN metrics m ON t.test_id = m.test_id
20+
JOIN scenarios s ON t.scenario_id = s.scenario_id
21+
WHERE
22+
j.job_name LIKE '3.0.0-%'
23+
AND m.metric_name = 'cpu_info.cpu_percent'
24+
AND {{scenario_name}}
25+
ORDER BY
26+
j.start_timestamp DESC
27+
OFFSET
28+
1
29+
LIMIT
30+
100
31+
)
32+
),
33+
baseline250 AS (
34+
SELECT
35+
AVG(measured_value) AS baseline_cpu_usage
36+
FROM
37+
(
38+
SELECT
39+
m.measured_value
40+
FROM
41+
jobs j
42+
JOIN tests t ON j.job_id = t.job_id
43+
JOIN metrics m ON t.test_id = m.test_id
44+
JOIN scenarios s ON t.scenario_id = s.scenario_id
45+
WHERE
46+
j.job_name LIKE '2.5.0-%'
47+
AND m.metric_name = 'cpu_info.cpu_percent'
48+
AND {{scenario_name}}
49+
ORDER BY
50+
j.start_timestamp DESC
51+
OFFSET
52+
1
53+
LIMIT
54+
100
55+
)
56+
),
57+
baseline240 AS (
58+
SELECT
59+
AVG(measured_value) AS baseline_cpu_usage
60+
FROM
61+
(
62+
SELECT
63+
m.measured_value
64+
FROM
65+
jobs j
66+
JOIN tests t ON j.job_id = t.job_id
67+
JOIN metrics m ON t.test_id = m.test_id
68+
JOIN scenarios s ON t.scenario_id = s.scenario_id
69+
WHERE
70+
j.job_name LIKE '2.4.0-%'
71+
AND m.metric_name = 'cpu_info.cpu_percent'
72+
AND {{scenario_name}}
73+
ORDER BY
74+
j.start_timestamp DESC
75+
OFFSET
76+
1
77+
LIMIT
78+
100
79+
)
80+
),
81+
baseline230 AS (
82+
SELECT
83+
AVG(measured_value) AS baseline_cpu_usage
84+
FROM
85+
(
86+
SELECT
87+
m.measured_value
88+
FROM
89+
jobs j
90+
JOIN tests t ON j.job_id = t.job_id
91+
JOIN metrics m ON t.test_id = m.test_id
92+
JOIN scenarios s ON t.scenario_id = s.scenario_id
93+
WHERE
94+
j.job_name LIKE '2.3.0-%'
95+
AND m.metric_name = 'cpu_info.cpu_percent'
96+
AND {{scenario_name}}
97+
ORDER BY
98+
j.start_timestamp DESC
99+
OFFSET
100+
1
101+
LIMIT
102+
100
103+
)
104+
)
105+
SELECT
106+
j.job_name AS "Job Name",
107+
s.scenario_name AS "Scenario Name",
108+
AVG(m.measured_value) / 100 AS "average CPU usage (%)",
109+
b300.baseline_cpu_usage / 100 AS "3.0.0 baseline CPU usage (%)",
110+
b250.baseline_cpu_usage / 100 AS "2.5.0 baseline CPU usage (%)",
111+
b240.baseline_cpu_usage / 100 AS "2.4.0 baseline CPU usage (%)",
112+
b230.baseline_cpu_usage / 100 AS "2.3.0 baseline CPU usage (%)"
113+
FROM
114+
jobs j
115+
JOIN tests t ON j.job_id = t.job_id
116+
JOIN metrics m ON t.test_id = m.test_id
117+
JOIN scenarios s ON t.scenario_id = s.scenario_id
118+
CROSS JOIN baseline300 b300
119+
CROSS JOIN baseline250 b250
120+
CROSS JOIN baseline240 b240
121+
CROSS JOIN baseline230 b230
122+
WHERE
123+
j.job_name LIKE CONCAT({{product_release}}, '-%')
124+
AND j.start_timestamp >= now() - INTERVAL '6 months'
125+
AND m.metric_name = 'cpu_info.cpu_percent'
126+
AND {{scenario_name}}
127+
GROUP BY
128+
j.job_name,
129+
s.scenario_name,
130+
b300.baseline_cpu_usage,
131+
b250.baseline_cpu_usage,
132+
b240.baseline_cpu_usage,
133+
b230.baseline_cpu_usage
134+
ORDER BY
135+
j.job_name ASC;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
-- UI CPU history graph: like cpu_history.sql but for the GUI/UI scenarios
2+
-- (test_performance_ui_*). Same 6-month window and {{product_release}} filter.
3+
SELECT
4+
j.job_name AS "Job Name",
5+
s.scenario_name AS "Scenario Name",
6+
AVG(m.measured_value) / 100 AS "Average CPU usage (%)"
7+
FROM
8+
jobs j
9+
JOIN tests t ON j.job_id = t.job_id
10+
JOIN metrics m ON t.test_id = m.test_id
11+
JOIN scenarios s ON t.scenario_id = s.scenario_id
12+
WHERE
13+
j.job_name LIKE CONCAT({{product_release}}, '-%')
14+
AND j.start_timestamp >= now() - INTERVAL '6 months'
15+
AND m.metric_name = 'cpu_info.cpu_percent'
16+
AND s.scenario_name LIKE 'test_performance_ui_%'
17+
GROUP BY
18+
j.job_name,
19+
s.scenario_name
20+
ORDER BY
21+
j.job_name ASC;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
-- Backend memory history graph: average virtual-memory usage per scenario across
2+
-- all jobs of the selected {{product_release}} in the last 6 months. Backend
3+
-- scenarios only. Divided by 100 for Metabase's percent formatting.
4+
SELECT
5+
j.job_name AS "Job Name",
6+
s.scenario_name AS "Scenario Name",
7+
AVG(m.measured_value) / 100 AS "Average memory usage (%)"
8+
FROM
9+
jobs j
10+
JOIN tests t ON j.job_id = t.job_id
11+
JOIN metrics m ON t.test_id = m.test_id
12+
JOIN scenarios s ON t.scenario_id = s.scenario_id
13+
WHERE
14+
j.job_name LIKE CONCAT({{product_release}}, '-%')
15+
AND j.start_timestamp >= now() - INTERVAL '6 months'
16+
AND m.metric_name = 'memory_info.virtual_memory_percent'
17+
AND s.scenario_name LIKE 'test_%'
18+
AND s.scenario_name NOT LIKE 'test_performance_ui_%'
19+
GROUP BY
20+
j.job_name,
21+
s.scenario_name
22+
ORDER BY
23+
j.job_name ASC;

0 commit comments

Comments
 (0)