Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance 2020 query update #1595

Merged
merged 2 commits into from
Nov 30, 2020
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
47 changes: 27 additions & 20 deletions sql/2020/09_Performance/lh6_vs_lh5_performance_score_02.sql
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
#standardSQL

# Calculates percentage of sites where the performance score changed low ( < 10), medium (10-30) or big (> 30) between
# LH 5 and 6 versions.

# Calculates percentage of sites where the performance score changed small ( < 10), medium (10-30) or large (> 30) between LH 5 and 6 versions.
SELECT
SAFE_DIVIDE(small_change, small_change + mid_change + big_change) AS small,
SAFE_DIVIDE(mid_change, small_change + mid_change + big_change) AS avg,
SAFE_DIVIDE(big_change, small_change + mid_change + big_change) AS big
direction,
magnitude,
pages AS freq,
SUM(pages) OVER () AS total,
pages / SUM(pages) OVER () AS pct
FROM (
SELECT
COUNTIF(perf_score_delta <= 0.1) AS small_change,
COUNTIF(perf_score_delta > 0.1 AND perf_score_delta <= 0.3) AS mid_change,
COUNTIF(perf_score_delta > 0.3) AS big_change
FROM
(
CASE
WHEN perf_score_delta < 0 THEN 'negative'
ELSE 'positive'
END AS direction,
CASE
WHEN ABS(perf_score_delta) <= 0.1 THEN 'small'
WHEN ABS(perf_score_delta) < 0.3 THEN 'large'
ELSE 'medium'
END AS magnitude,
COUNT(0) AS pages
FROM (
SELECT
perf_score_lh6,
perf_score_lh5,
(perf_score_lh6 - perf_score_lh5) AS perf_score_delta
FROM
(
perf_score_lh6 - perf_score_lh5 AS perf_score_delta
FROM (
SELECT
CAST(JSON_EXTRACT(lh6.report, '$.categories.performance.score') AS NUMERIC) AS perf_score_lh6,
CAST(JSON_EXTRACT(lh5.report, '$.categories.performance.score') AS NUMERIC) AS perf_score_lh5
FROM `httparchive.lighthouse.2020_09_01_mobile` lh6
JOIN `httparchive.lighthouse.2019_07_01_mobile` lh5 ON lh5.url=lh6.url
)
)
)
FROM
`httparchive.lighthouse.2020_09_01_mobile` AS lh6
JOIN
`httparchive.lighthouse.2019_07_01_mobile` AS lh5
USING (url)))
GROUP BY
direction,
magnitude)
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#standardSQL
SELECT
perf_score_delta,
COUNT(0) AS pages
FROM (
SELECT
perf_score_lh6 - perf_score_lh5 AS perf_score_delta,
ROW_NUMBER() OVER (ORDER BY (perf_score_lh6 - perf_score_lh5)) AS row_number,
COUNT(0) OVER () AS n
FROM (
SELECT
CAST(JSON_EXTRACT(lh6.report, '$.categories.performance.score') AS NUMERIC) AS perf_score_lh6,
CAST(JSON_EXTRACT(lh5.report, '$.categories.performance.score') AS NUMERIC) AS perf_score_lh5
FROM
`httparchive.lighthouse.2020_09_01_mobile` AS lh6
JOIN
`httparchive.lighthouse.2019_07_01_mobile` AS lh5
USING (url)))
WHERE
perf_score_delta IS NOT NULL
GROUP BY
perf_score_delta
ORDER BY
perf_score_delta