From 8dd8a92f2fd6db669342d1b02be7b87b84f61d16 Mon Sep 17 00:00:00 2001 From: "dooman87@gmail.com" Date: Mon, 20 Jul 2020 06:02:20 +1000 Subject: [PATCH 01/39] Selecting LH performance score. WIP --- sql/2020/9_Performance/lighthouse_performance_score.sql | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 sql/2020/9_Performance/lighthouse_performance_score.sql diff --git a/sql/2020/9_Performance/lighthouse_performance_score.sql b/sql/2020/9_Performance/lighthouse_performance_score.sql new file mode 100644 index 00000000000..f0c536cb202 --- /dev/null +++ b/sql/2020/9_Performance/lighthouse_performance_score.sql @@ -0,0 +1,4 @@ +#standardSQL +# LH5 vs LH6 score + +SELECT url, JSON_EXTRACT(report, '$.categories.performance.score') AS performance_score FROM `httparchive.sample_data.lighthouse_mobile_10k` LIMIT 100 \ No newline at end of file From 8892bb1a872205692f2eabdd22149d818d628f1e Mon Sep 17 00:00:00 2001 From: "dooman87@gmail.com" Date: Tue, 21 Jul 2020 06:31:47 +1000 Subject: [PATCH 02/39] Selecting LH performance score. WIP --- sql/2020/9_Performance/lh6_vs_lh5_score_distribution.sql | 8 ++++++++ sql/2020/9_Performance/lighthouse_performance_score.sql | 4 ---- 2 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 sql/2020/9_Performance/lh6_vs_lh5_score_distribution.sql delete mode 100644 sql/2020/9_Performance/lighthouse_performance_score.sql diff --git a/sql/2020/9_Performance/lh6_vs_lh5_score_distribution.sql b/sql/2020/9_Performance/lh6_vs_lh5_score_distribution.sql new file mode 100644 index 00000000000..2da9206b9ab --- /dev/null +++ b/sql/2020/9_Performance/lh6_vs_lh5_score_distribution.sql @@ -0,0 +1,8 @@ +#standardSQL +# LH5 vs LH6 score. WIP + +# Performance Score +SELECT url, JSON_EXTRACT(report, '$.categories.performance.score') AS performance_score FROM `httparchive.sample_data.lighthouse_mobile_10k` LIMIT 100 + +# Intersected URLs for LH5 and LH6 +SELECT lh6.url AS lh6_url, lh5.url AS lh5_url FROM `httparchive.lighthouse.2020_06_01_mobile` lh6 JOIN `httparchive.lighthouse.2020_03_01_mobile` lh5 ON lh5.url=lh6.url \ No newline at end of file diff --git a/sql/2020/9_Performance/lighthouse_performance_score.sql b/sql/2020/9_Performance/lighthouse_performance_score.sql deleted file mode 100644 index f0c536cb202..00000000000 --- a/sql/2020/9_Performance/lighthouse_performance_score.sql +++ /dev/null @@ -1,4 +0,0 @@ -#standardSQL -# LH5 vs LH6 score - -SELECT url, JSON_EXTRACT(report, '$.categories.performance.score') AS performance_score FROM `httparchive.sample_data.lighthouse_mobile_10k` LIMIT 100 \ No newline at end of file From 5ec786012ac89f177fabb4fa6802b12a6423d680 Mon Sep 17 00:00:00 2001 From: "dooman87@gmail.com" Date: Tue, 21 Jul 2020 07:14:56 +1000 Subject: [PATCH 03/39] Selecting LH performance score. WIP --- .../9_Performance/lh6_vs_lh5_score_distribution.sql | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sql/2020/9_Performance/lh6_vs_lh5_score_distribution.sql b/sql/2020/9_Performance/lh6_vs_lh5_score_distribution.sql index 2da9206b9ab..b082737a7a0 100644 --- a/sql/2020/9_Performance/lh6_vs_lh5_score_distribution.sql +++ b/sql/2020/9_Performance/lh6_vs_lh5_score_distribution.sql @@ -1,8 +1,9 @@ #standardSQL # LH5 vs LH6 score. WIP -# Performance Score -SELECT url, JSON_EXTRACT(report, '$.categories.performance.score') AS performance_score FROM `httparchive.sample_data.lighthouse_mobile_10k` LIMIT 100 - -# Intersected URLs for LH5 and LH6 -SELECT lh6.url AS lh6_url, lh5.url AS lh5_url FROM `httparchive.lighthouse.2020_06_01_mobile` lh6 JOIN `httparchive.lighthouse.2020_03_01_mobile` lh5 ON lh5.url=lh6.url \ No newline at end of file +# Performance Score from LH5 and LH6 +SELECT lh6.url AS url, + JSON_EXTRACT(lh6.report, '$.categories.performance.score') AS perf_score_lh6, + JSON_EXTRACT(lh5.report, '$.categories.performance.score') AS perf_score_lh5, + FROM `httparchive.sample_data.lighthouse_mobile_10k` lh6 + JOIN `httparchive.scratchspace.2020_03_01_lighthouse_mobile_10k` lh5 ON lh5.url=lh6.url \ No newline at end of file From 8e949842cd56f924f8d18360ff6a1e1a23033136 Mon Sep 17 00:00:00 2001 From: "dooman87@gmail.com" Date: Thu, 23 Jul 2020 07:15:54 +1000 Subject: [PATCH 04/39] Delta for LH5 and LH6 performance scores --- .../lh6_vs_lh5_score_distribution.sql | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/sql/2020/9_Performance/lh6_vs_lh5_score_distribution.sql b/sql/2020/9_Performance/lh6_vs_lh5_score_distribution.sql index b082737a7a0..69d9287a0cf 100644 --- a/sql/2020/9_Performance/lh6_vs_lh5_score_distribution.sql +++ b/sql/2020/9_Performance/lh6_vs_lh5_score_distribution.sql @@ -1,9 +1,21 @@ #standardSQL # LH5 vs LH6 score. WIP -# Performance Score from LH5 and LH6 -SELECT lh6.url AS url, - JSON_EXTRACT(lh6.report, '$.categories.performance.score') AS perf_score_lh6, - JSON_EXTRACT(lh5.report, '$.categories.performance.score') AS perf_score_lh5, - FROM `httparchive.sample_data.lighthouse_mobile_10k` lh6 - JOIN `httparchive.scratchspace.2020_03_01_lighthouse_mobile_10k` lh5 ON lh5.url=lh6.url \ No newline at end of file +# Calculates minimum, maximum and average delta between LH5 and LH6 performance score +SELECT MIN(perf_score_delta) AS min_delta, MAX(perf_score_delta) AS max_delta, AVG(perf_score_delta) AS avg_delta +FROM +( + SELECT + url, + perf_score_lh6, + perf_score_lh5, + (perf_score_lh6 - perf_score_lh5) as perf_score_delta + FROM + ( + SELECT lh6.url AS url, + 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.sample_data.lighthouse_mobile_10k` lh6 + JOIN `httparchive.scratchspace.2020_03_01_lighthouse_mobile_10k` lh5 ON lh5.url=lh6.url + ) +) \ No newline at end of file From a67e276d7e6dfcbb72798471f75633685e922f6f Mon Sep 17 00:00:00 2001 From: "dooman87@gmail.com" Date: Thu, 23 Jul 2020 07:27:47 +1000 Subject: [PATCH 05/39] Delta for LH5 and LH6 performance scores --- ...ql => lh6_vs_lh5_performance_score_01.sql} | 3 +-- .../lh6_vs_lh5_performance_score_02.sql | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) rename sql/2020/9_Performance/{lh6_vs_lh5_score_distribution.sql => lh6_vs_lh5_performance_score_01.sql} (93%) create mode 100644 sql/2020/9_Performance/lh6_vs_lh5_performance_score_02.sql diff --git a/sql/2020/9_Performance/lh6_vs_lh5_score_distribution.sql b/sql/2020/9_Performance/lh6_vs_lh5_performance_score_01.sql similarity index 93% rename from sql/2020/9_Performance/lh6_vs_lh5_score_distribution.sql rename to sql/2020/9_Performance/lh6_vs_lh5_performance_score_01.sql index 69d9287a0cf..76daf3b8733 100644 --- a/sql/2020/9_Performance/lh6_vs_lh5_score_distribution.sql +++ b/sql/2020/9_Performance/lh6_vs_lh5_performance_score_01.sql @@ -1,7 +1,6 @@ #standardSQL -# LH5 vs LH6 score. WIP -# Calculates minimum, maximum and average delta between LH5 and LH6 performance score +# Calculates minimum, maximum and average delta between LH5 and LH6 performance score for mobile SELECT MIN(perf_score_delta) AS min_delta, MAX(perf_score_delta) AS max_delta, AVG(perf_score_delta) AS avg_delta FROM ( diff --git a/sql/2020/9_Performance/lh6_vs_lh5_performance_score_02.sql b/sql/2020/9_Performance/lh6_vs_lh5_performance_score_02.sql new file mode 100644 index 00000000000..b43a4e69062 --- /dev/null +++ b/sql/2020/9_Performance/lh6_vs_lh5_performance_score_02.sql @@ -0,0 +1,24 @@ +#standardSQL + +# Calculates number of sites where the performance score changed low ( < 10), medium (10-30) or big (> 30) between +# LH 5 and 6 versions. +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 +( + SELECT + url, + perf_score_lh6, + perf_score_lh5, + (perf_score_lh6 - perf_score_lh5) as perf_score_delta + FROM + ( + SELECT lh6.url AS url, + 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.sample_data.lighthouse_mobile_10k` lh6 + JOIN `httparchive.scratchspace.2020_03_01_lighthouse_mobile_10k` lh5 ON lh5.url=lh6.url + ) +) \ No newline at end of file From b111b5a6d21b721e1bdf1488be91d76846d7c761 Mon Sep 17 00:00:00 2001 From: "dooman87@gmail.com" Date: Thu, 23 Jul 2020 10:10:01 +1000 Subject: [PATCH 06/39] Delta for LH5 and LH6 performance scores --- .../lh6_vs_lh5_performance_score_01.sql | 0 .../lh6_vs_lh5_performance_score_02.sql | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename sql/2020/{9_Performance => 09_Performance}/lh6_vs_lh5_performance_score_01.sql (100%) rename sql/2020/{9_Performance => 09_Performance}/lh6_vs_lh5_performance_score_02.sql (100%) diff --git a/sql/2020/9_Performance/lh6_vs_lh5_performance_score_01.sql b/sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql similarity index 100% rename from sql/2020/9_Performance/lh6_vs_lh5_performance_score_01.sql rename to sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql diff --git a/sql/2020/9_Performance/lh6_vs_lh5_performance_score_02.sql b/sql/2020/09_Performance/lh6_vs_lh5_performance_score_02.sql similarity index 100% rename from sql/2020/9_Performance/lh6_vs_lh5_performance_score_02.sql rename to sql/2020/09_Performance/lh6_vs_lh5_performance_score_02.sql From 38580fa1abaeed0a973ddcd33ecd17819d198d1d Mon Sep 17 00:00:00 2001 From: Max Ostapenko Date: Thu, 23 Jul 2020 03:54:38 +0100 Subject: [PATCH 07/39] web vitals aggregated --- .../09_Performance/web_vitals_per_device.sql | 202 ++++++++++++++++++ 1 file changed, 202 insertions(+) create mode 100644 sql/2020/09_Performance/web_vitals_per_device.sql diff --git a/sql/2020/09_Performance/web_vitals_per_device.sql b/sql/2020/09_Performance/web_vitals_per_device.sql new file mode 100644 index 00000000000..4e6d7483057 --- /dev/null +++ b/sql/2020/09_Performance/web_vitals_per_device.sql @@ -0,0 +1,202 @@ +#standardSQL +# TODO: add FCP and TTFB + +WITH + base AS ( + SELECT + # remove literals after switching to country table + 202006 AS yyyymm, +  'pt' AS country_code, +  origin, + # to exclude dimension from segmentation + #'all' AS device, + form_factor.name AS device, + effective_connection_type.name AS network, + layout_instability, + largest_contentful_paint, + first_input + FROM + # change to `chrome-ux-report.experimental.country` + `chrome-ux-report.country_zw.202006` + WHERE + form_factor.name in ('desktop','phone') + # filtered by origin for debug + #origin = "http://borwap.com" + # uncomment for country table + #yyyymm = 202006 + ), + dimensions AS ( + SELECT + yyyymm, + country_code, + origin, + device, + network + FROM + base + GROUP BY + yyyymm, + country_code, + origin, + device, + network + ), + cls AS ( + SELECT + yyyymm, + country_code, + origin, + device, + network, + ROUND(SUM(IF(bin.start < 0.1, bin.density, 0)), 4) AS small, + ROUND(SUM(IF(bin.start > 0.1 AND bin.start < 0.25, bin.density, 0)), 4) AS medium, + ROUND(SUM(IF(bin.start >= 0.25, bin.density, 0)), 4) AS large, + `chrome-ux-report`.experimental.PERCENTILE_NUMERIC(ARRAY_AGG(bin), 75) AS p75 + FROM + base + LEFT JOIN + UNNEST(layout_instability.cumulative_layout_shift.histogram.bin) AS bin + WHERE + bin IS NOT NULL + GROUP BY + yyyymm, + country_code, + origin, + device, + network + ), + lcp AS ( + SELECT + yyyymm, + country_code, + origin, + device, + network, + ROUND(SUM(IF(bin.start < 2500, bin.density, 0)), 4) AS fast, + ROUND(SUM(IF(bin.start >= 2500 AND bin.start < 4000, bin.density, 0)), 4) AS avg, + ROUND(SUM(IF(bin.start >= 4000, bin.density, 0)), 4) AS slow, + `chrome-ux-report`.experimental.PERCENTILE(ARRAY_AGG(bin), 75) AS p75 + FROM + base + LEFT JOIN + UNNEST(largest_contentful_paint.histogram.bin) AS bin + WHERE + bin IS NOT NULL + GROUP BY + yyyymm, + country_code, + origin, + device, + network + ), + fid AS ( + SELECT + yyyymm, + country_code, + origin, + device, + network, + ROUND(SUM(IF(bin.start < 100, bin.density, 0)), 4) AS fast, + ROUND(SUM(IF(bin.start >= 100 AND bin.start < 300, bin.density, 0)), 4) AS avg, + ROUND(SUM(IF(bin.start >= 300, bin.density, 0)), 4) AS slow, + `chrome-ux-report`.experimental.PERCENTILE(ARRAY_AGG(bin), 75) AS p75 + FROM + base + LEFT JOIN + UNNEST(first_input.delay.histogram.bin) AS bin + WHERE + bin IS NOT NULL + GROUP BY + yyyymm, + country_code, + origin, + device, + network + ), + granular_metrics AS ( + SELECT + yyyymm, + country_code, + origin, + device, + network, + cls.small AS small_cls, + cls.medium AS medium_cls, + cls.large AS large_cls, + cls.p75 AS p75_cls, + + lcp.fast AS fast_lcp, + lcp.avg AS avg_lcp, + lcp.slow AS slow_lcp, + lcp.p75 AS p75_lcp, + + fid.fast AS fast_fid, + fid.avg AS avg_fid, + fid.slow AS slow_fid, + fid.p75 AS p75_fid, + FROM + dimensions + LEFT JOIN + cls + USING + (yyyymm, country_code, origin, device, network) + LEFT JOIN + lcp + USING + (yyyymm, country_code, origin, device, network) + LEFT JOIN + fid + USING + (yyyymm, country_code, origin, device, network)), + adjusted_metrics AS ( + SELECT + yyyymm, + country_code, + origin, + device, + network, + SAFE_DIVIDE(fast_lcp, fast_lcp+avg_lcp+slow_lcp) AS fast_lcp_adjusted, + SAFE_DIVIDE(avg_lcp, fast_lcp+avg_lcp+slow_lcp) AS avg_lcp_adjusted, + SAFE_DIVIDE(slow_lcp, fast_lcp+avg_lcp+slow_lcp) AS slow_lcp_adjusted, + + SAFE_DIVIDE(fast_fid, fast_fid+avg_fid+slow_fid) AS fast_fid_adjusted, + SAFE_DIVIDE(avg_fid, fast_fid+avg_fid+slow_fid) AS avg_fid_adjusted, + SAFE_DIVIDE(slow_fid, fast_fid+avg_fid+slow_fid) AS slow_fid_adjusted, + + SAFE_DIVIDE(small_cls, small_cls+medium_cls+large_cls) AS small_cls_adjusted, + SAFE_DIVIDE(medium_cls, small_cls+medium_cls+large_cls) AS medium_cls_adjusted, + SAFE_DIVIDE(large_cls, small_cls+medium_cls+large_cls) AS large_cls_adjusted, + + FROM + granular_metrics) + +SELECT + yyyymm, +  country_code, +  device, + network, + COUNT(0) AS total_origins, + + ROUND(COUNTIF( fast_lcp_adjusted >= 0.75 AND fast_fid_adjusted >= 0.75 AND small_cls_adjusted >= 0.75) * 100 / COUNT(0), 2) AS pct_corewebvitals_pass, + + ROUND(COUNTIF( fast_lcp_adjusted >= 0.75) * 100 / COUNT(0), 2) AS pct_corewebvitals_lcp_good, + ROUND(COUNTIF( fast_lcp_adjusted < 0.75 AND slow_lcp_adjusted < 0.25) * 100 / COUNT(0), 2) AS pct_corewebvitals_lcp_ni, + ROUND(COUNTIF( slow_lcp_adjusted >= 0.25 OR slow_lcp_adjusted IS NULL) * 100 / COUNT(0), 2) AS pct_corewebvitals_lcp_poor, + + ROUND(COUNTIF( fast_fid_adjusted >= 0.75) * 100 / COUNT(0), 2) AS pct_corewebvitals_fid_good, + ROUND(COUNTIF( fast_fid_adjusted < 0.75 AND slow_fid_adjusted < 0.25) * 100 / COUNT(0), 2) AS pct_corewebvitals_fid_ni, + ROUND(COUNTIF( slow_fid_adjusted >= 0.25 OR slow_fid_adjusted IS NULL) * 100 / COUNT(0), 2) AS pct_corewebvitals_fid_poor, + + ROUND(COUNTIF( small_cls_adjusted >= 0.75) * 100 / COUNT(0), 2) AS pct_corewebvitals_cls_good, + ROUND(COUNTIF( small_cls_adjusted < 0.75 AND large_cls_adjusted < 0.25) * 100 / COUNT(0), 2) AS pct_corewebvitals_cls_ni, + ROUND(COUNTIF( large_cls_adjusted >= 0.25 OR large_cls_adjusted IS NULL) * 100 / COUNT(0), 2) AS pct_corewebvitals_cls_poor, + +FROM + adjusted_metrics +GROUP BY + yyyymm, +  country_code, +  device, + network +# exclude small segments +#HAVING total_origins > 1000 \ No newline at end of file From 7d007b762fbcfaf7311a133be14e4587946a54d8 Mon Sep 17 00:00:00 2001 From: "dooman87@gmail.com" Date: Sat, 25 Jul 2020 07:46:21 +1000 Subject: [PATCH 08/39] Web Vitals query suggested in the discussion --- .../web_vitals_suggested_by_rick.sql | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 sql/2020/09_Performance/web_vitals_suggested_by_rick.sql diff --git a/sql/2020/09_Performance/web_vitals_suggested_by_rick.sql b/sql/2020/09_Performance/web_vitals_suggested_by_rick.sql new file mode 100644 index 00000000000..12e1bad773b --- /dev/null +++ b/sql/2020/09_Performance/web_vitals_suggested_by_rick.sql @@ -0,0 +1,39 @@ +CREATE TEMP FUNCTION IS_GOOD (good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS ( + good / (good + needs_improvement + poor) >= 0.75 +); + +CREATE TEMP FUNCTION IS_NON_ZERO (good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS ( + good + needs_improvement + poor > 0 +); + + +SELECT + # Origins with good LCP divided by origins with any LCP. + SAFE_DIVIDE( + COUNT(DISTINCT IF(IS_GOOD(fast_lcp, avg_lcp, slow_lcp), origin, NULL)), + COUNT(DISTINCT IF(IS_NON_ZERO(fast_lcp, avg_lcp, slow_lcp), origin, NULL))) AS pct_good_lcp, + + # Origins with good FID divided by origins with any FID. + SAFE_DIVIDE( + COUNT(DISTINCT IF(IS_GOOD(fast_fid, avg_fid, slow_fid), origin, NULL)), + COUNT(DISTINCT IF(IS_NON_ZERO(fast_fid, avg_fid, slow_fid), origin, NULL))) AS pct_good_fid, + + # Origins with good CLS divided by origins with any CLS. + SAFE_DIVIDE( + COUNT(DISTINCT IF(IS_GOOD(small_cls, medium_cls, large_cls), origin, NULL)), + COUNT(DISTINCT IF(IS_NON_ZERO(small_cls, medium_cls, large_cls), origin, NULL))) AS pct_good_cls, + + # Origins with good LCP, FID, and CLS dividied by origins with any LCP, FID, and CLS. + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_GOOD(fast_lcp, avg_lcp, slow_lcp) AND + IS_GOOD(fast_fid, avg_fid, slow_fid) AND + IS_GOOD(small_cls, medium_cls, large_cls), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(fast_lcp, avg_lcp, slow_lcp) AND + IS_NON_ZERO(fast_fid, avg_fid, slow_fid) AND + IS_NON_ZERO(small_cls, medium_cls, large_cls), origin, NULL))) AS pct_good_cwv +FROM + `chrome-ux-report.materialized.metrics_summary` +WHERE + date = '2020-06-01' \ No newline at end of file From aff681b4abe38a45f7546693316b43dc4b120813 Mon Sep 17 00:00:00 2001 From: Max Ostapenko Date: Fri, 24 Jul 2020 23:54:55 +0100 Subject: [PATCH 09/39] cwv per device, ect and country --- .../core_web_vitals_per_country.sql | 109 ++++++++ .../core_web_vitals_per_device.sql | 110 ++++++++ .../core_web_vitals_per_ect.sql | 234 ++++++++++++++++++ .../09_Performance/web_vitals_per_device.sql | 202 --------------- 4 files changed, 453 insertions(+), 202 deletions(-) create mode 100644 sql/2020/09_Performance/core_web_vitals_per_country.sql create mode 100644 sql/2020/09_Performance/core_web_vitals_per_device.sql create mode 100644 sql/2020/09_Performance/core_web_vitals_per_ect.sql delete mode 100644 sql/2020/09_Performance/web_vitals_per_device.sql diff --git a/sql/2020/09_Performance/core_web_vitals_per_country.sql b/sql/2020/09_Performance/core_web_vitals_per_country.sql new file mode 100644 index 00000000000..a22d68c36d5 --- /dev/null +++ b/sql/2020/09_Performance/core_web_vitals_per_country.sql @@ -0,0 +1,109 @@ +#standardSQL +# Core WebVitals per country + +CREATE TEMP FUNCTION IS_GOOD (good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS ( + good / (good + needs_improvement + poor) >= 0.75 +); + +CREATE TEMP FUNCTION IS_NI (good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS ( + good / (good + needs_improvement + poor) < 0.75 + AND poor / (good + needs_improvement + poor) < 0.25 +); + +CREATE TEMP FUNCTION IS_POOR (good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS ( + poor / (good + needs_improvement + poor) >= 0.25 +); + +CREATE TEMP FUNCTION IS_NON_ZERO (good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS ( + good + needs_improvement + poor > 0 +); + +WITH + base AS ( + SELECT +  origin, + country_code, + + fast_fid, + avg_fid, + slow_fid, + + fast_lcp, + avg_lcp, + slow_lcp, + + small_cls, + medium_cls, + large_cls + FROM + `chrome-ux-report.materialized.country_summary` + WHERE + yyyymm = 202006 + ) + +SELECT +  country_code, + + COUNT(DISTINCT origin) AS total_origins, + + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_GOOD(fast_fid, avg_fid, slow_fid) AND + IS_GOOD(fast_lcp, avg_lcp, slow_lcp) AND + IS_GOOD(small_cls, medium_cls, large_cls), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(fast_fid, avg_fid, slow_fid) AND + IS_NON_ZERO(fast_lcp, avg_lcp, slow_lcp) AND + IS_NON_ZERO(small_cls, medium_cls, large_cls), origin, NULL))) AS pct_cwv_good, + + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_GOOD(fast_lcp, avg_lcp, slow_lcp), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(fast_lcp, avg_lcp, slow_lcp), origin, NULL))) AS pct_lcp_good, + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_NI(fast_lcp, avg_lcp, slow_lcp), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(fast_lcp, avg_lcp, slow_lcp), origin, NULL))) AS pct_lcp_ni, + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_POOR(fast_lcp, avg_lcp, slow_lcp), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(fast_lcp, avg_lcp, slow_lcp), origin, NULL))) AS pct_lcp_poor, + + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_GOOD(fast_fid, avg_fid, slow_fid), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(fast_fid, avg_fid, slow_fid), origin, NULL))) AS pct_fid_good, + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_NI(fast_fid, avg_fid, slow_fid), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(fast_fid, avg_fid, slow_fid), origin, NULL))) AS pct_fid_ni, + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_POOR(fast_fid, avg_fid, slow_fid), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(fast_fid, avg_fid, slow_fid), origin, NULL))) AS pct_fid_poor, + + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_GOOD(small_cls, medium_cls, large_cls), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(small_cls, medium_cls, large_cls), origin, NULL))) AS pct_cls_good, + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_NI(small_cls, medium_cls, large_cls), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(small_cls, medium_cls, large_cls), origin, NULL))) AS pct_cls_ni, + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_POOR(small_cls, medium_cls, large_cls), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(small_cls, medium_cls, large_cls), origin, NULL))) AS pct_cls_poor, +FROM + base +GROUP BY +  country_code \ No newline at end of file diff --git a/sql/2020/09_Performance/core_web_vitals_per_device.sql b/sql/2020/09_Performance/core_web_vitals_per_device.sql new file mode 100644 index 00000000000..95054553873 --- /dev/null +++ b/sql/2020/09_Performance/core_web_vitals_per_device.sql @@ -0,0 +1,110 @@ +#standardSQL +# Core WebVitals per device + +CREATE TEMP FUNCTION IS_GOOD (good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS ( + good / (good + needs_improvement + poor) >= 0.75 +); + +CREATE TEMP FUNCTION IS_NI (good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS ( + good / (good + needs_improvement + poor) < 0.75 + AND poor / (good + needs_improvement + poor) < 0.25 +); + +CREATE TEMP FUNCTION IS_POOR (good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS ( + poor / (good + needs_improvement + poor) >= 0.25 +); + +CREATE TEMP FUNCTION IS_NON_ZERO (good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS ( + good + needs_improvement + poor > 0 +); + +WITH + base AS ( + SELECT +  origin, + device, + + fast_fid, + avg_fid, + slow_fid, + + fast_lcp, + avg_lcp, + slow_lcp, + + small_cls, + medium_cls, + large_cls + FROM + `chrome-ux-report.materialized.device_summary` + WHERE + device in ('desktop','phone') + AND date = date('2020-06-01') + ) + +SELECT +  device, + + COUNT(DISTINCT origin) AS total_origins, + + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_GOOD(fast_fid, avg_fid, slow_fid) AND + IS_GOOD(fast_lcp, avg_lcp, slow_lcp) AND + IS_GOOD(small_cls, medium_cls, large_cls), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(fast_fid, avg_fid, slow_fid) AND + IS_NON_ZERO(fast_lcp, avg_lcp, slow_lcp) AND + IS_NON_ZERO(small_cls, medium_cls, large_cls), origin, NULL))) AS pct_cwv_good, + + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_GOOD(fast_lcp, avg_lcp, slow_lcp), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(fast_lcp, avg_lcp, slow_lcp), origin, NULL))) AS pct_lcp_good, + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_NI(fast_lcp, avg_lcp, slow_lcp), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(fast_lcp, avg_lcp, slow_lcp), origin, NULL))) AS pct_lcp_ni, + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_POOR(fast_lcp, avg_lcp, slow_lcp), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(fast_lcp, avg_lcp, slow_lcp), origin, NULL))) AS pct_lcp_poor, + + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_GOOD(fast_fid, avg_fid, slow_fid), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(fast_fid, avg_fid, slow_fid), origin, NULL))) AS pct_fid_good, + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_NI(fast_fid, avg_fid, slow_fid), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(fast_fid, avg_fid, slow_fid), origin, NULL))) AS pct_fid_ni, + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_POOR(fast_fid, avg_fid, slow_fid), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(fast_fid, avg_fid, slow_fid), origin, NULL))) AS pct_fid_poor, + + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_GOOD(small_cls, medium_cls, large_cls), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(small_cls, medium_cls, large_cls), origin, NULL))) AS pct_cls_good, + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_NI(small_cls, medium_cls, large_cls), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(small_cls, medium_cls, large_cls), origin, NULL))) AS pct_cls_ni, + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_POOR(small_cls, medium_cls, large_cls), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(small_cls, medium_cls, large_cls), origin, NULL))) AS pct_cls_poor, +FROM + base +GROUP BY +  device \ No newline at end of file diff --git a/sql/2020/09_Performance/core_web_vitals_per_ect.sql b/sql/2020/09_Performance/core_web_vitals_per_ect.sql new file mode 100644 index 00000000000..c1850b7e85c --- /dev/null +++ b/sql/2020/09_Performance/core_web_vitals_per_ect.sql @@ -0,0 +1,234 @@ +#standardSQL +# Core WebVitals per effective connection type + +CREATE TEMP FUNCTION IS_GOOD (good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS ( + good / (good + needs_improvement + poor) >= 0.75 +); + +CREATE TEMP FUNCTION IS_NI (good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS ( + good / (good + needs_improvement + poor) < 0.75 + AND poor / (good + needs_improvement + poor) < 0.25 +); + +CREATE TEMP FUNCTION IS_POOR (good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS ( + poor / (good + needs_improvement + poor) >= 0.25 +); + +CREATE TEMP FUNCTION IS_NON_ZERO (good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS ( + good + needs_improvement + poor > 0 +); + +WITH + base AS ( + SELECT + yyyymm, +  origin, + 'all' AS country_code, + 'all' AS device, + effective_connection_type.name AS network, + layout_instability, + largest_contentful_paint, + first_input + FROM + `chrome-ux-report.experimental.country` + WHERE + form_factor.name in ('desktop','phone') + AND yyyymm = 202006 + ), + dimensions AS ( + SELECT + yyyymm, + country_code, + origin, + device, + network + FROM + base + GROUP BY + yyyymm, + country_code, + origin, + device, + network + ), + cls AS ( + SELECT + yyyymm, + country_code, + origin, + device, + network, + SUM(IF(bin.start < 0.1, bin.density, 0)) AS small, + SUM(IF(bin.start > 0.1 AND bin.start < 0.25, bin.density, 0)) AS medium, + SUM(IF(bin.start >= 0.25, bin.density, 0)) AS large, + `chrome-ux-report`.experimental.PERCENTILE_NUMERIC(ARRAY_AGG(bin), 75) AS p75 + FROM + base + LEFT JOIN + UNNEST(layout_instability.cumulative_layout_shift.histogram.bin) AS bin + WHERE + bin IS NOT NULL + GROUP BY + yyyymm, + country_code, + origin, + device, + network + ), + lcp AS ( + SELECT + yyyymm, + country_code, + origin, + device, + network, + SUM(IF(bin.start < 2500, bin.density, 0)) AS fast, + SUM(IF(bin.start >= 2500 AND bin.start < 4000, bin.density, 0)) AS avg, + SUM(IF(bin.start >= 4000, bin.density, 0)) AS slow, + `chrome-ux-report`.experimental.PERCENTILE(ARRAY_AGG(bin), 75) AS p75 + FROM + base + LEFT JOIN + UNNEST(largest_contentful_paint.histogram.bin) AS bin + WHERE + bin IS NOT NULL + GROUP BY + yyyymm, + country_code, + origin, + device, + network + ), + fid AS ( + SELECT + yyyymm, + country_code, + origin, + device, + network, + SUM(IF(bin.start < 100, bin.density, 0)) AS fast, + SUM(IF(bin.start >= 100 AND bin.start < 300, bin.density, 0)) AS avg, + SUM(IF(bin.start >= 300, bin.density, 0)) AS slow, + `chrome-ux-report`.experimental.PERCENTILE(ARRAY_AGG(bin), 75) AS p75 + FROM + base + LEFT JOIN + UNNEST(first_input.delay.histogram.bin) AS bin + WHERE + bin IS NOT NULL + GROUP BY + yyyymm, + country_code, + origin, + device, + network + ), + granular_metrics AS ( + SELECT + yyyymm, + country_code, + origin, + device, + network, + cls.small AS small_cls, + cls.medium AS medium_cls, + cls.large AS large_cls, + cls.p75 AS p75_cls, + + lcp.fast AS fast_lcp, + lcp.avg AS avg_lcp, + lcp.slow AS slow_lcp, + lcp.p75 AS p75_lcp, + + fid.fast AS fast_fid, + fid.avg AS avg_fid, + fid.slow AS slow_fid, + fid.p75 AS p75_fid, + FROM + dimensions + LEFT JOIN + cls + USING + (yyyymm, country_code, origin, device, network) + LEFT JOIN + lcp + USING + (yyyymm, country_code, origin, device, network) + LEFT JOIN + fid + USING + (yyyymm, country_code, origin, device, network)) + +SELECT + yyyymm, +  country_code, +  device, + network, + + COUNT(DISTINCT origin) AS total_origins, + + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_GOOD(fast_fid, avg_fid, slow_fid) AND + IS_GOOD(fast_lcp, avg_lcp, slow_lcp) AND + IS_GOOD(small_cls, medium_cls, large_cls), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(fast_fid, avg_fid, slow_fid) AND + IS_NON_ZERO(fast_lcp, avg_lcp, slow_lcp) AND + IS_NON_ZERO(small_cls, medium_cls, large_cls), origin, NULL))) AS pct_cwv_good, + + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_GOOD(fast_lcp, avg_lcp, slow_lcp), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(fast_lcp, avg_lcp, slow_lcp), origin, NULL))) AS pct_lcp_good, + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_NI(fast_lcp, avg_lcp, slow_lcp), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(fast_lcp, avg_lcp, slow_lcp), origin, NULL))) AS pct_lcp_ni, + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_POOR(fast_lcp, avg_lcp, slow_lcp), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(fast_lcp, avg_lcp, slow_lcp), origin, NULL))) AS pct_lcp_poor, + + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_GOOD(fast_fid, avg_fid, slow_fid), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(fast_fid, avg_fid, slow_fid), origin, NULL))) AS pct_fid_good, + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_NI(fast_fid, avg_fid, slow_fid), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(fast_fid, avg_fid, slow_fid), origin, NULL))) AS pct_fid_ni, + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_POOR(fast_fid, avg_fid, slow_fid), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(fast_fid, avg_fid, slow_fid), origin, NULL))) AS pct_fid_poor, + + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_GOOD(small_cls, medium_cls, large_cls), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(small_cls, medium_cls, large_cls), origin, NULL))) AS pct_cls_good, + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_NI(small_cls, medium_cls, large_cls), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(small_cls, medium_cls, large_cls), origin, NULL))) AS pct_cls_ni, + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_POOR(small_cls, medium_cls, large_cls), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(small_cls, medium_cls, large_cls), origin, NULL))) AS pct_cls_poor, + +FROM + granular_metrics +GROUP BY + yyyymm, +  country_code, +  device, + network \ No newline at end of file diff --git a/sql/2020/09_Performance/web_vitals_per_device.sql b/sql/2020/09_Performance/web_vitals_per_device.sql deleted file mode 100644 index 4e6d7483057..00000000000 --- a/sql/2020/09_Performance/web_vitals_per_device.sql +++ /dev/null @@ -1,202 +0,0 @@ -#standardSQL -# TODO: add FCP and TTFB - -WITH - base AS ( - SELECT - # remove literals after switching to country table - 202006 AS yyyymm, -  'pt' AS country_code, -  origin, - # to exclude dimension from segmentation - #'all' AS device, - form_factor.name AS device, - effective_connection_type.name AS network, - layout_instability, - largest_contentful_paint, - first_input - FROM - # change to `chrome-ux-report.experimental.country` - `chrome-ux-report.country_zw.202006` - WHERE - form_factor.name in ('desktop','phone') - # filtered by origin for debug - #origin = "http://borwap.com" - # uncomment for country table - #yyyymm = 202006 - ), - dimensions AS ( - SELECT - yyyymm, - country_code, - origin, - device, - network - FROM - base - GROUP BY - yyyymm, - country_code, - origin, - device, - network - ), - cls AS ( - SELECT - yyyymm, - country_code, - origin, - device, - network, - ROUND(SUM(IF(bin.start < 0.1, bin.density, 0)), 4) AS small, - ROUND(SUM(IF(bin.start > 0.1 AND bin.start < 0.25, bin.density, 0)), 4) AS medium, - ROUND(SUM(IF(bin.start >= 0.25, bin.density, 0)), 4) AS large, - `chrome-ux-report`.experimental.PERCENTILE_NUMERIC(ARRAY_AGG(bin), 75) AS p75 - FROM - base - LEFT JOIN - UNNEST(layout_instability.cumulative_layout_shift.histogram.bin) AS bin - WHERE - bin IS NOT NULL - GROUP BY - yyyymm, - country_code, - origin, - device, - network - ), - lcp AS ( - SELECT - yyyymm, - country_code, - origin, - device, - network, - ROUND(SUM(IF(bin.start < 2500, bin.density, 0)), 4) AS fast, - ROUND(SUM(IF(bin.start >= 2500 AND bin.start < 4000, bin.density, 0)), 4) AS avg, - ROUND(SUM(IF(bin.start >= 4000, bin.density, 0)), 4) AS slow, - `chrome-ux-report`.experimental.PERCENTILE(ARRAY_AGG(bin), 75) AS p75 - FROM - base - LEFT JOIN - UNNEST(largest_contentful_paint.histogram.bin) AS bin - WHERE - bin IS NOT NULL - GROUP BY - yyyymm, - country_code, - origin, - device, - network - ), - fid AS ( - SELECT - yyyymm, - country_code, - origin, - device, - network, - ROUND(SUM(IF(bin.start < 100, bin.density, 0)), 4) AS fast, - ROUND(SUM(IF(bin.start >= 100 AND bin.start < 300, bin.density, 0)), 4) AS avg, - ROUND(SUM(IF(bin.start >= 300, bin.density, 0)), 4) AS slow, - `chrome-ux-report`.experimental.PERCENTILE(ARRAY_AGG(bin), 75) AS p75 - FROM - base - LEFT JOIN - UNNEST(first_input.delay.histogram.bin) AS bin - WHERE - bin IS NOT NULL - GROUP BY - yyyymm, - country_code, - origin, - device, - network - ), - granular_metrics AS ( - SELECT - yyyymm, - country_code, - origin, - device, - network, - cls.small AS small_cls, - cls.medium AS medium_cls, - cls.large AS large_cls, - cls.p75 AS p75_cls, - - lcp.fast AS fast_lcp, - lcp.avg AS avg_lcp, - lcp.slow AS slow_lcp, - lcp.p75 AS p75_lcp, - - fid.fast AS fast_fid, - fid.avg AS avg_fid, - fid.slow AS slow_fid, - fid.p75 AS p75_fid, - FROM - dimensions - LEFT JOIN - cls - USING - (yyyymm, country_code, origin, device, network) - LEFT JOIN - lcp - USING - (yyyymm, country_code, origin, device, network) - LEFT JOIN - fid - USING - (yyyymm, country_code, origin, device, network)), - adjusted_metrics AS ( - SELECT - yyyymm, - country_code, - origin, - device, - network, - SAFE_DIVIDE(fast_lcp, fast_lcp+avg_lcp+slow_lcp) AS fast_lcp_adjusted, - SAFE_DIVIDE(avg_lcp, fast_lcp+avg_lcp+slow_lcp) AS avg_lcp_adjusted, - SAFE_DIVIDE(slow_lcp, fast_lcp+avg_lcp+slow_lcp) AS slow_lcp_adjusted, - - SAFE_DIVIDE(fast_fid, fast_fid+avg_fid+slow_fid) AS fast_fid_adjusted, - SAFE_DIVIDE(avg_fid, fast_fid+avg_fid+slow_fid) AS avg_fid_adjusted, - SAFE_DIVIDE(slow_fid, fast_fid+avg_fid+slow_fid) AS slow_fid_adjusted, - - SAFE_DIVIDE(small_cls, small_cls+medium_cls+large_cls) AS small_cls_adjusted, - SAFE_DIVIDE(medium_cls, small_cls+medium_cls+large_cls) AS medium_cls_adjusted, - SAFE_DIVIDE(large_cls, small_cls+medium_cls+large_cls) AS large_cls_adjusted, - - FROM - granular_metrics) - -SELECT - yyyymm, -  country_code, -  device, - network, - COUNT(0) AS total_origins, - - ROUND(COUNTIF( fast_lcp_adjusted >= 0.75 AND fast_fid_adjusted >= 0.75 AND small_cls_adjusted >= 0.75) * 100 / COUNT(0), 2) AS pct_corewebvitals_pass, - - ROUND(COUNTIF( fast_lcp_adjusted >= 0.75) * 100 / COUNT(0), 2) AS pct_corewebvitals_lcp_good, - ROUND(COUNTIF( fast_lcp_adjusted < 0.75 AND slow_lcp_adjusted < 0.25) * 100 / COUNT(0), 2) AS pct_corewebvitals_lcp_ni, - ROUND(COUNTIF( slow_lcp_adjusted >= 0.25 OR slow_lcp_adjusted IS NULL) * 100 / COUNT(0), 2) AS pct_corewebvitals_lcp_poor, - - ROUND(COUNTIF( fast_fid_adjusted >= 0.75) * 100 / COUNT(0), 2) AS pct_corewebvitals_fid_good, - ROUND(COUNTIF( fast_fid_adjusted < 0.75 AND slow_fid_adjusted < 0.25) * 100 / COUNT(0), 2) AS pct_corewebvitals_fid_ni, - ROUND(COUNTIF( slow_fid_adjusted >= 0.25 OR slow_fid_adjusted IS NULL) * 100 / COUNT(0), 2) AS pct_corewebvitals_fid_poor, - - ROUND(COUNTIF( small_cls_adjusted >= 0.75) * 100 / COUNT(0), 2) AS pct_corewebvitals_cls_good, - ROUND(COUNTIF( small_cls_adjusted < 0.75 AND large_cls_adjusted < 0.25) * 100 / COUNT(0), 2) AS pct_corewebvitals_cls_ni, - ROUND(COUNTIF( large_cls_adjusted >= 0.25 OR large_cls_adjusted IS NULL) * 100 / COUNT(0), 2) AS pct_corewebvitals_cls_poor, - -FROM - adjusted_metrics -GROUP BY - yyyymm, -  country_code, -  device, - network -# exclude small segments -#HAVING total_origins > 1000 \ No newline at end of file From 61a109305dad6aad5da4220be8db506d8e91c725 Mon Sep 17 00:00:00 2001 From: Max Ostapenko Date: Sat, 25 Jul 2020 00:38:35 +0100 Subject: [PATCH 10/39] offline origins --- sql/2020/09_Performance/offline_origins.sql | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 sql/2020/09_Performance/offline_origins.sql diff --git a/sql/2020/09_Performance/offline_origins.sql b/sql/2020/09_Performance/offline_origins.sql new file mode 100644 index 00000000000..533208e62ff --- /dev/null +++ b/sql/2020/09_Performance/offline_origins.sql @@ -0,0 +1,10 @@ +#standardSQL +# Offline origins + +SELECT + COUNT(DISTINCT origin) AS total_origins, + COUNT(DISTINCT IF(offlineDensity > 0, origin, NULL)) offline_origins +FROM + `chrome-ux-report.materialized.metrics_summary` +WHERE + date = '2020-06-01' \ No newline at end of file From 4e6118000b4a1fe5f0edb9c7c69f650cfaf01735 Mon Sep 17 00:00:00 2001 From: Max Ostapenko Date: Sat, 25 Jul 2020 02:37:40 +0100 Subject: [PATCH 11/39] webvitals distribution by device --- ..._country.sql => web_vitals_by_country.sql} | 46 ++++- ...er_device.sql => web_vitals_by_device.sql} | 46 ++++- ...tals_per_ect.sql => web_vitals_by_ect.sql} | 153 +++++++++------ .../web_vitals_distribution_by_device.sql | 182 ++++++++++++++++++ 4 files changed, 359 insertions(+), 68 deletions(-) rename sql/2020/09_Performance/{core_web_vitals_per_country.sql => web_vitals_by_country.sql} (70%) rename sql/2020/09_Performance/{core_web_vitals_per_device.sql => web_vitals_by_device.sql} (70%) rename sql/2020/09_Performance/{core_web_vitals_per_ect.sql => web_vitals_by_ect.sql} (66%) create mode 100644 sql/2020/09_Performance/web_vitals_distribution_by_device.sql diff --git a/sql/2020/09_Performance/core_web_vitals_per_country.sql b/sql/2020/09_Performance/web_vitals_by_country.sql similarity index 70% rename from sql/2020/09_Performance/core_web_vitals_per_country.sql rename to sql/2020/09_Performance/web_vitals_by_country.sql index a22d68c36d5..35fd0bbcfbe 100644 --- a/sql/2020/09_Performance/core_web_vitals_per_country.sql +++ b/sql/2020/09_Performance/web_vitals_by_country.sql @@ -1,5 +1,5 @@ #standardSQL -# Core WebVitals per country +# Core WebVitals by country CREATE TEMP FUNCTION IS_GOOD (good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS ( good / (good + needs_improvement + poor) >= 0.75 @@ -34,7 +34,16 @@ WITH small_cls, medium_cls, - large_cls + large_cls, + + fast_fcp, + avg_fcp, + slow_fcp, + + fast_ttfb, + avg_ttfb, + slow_ttfb, + FROM `chrome-ux-report.materialized.country_summary` WHERE @@ -103,6 +112,39 @@ SELECT IS_POOR(small_cls, medium_cls, large_cls), origin, NULL)), COUNT(DISTINCT IF( IS_NON_ZERO(small_cls, medium_cls, large_cls), origin, NULL))) AS pct_cls_poor, + + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_GOOD(fast_fcp, avg_fcp, slow_fcp), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(fast_fcp, avg_fcp, slow_fcp), origin, NULL))) AS pct_fcp_good, + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_NI(fast_fcp, avg_fcp, slow_fcp), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(fast_fcp, avg_fcp, slow_fcp), origin, NULL))) AS pct_fcp_ni, + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_POOR(fast_fcp, avg_fcp, slow_fcp), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(fast_fcp, avg_fcp, slow_fcp), origin, NULL))) AS pct_fcp_poor, + + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_GOOD(fast_ttfb, avg_ttfb, slow_ttfb), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(fast_ttfb, avg_ttfb, slow_ttfb), origin, NULL))) AS pct_ttfb_good, + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_NI(fast_ttfb, avg_ttfb, slow_ttfb), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(fast_ttfb, avg_ttfb, slow_ttfb), origin, NULL))) AS pct_ttfb_ni, + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_POOR(fast_ttfb, avg_ttfb, slow_ttfb), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(fast_ttfb, avg_ttfb, slow_ttfb), origin, NULL))) AS pct_ttfb_poor, + FROM base GROUP BY diff --git a/sql/2020/09_Performance/core_web_vitals_per_device.sql b/sql/2020/09_Performance/web_vitals_by_device.sql similarity index 70% rename from sql/2020/09_Performance/core_web_vitals_per_device.sql rename to sql/2020/09_Performance/web_vitals_by_device.sql index 95054553873..d99663b4acd 100644 --- a/sql/2020/09_Performance/core_web_vitals_per_device.sql +++ b/sql/2020/09_Performance/web_vitals_by_device.sql @@ -1,5 +1,5 @@ #standardSQL -# Core WebVitals per device +# Core WebVitals by device CREATE TEMP FUNCTION IS_GOOD (good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS ( good / (good + needs_improvement + poor) >= 0.75 @@ -34,7 +34,16 @@ WITH small_cls, medium_cls, - large_cls + large_cls, + + fast_fcp, + avg_fcp, + slow_fcp, + + fast_ttfb, + avg_ttfb, + slow_ttfb + FROM `chrome-ux-report.materialized.device_summary` WHERE @@ -104,6 +113,39 @@ SELECT IS_POOR(small_cls, medium_cls, large_cls), origin, NULL)), COUNT(DISTINCT IF( IS_NON_ZERO(small_cls, medium_cls, large_cls), origin, NULL))) AS pct_cls_poor, + + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_GOOD(fast_fcp, avg_fcp, slow_fcp), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(fast_fcp, avg_fcp, slow_fcp), origin, NULL))) AS pct_fcp_good, + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_NI(fast_fcp, avg_fcp, slow_fcp), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(fast_fcp, avg_fcp, slow_fcp), origin, NULL))) AS pct_fcp_ni, + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_POOR(fast_fcp, avg_fcp, slow_fcp), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(fast_fcp, avg_fcp, slow_fcp), origin, NULL))) AS pct_fcp_poor, + + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_GOOD(fast_ttfb, avg_ttfb, slow_ttfb), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(fast_ttfb, avg_ttfb, slow_ttfb), origin, NULL))) AS pct_ttfb_good, + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_NI(fast_ttfb, avg_ttfb, slow_ttfb), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(fast_ttfb, avg_ttfb, slow_ttfb), origin, NULL))) AS pct_ttfb_ni, + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_POOR(fast_ttfb, avg_ttfb, slow_ttfb), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(fast_ttfb, avg_ttfb, slow_ttfb), origin, NULL))) AS pct_ttfb_poor, + FROM base GROUP BY diff --git a/sql/2020/09_Performance/core_web_vitals_per_ect.sql b/sql/2020/09_Performance/web_vitals_by_ect.sql similarity index 66% rename from sql/2020/09_Performance/core_web_vitals_per_ect.sql rename to sql/2020/09_Performance/web_vitals_by_ect.sql index c1850b7e85c..baff3c9d073 100644 --- a/sql/2020/09_Performance/core_web_vitals_per_ect.sql +++ b/sql/2020/09_Performance/web_vitals_by_ect.sql @@ -1,5 +1,5 @@ #standardSQL -# Core WebVitals per effective connection type +# WebVitals by effective connection type CREATE TEMP FUNCTION IS_GOOD (good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS ( good / (good + needs_improvement + poor) >= 0.75 @@ -21,42 +21,19 @@ CREATE TEMP FUNCTION IS_NON_ZERO (good FLOAT64, needs_improvement FLOAT64, poor WITH base AS ( SELECT - yyyymm,   origin, - 'all' AS country_code, - 'all' AS device, effective_connection_type.name AS network, layout_instability, largest_contentful_paint, - first_input + first_input, + first_contentful_paint, + experimental.time_to_first_byte AS time_to_first_byte FROM - `chrome-ux-report.experimental.country` - WHERE - form_factor.name in ('desktop','phone') - AND yyyymm = 202006 - ), - dimensions AS ( - SELECT - yyyymm, - country_code, - origin, - device, - network - FROM - base - GROUP BY - yyyymm, - country_code, - origin, - device, - network + `chrome-ux-report.all.202006` ), cls AS ( SELECT - yyyymm, - country_code, origin, - device, network, SUM(IF(bin.start < 0.1, bin.density, 0)) AS small, SUM(IF(bin.start > 0.1 AND bin.start < 0.25, bin.density, 0)) AS medium, @@ -66,21 +43,13 @@ WITH base LEFT JOIN UNNEST(layout_instability.cumulative_layout_shift.histogram.bin) AS bin - WHERE - bin IS NOT NULL GROUP BY - yyyymm, - country_code, origin, - device, network ), lcp AS ( SELECT - yyyymm, - country_code, origin, - device, network, SUM(IF(bin.start < 2500, bin.density, 0)) AS fast, SUM(IF(bin.start >= 2500 AND bin.start < 4000, bin.density, 0)) AS avg, @@ -90,21 +59,13 @@ WITH base LEFT JOIN UNNEST(largest_contentful_paint.histogram.bin) AS bin - WHERE - bin IS NOT NULL GROUP BY - yyyymm, - country_code, origin, - device, network ), fid AS ( SELECT - yyyymm, - country_code, origin, - device, network, SUM(IF(bin.start < 100, bin.density, 0)) AS fast, SUM(IF(bin.start >= 100 AND bin.start < 300, bin.density, 0)) AS avg, @@ -114,21 +75,45 @@ WITH base LEFT JOIN UNNEST(first_input.delay.histogram.bin) AS bin - WHERE - bin IS NOT NULL GROUP BY - yyyymm, - country_code, origin, - device, + network + ), + fcp AS ( + SELECT + origin, + network, +   SUM(IF(bin.start < 1500, bin.density, 0)) AS fast, +   SUM(IF(bin.start >= 1500 AND bin.start < 2500, bin.density, 0)) AS avg, +   SUM(IF(bin.start >= 2500, bin.density, 0)) AS slow, + `chrome-ux-report`.experimental.PERCENTILE(ARRAY_AGG(bin), 75) AS p75 + FROM +   base + LEFT JOIN +   UNNEST(first_contentful_paint.histogram.bin) AS bin + GROUP BY + origin, + network + ), + ttfb AS ( + SELECT + origin, + network, +   SUM(IF(bin.start < 500, bin.density, 0)) AS fast, +   SUM(IF(bin.start >= 500 AND bin.start < 1500, bin.density, 0)) AS avg, +   SUM(IF(bin.start >= 1500, bin.density, 0)) AS slow, + `chrome-ux-report`.experimental.PERCENTILE(ARRAY_AGG(bin), 75) AS p75 + FROM + base + LEFT JOIN +   UNNEST(time_to_first_byte.histogram.bin) AS bin + GROUP BY + origin, network ), granular_metrics AS ( SELECT - yyyymm, - country_code, origin, - device, network, cls.small AS small_cls, cls.medium AS medium_cls, @@ -144,25 +129,36 @@ WITH fid.avg AS avg_fid, fid.slow AS slow_fid, fid.p75 AS p75_fid, + + fcp.fast AS fast_fcp, + fcp.avg AS avg_fcp, + fcp.slow AS slow_fcp, + fcp.p75 AS p75_fcp, + + ttfb.fast AS fast_ttfb, + ttfb.avg AS avg_ttfb, + ttfb.slow AS slow_ttfb, + ttfb.p75 AS p75_ttfb, FROM - dimensions - LEFT JOIN cls - USING - (yyyymm, country_code, origin, device, network) LEFT JOIN lcp USING - (yyyymm, country_code, origin, device, network) + (origin, network) LEFT JOIN fid USING - (yyyymm, country_code, origin, device, network)) + (origin, network) + LEFT JOIN + fcp + USING + (origin, network) + LEFT JOIN + ttfb + USING + (origin, network)) SELECT - yyyymm, -  country_code, -  device, network, COUNT(DISTINCT origin) AS total_origins, @@ -225,10 +221,39 @@ SELECT COUNT(DISTINCT IF( IS_NON_ZERO(small_cls, medium_cls, large_cls), origin, NULL))) AS pct_cls_poor, + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_GOOD(fast_fcp, avg_fcp, slow_fcp), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(fast_fcp, avg_fcp, slow_fcp), origin, NULL))) AS pct_fcp_good, + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_NI(fast_fcp, avg_fcp, slow_fcp), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(fast_fcp, avg_fcp, slow_fcp), origin, NULL))) AS pct_fcp_ni, + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_POOR(fast_fcp, avg_fcp, slow_fcp), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(fast_fcp, avg_fcp, slow_fcp), origin, NULL))) AS pct_fcp_poor, + + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_GOOD(fast_ttfb, avg_ttfb, slow_ttfb), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(fast_ttfb, avg_ttfb, slow_ttfb), origin, NULL))) AS pct_ttfb_good, + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_NI(fast_ttfb, avg_ttfb, slow_ttfb), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(fast_ttfb, avg_ttfb, slow_ttfb), origin, NULL))) AS pct_ttfb_ni, + SAFE_DIVIDE( + COUNT(DISTINCT IF( + IS_POOR(fast_ttfb, avg_ttfb, slow_ttfb), origin, NULL)), + COUNT(DISTINCT IF( + IS_NON_ZERO(fast_ttfb, avg_ttfb, slow_ttfb), origin, NULL))) AS pct_ttfb_poor, + FROM granular_metrics GROUP BY - yyyymm, -  country_code, -  device, network \ No newline at end of file diff --git a/sql/2020/09_Performance/web_vitals_distribution_by_device.sql b/sql/2020/09_Performance/web_vitals_distribution_by_device.sql new file mode 100644 index 00000000000..b1236c3cd1a --- /dev/null +++ b/sql/2020/09_Performance/web_vitals_distribution_by_device.sql @@ -0,0 +1,182 @@ +#standardSQL +# WebVitals distribution by device + +WITH + base AS ( + SELECT + device, + + fast_fid, + avg_fid, + slow_fid, + + fast_lcp, + avg_lcp, + slow_lcp, + + small_cls, + medium_cls, + large_cls, + + fast_fcp, + avg_fcp, + slow_fcp, + + fast_ttfb, + avg_ttfb, + slow_ttfb, + + FROM + `chrome-ux-report.materialized.device_summary` + WHERE + device in ('desktop','phone') + AND date = date('2020-06-01') + ), +fid AS ( + SELECT + device, + fast_fid, + avg_fid, + slow_fid, + ROW_NUMBER() OVER (PARTITION BY device ORDER BY fast_fid DESC) AS row, + FROM ( + SELECT + device, + SAFE_DIVIDE(fast_fid, fast_fid + avg_fid + slow_fid) AS fast_fid, + SAFE_DIVIDE(avg_fid, fast_fid + avg_fid + slow_fid) AS avg_fid, + SAFE_DIVIDE(slow_fid, fast_fid + avg_fid + slow_fid) AS slow_fid, + ROW_NUMBER() OVER (PARTITION BY device ORDER BY fast_fid DESC) AS row, + COUNT(0) OVER (PARTITION BY device) AS n, + FROM + base + WHERE + fast_fid + avg_fid + slow_fid > 0) + WHERE + MOD(row, CAST(FLOOR(n / 1000) AS INT64)) = 0 +), +lcp AS ( + SELECT + device, + fast_lcp, + avg_lcp, + slow_lcp, + ROW_NUMBER() OVER (PARTITION BY device ORDER BY fast_lcp DESC) AS row, + FROM ( + SELECT + device, + SAFE_DIVIDE(fast_lcp, fast_lcp + avg_lcp + slow_lcp) AS fast_lcp, + SAFE_DIVIDE(avg_lcp, fast_lcp + avg_lcp + slow_lcp) AS avg_lcp, + SAFE_DIVIDE(slow_lcp, fast_lcp + avg_lcp + slow_lcp) AS slow_lcp, + ROW_NUMBER() OVER (PARTITION BY device ORDER BY fast_lcp DESC) AS row, + COUNT(0) OVER (PARTITION BY device) AS n, + FROM + base + WHERE + fast_lcp + avg_lcp + slow_lcp > 0) + WHERE + MOD(row, CAST(FLOOR(n / 1000) AS INT64)) = 0 +), +cls AS ( + SELECT + device, + small_cls, + medium_cls, + large_cls, + ROW_NUMBER() OVER (PARTITION BY device ORDER BY small_cls DESC) AS row, + FROM ( + SELECT + device, + SAFE_DIVIDE(small_cls, small_cls + medium_cls + large_cls) AS small_cls, + SAFE_DIVIDE(medium_cls, small_cls + medium_cls + large_cls) AS medium_cls, + SAFE_DIVIDE(large_cls, small_cls + medium_cls + large_cls) AS large_cls, + ROW_NUMBER() OVER (PARTITION BY device ORDER BY small_cls DESC) AS row, + COUNT(0) OVER (PARTITION BY device) AS n, + FROM + base + WHERE + small_cls + medium_cls + large_cls > 0) + WHERE + MOD(row, CAST(FLOOR(n / 1000) AS INT64)) = 0 +), +fcp AS ( + SELECT + device, + fast_fcp, + avg_fcp, + slow_fcp, + ROW_NUMBER() OVER (PARTITION BY device ORDER BY fast_fcp DESC) AS row, + FROM ( + SELECT + device, + SAFE_DIVIDE(fast_fcp, fast_fcp + avg_fcp + slow_fcp) AS fast_fcp, + SAFE_DIVIDE(avg_fcp, fast_fcp + avg_fcp + slow_fcp) AS avg_fcp, + SAFE_DIVIDE(slow_fcp, fast_fcp + avg_fcp + slow_fcp) AS slow_fcp, + ROW_NUMBER() OVER (PARTITION BY device ORDER BY fast_fcp DESC) AS row, + COUNT(0) OVER (PARTITION BY device) AS n, + FROM + base + WHERE + fast_fcp + avg_fcp + slow_fcp > 0) + WHERE + MOD(row, CAST(FLOOR(n / 1000) AS INT64)) = 0 +), +ttfb AS ( + SELECT + device, + fast_ttfb, + avg_ttfb, + slow_ttfb, + ROW_NUMBER() OVER (PARTITION BY device ORDER BY fast_ttfb DESC) AS row, + FROM ( + SELECT + device, + SAFE_DIVIDE(fast_ttfb, fast_ttfb + avg_ttfb + slow_ttfb) AS fast_ttfb, + SAFE_DIVIDE(avg_ttfb, fast_ttfb + avg_ttfb + slow_ttfb) AS avg_ttfb, + SAFE_DIVIDE(slow_ttfb, fast_ttfb + avg_ttfb + slow_ttfb) AS slow_ttfb, + ROW_NUMBER() OVER (PARTITION BY device ORDER BY fast_ttfb DESC) AS row, + COUNT(0) OVER (PARTITION BY device) AS n, + FROM + base + WHERE + fast_ttfb + avg_ttfb + slow_ttfb > 0) + WHERE + MOD(row, CAST(FLOOR(n / 1000) AS INT64)) = 0 +) + +SELECT + row, + device, + + fast_fid, + avg_fid, + slow_fid, + + small_cls, + medium_cls, + large_cls, + + fast_lcp, + avg_lcp, + slow_lcp, + + fast_fcp, + avg_fcp, + slow_fcp, + + fast_ttfb, + avg_ttfb, + slow_ttfb, +FROM + fid +FULL JOIN + lcp +USING (row, device) +FULL JOIN + cls +USING (row, device) +FULL JOIN + fcp +USING (row, device) +FULL JOIN + ttfb +USING (row, device) \ No newline at end of file From d46e1b5fdb23250b4fd442a55104967511a007bb Mon Sep 17 00:00:00 2001 From: Max Ostapenko Date: Sat, 25 Jul 2020 03:50:34 +0100 Subject: [PATCH 12/39] lcp score by month --- .../09_Performance/lcp_score_by_month.sql | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 sql/2020/09_Performance/lcp_score_by_month.sql diff --git a/sql/2020/09_Performance/lcp_score_by_month.sql b/sql/2020/09_Performance/lcp_score_by_month.sql new file mode 100644 index 00000000000..43052ca2758 --- /dev/null +++ b/sql/2020/09_Performance/lcp_score_by_month.sql @@ -0,0 +1,28 @@ +#standardSQL + # Largest contentful paint score thresholds by month + +SELECT + * +FROM ( + SELECT + date, + device, + ROW_NUMBER() OVER (PARTITION BY date, device ORDER BY lcp_value ASC) AS percentile, + lcp_value + FROM ( + SELECT + DATE("2020-06-01") AS date, + "desktop" AS device, + APPROX_QUANTILES(CAST(JSON_EXTRACT_SCALAR(payload, "$['_chromeUserTiming.LargestContentfulPaint']") AS NUMERIC), 100) AS lcp, + FROM + `httparchive.pages.2020_06_01_desktop` + UNION ALL + SELECT + DATE("2020-06-01") AS date, + "mobile" AS device, + APPROX_QUANTILES(CAST(JSON_EXTRACT_SCALAR(payload, "$['_chromeUserTiming.LargestContentfulPaint']") AS NUMERIC), 100) AS lcp, + FROM + `httparchive.pages.2020_06_01_mobile`), + UNNEST(lcp) lcp_value) +WHERE + percentile IN (5, 25) \ No newline at end of file From 8e138855368434a7a612cbce14aef5fd9cd3ac53 Mon Sep 17 00:00:00 2001 From: "dooman87@gmail.com" Date: Sun, 26 Jul 2020 06:26:37 +1000 Subject: [PATCH 13/39] Removed unused query --- .../web_vitals_suggested_by_rick.sql | 39 ------------------- 1 file changed, 39 deletions(-) delete mode 100644 sql/2020/09_Performance/web_vitals_suggested_by_rick.sql diff --git a/sql/2020/09_Performance/web_vitals_suggested_by_rick.sql b/sql/2020/09_Performance/web_vitals_suggested_by_rick.sql deleted file mode 100644 index 12e1bad773b..00000000000 --- a/sql/2020/09_Performance/web_vitals_suggested_by_rick.sql +++ /dev/null @@ -1,39 +0,0 @@ -CREATE TEMP FUNCTION IS_GOOD (good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS ( - good / (good + needs_improvement + poor) >= 0.75 -); - -CREATE TEMP FUNCTION IS_NON_ZERO (good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS ( - good + needs_improvement + poor > 0 -); - - -SELECT - # Origins with good LCP divided by origins with any LCP. - SAFE_DIVIDE( - COUNT(DISTINCT IF(IS_GOOD(fast_lcp, avg_lcp, slow_lcp), origin, NULL)), - COUNT(DISTINCT IF(IS_NON_ZERO(fast_lcp, avg_lcp, slow_lcp), origin, NULL))) AS pct_good_lcp, - - # Origins with good FID divided by origins with any FID. - SAFE_DIVIDE( - COUNT(DISTINCT IF(IS_GOOD(fast_fid, avg_fid, slow_fid), origin, NULL)), - COUNT(DISTINCT IF(IS_NON_ZERO(fast_fid, avg_fid, slow_fid), origin, NULL))) AS pct_good_fid, - - # Origins with good CLS divided by origins with any CLS. - SAFE_DIVIDE( - COUNT(DISTINCT IF(IS_GOOD(small_cls, medium_cls, large_cls), origin, NULL)), - COUNT(DISTINCT IF(IS_NON_ZERO(small_cls, medium_cls, large_cls), origin, NULL))) AS pct_good_cls, - - # Origins with good LCP, FID, and CLS dividied by origins with any LCP, FID, and CLS. - SAFE_DIVIDE( - COUNT(DISTINCT IF( - IS_GOOD(fast_lcp, avg_lcp, slow_lcp) AND - IS_GOOD(fast_fid, avg_fid, slow_fid) AND - IS_GOOD(small_cls, medium_cls, large_cls), origin, NULL)), - COUNT(DISTINCT IF( - IS_NON_ZERO(fast_lcp, avg_lcp, slow_lcp) AND - IS_NON_ZERO(fast_fid, avg_fid, slow_fid) AND - IS_NON_ZERO(small_cls, medium_cls, large_cls), origin, NULL))) AS pct_good_cwv -FROM - `chrome-ux-report.materialized.metrics_summary` -WHERE - date = '2020-06-01' \ No newline at end of file From 32e6a429e26c90bdff82dac31e30898361ada486 Mon Sep 17 00:00:00 2001 From: Max Ostapenko Date: Mon, 27 Jul 2020 00:02:05 +0100 Subject: [PATCH 14/39] review updates --- .../09_Performance/lcp_score_by_month.sql | 34 ++++++--------- sql/2020/09_Performance/offline_origins.sql | 20 ++++++--- .../09_Performance/web_vitals_by_country.sql | 43 ++++++++++--------- .../09_Performance/web_vitals_by_device.sql | 4 +- .../web_vitals_distribution_by_device.sql | 4 +- 5 files changed, 54 insertions(+), 51 deletions(-) diff --git a/sql/2020/09_Performance/lcp_score_by_month.sql b/sql/2020/09_Performance/lcp_score_by_month.sql index 43052ca2758..b8b15e15718 100644 --- a/sql/2020/09_Performance/lcp_score_by_month.sql +++ b/sql/2020/09_Performance/lcp_score_by_month.sql @@ -2,27 +2,21 @@ # Largest contentful paint score thresholds by month SELECT - * + date, + device, + median_p75_lcp FROM ( SELECT date, device, - ROW_NUMBER() OVER (PARTITION BY date, device ORDER BY lcp_value ASC) AS percentile, - lcp_value - FROM ( - SELECT - DATE("2020-06-01") AS date, - "desktop" AS device, - APPROX_QUANTILES(CAST(JSON_EXTRACT_SCALAR(payload, "$['_chromeUserTiming.LargestContentfulPaint']") AS NUMERIC), 100) AS lcp, - FROM - `httparchive.pages.2020_06_01_desktop` - UNION ALL - SELECT - DATE("2020-06-01") AS date, - "mobile" AS device, - APPROX_QUANTILES(CAST(JSON_EXTRACT_SCALAR(payload, "$['_chromeUserTiming.LargestContentfulPaint']") AS NUMERIC), 100) AS lcp, - FROM - `httparchive.pages.2020_06_01_mobile`), - UNNEST(lcp) lcp_value) -WHERE - percentile IN (5, 25) \ No newline at end of file + PERCENTILE_CONT(p75_lcp, 0.5) OVER(PARTITION BY date, device) AS median_p75_lcp + FROM + `chrome-ux-report.materialized.device_summary` + WHERE + date >= "2019-07-01" + AND device IN ('desktop','phone') +) +GROUP BY + date, + device, + median_p75_lcp \ No newline at end of file diff --git a/sql/2020/09_Performance/offline_origins.sql b/sql/2020/09_Performance/offline_origins.sql index 533208e62ff..81cf6eb0024 100644 --- a/sql/2020/09_Performance/offline_origins.sql +++ b/sql/2020/09_Performance/offline_origins.sql @@ -1,10 +1,16 @@ #standardSQL # Offline origins -SELECT - COUNT(DISTINCT origin) AS total_origins, - COUNT(DISTINCT IF(offlineDensity > 0, origin, NULL)) offline_origins -FROM - `chrome-ux-report.materialized.metrics_summary` -WHERE - date = '2020-06-01' \ No newline at end of file +SELECT + total_origins, + offline_origins, + offline_origins/total_origins AS pct_offline_origins +FROM ( + SELECT + COUNT(DISTINCT origin) AS total_origins, + COUNT(DISTINCT IF(offlineDensity > 0, origin, NULL)) AS offline_origins, + FROM + `chrome-ux-report.materialized.metrics_summary` + WHERE + date = '2020-06-01' +) \ No newline at end of file diff --git a/sql/2020/09_Performance/web_vitals_by_country.sql b/sql/2020/09_Performance/web_vitals_by_country.sql index 35fd0bbcfbe..71139f20ff0 100644 --- a/sql/2020/09_Performance/web_vitals_by_country.sql +++ b/sql/2020/09_Performance/web_vitals_by_country.sql @@ -5,15 +5,15 @@ CREATE TEMP FUNCTION IS_GOOD (good FLOAT64, needs_improvement FLOAT64, poor FLOA good / (good + needs_improvement + poor) >= 0.75 ); -CREATE TEMP FUNCTION IS_NI (good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS ( - good / (good + needs_improvement + poor) < 0.75 - AND poor / (good + needs_improvement + poor) < 0.25 -); - CREATE TEMP FUNCTION IS_POOR (good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS ( poor / (good + needs_improvement + poor) >= 0.25 ); +CREATE TEMP FUNCTION IS_NI (good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS ( + NOT IS_GOOD(good, needs_improvement, poor) + AND NOT IS_POOR(good, needs_improvement, poor) +); + CREATE TEMP FUNCTION IS_NON_ZERO (good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS ( good + needs_improvement + poor > 0 ); @@ -24,30 +24,33 @@ WITH   origin, country_code, - fast_fid, - avg_fid, - slow_fid, + SUM(fast_fid) / SUM(fast_fid + avg_fid + slow_fid) AS fast_fid, + SUM(avg_fid) / SUM(fast_fid + avg_fid + slow_fid) AS avg_fid, + SUM(slow_fid) / SUM(fast_fid + avg_fid + slow_fid) AS slow_fid, - fast_lcp, - avg_lcp, - slow_lcp, + SUM(fast_lcp) / SUM(fast_lcp + avg_lcp + slow_lcp) AS fast_lcp, + SUM(avg_lcp) / SUM(fast_lcp + avg_lcp + slow_lcp) AS avg_lcp, + SUM(slow_lcp) / SUM(fast_lcp + avg_lcp + slow_lcp) AS slow_lcp, - small_cls, - medium_cls, - large_cls, + SUM(small_cls) / SUM(small_cls + medium_cls + large_cls) AS small_cls, + SUM(medium_cls) / SUM(small_cls + medium_cls + large_cls) AS medium_cls, + SUM(large_cls) / SUM(small_cls + medium_cls + large_cls) AS large_cls, - fast_fcp, - avg_fcp, - slow_fcp, + SUM(fast_fcp) / SUM(fast_fcp + avg_fcp + slow_fcp) AS fast_fcp, + SUM(avg_fcp) / SUM(fast_fcp + avg_fcp + slow_fcp) AS avg_fcp, + SUM(slow_fcp) / SUM(fast_fcp + avg_fcp + slow_fcp) AS slow_fcp, - fast_ttfb, - avg_ttfb, - slow_ttfb, + SUM(fast_ttfb) / SUM(fast_ttfb + avg_ttfb + slow_ttfb) AS fast_ttfb, + SUM(avg_ttfb) / SUM(fast_ttfb + avg_ttfb + slow_ttfb) AS avg_ttfb, + SUM(slow_ttfb) / SUM(fast_ttfb + avg_ttfb + slow_ttfb) AS slow_ttfb, FROM `chrome-ux-report.materialized.country_summary` WHERE yyyymm = 202006 + GROUP BY + origin, + country_code ) SELECT diff --git a/sql/2020/09_Performance/web_vitals_by_device.sql b/sql/2020/09_Performance/web_vitals_by_device.sql index d99663b4acd..5105d855f09 100644 --- a/sql/2020/09_Performance/web_vitals_by_device.sql +++ b/sql/2020/09_Performance/web_vitals_by_device.sql @@ -47,8 +47,8 @@ WITH FROM `chrome-ux-report.materialized.device_summary` WHERE - device in ('desktop','phone') - AND date = date('2020-06-01') + device IN ('desktop','phone') + AND date = '2020-06-01' ) SELECT diff --git a/sql/2020/09_Performance/web_vitals_distribution_by_device.sql b/sql/2020/09_Performance/web_vitals_distribution_by_device.sql index b1236c3cd1a..360be760e51 100644 --- a/sql/2020/09_Performance/web_vitals_distribution_by_device.sql +++ b/sql/2020/09_Performance/web_vitals_distribution_by_device.sql @@ -29,8 +29,8 @@ WITH FROM `chrome-ux-report.materialized.device_summary` WHERE - device in ('desktop','phone') - AND date = date('2020-06-01') + device IN ('desktop','phone') + AND date = '2020-06-01' ), fid AS ( SELECT From d80737b5a3e4c69e688623aed56a8976e1fa9949 Mon Sep 17 00:00:00 2001 From: Max Ostapenko Date: Mon, 27 Jul 2020 00:05:43 +0100 Subject: [PATCH 15/39] query name updated --- .../{lcp_score_by_month.sql => median_lcp_score_by_month.sql} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename sql/2020/09_Performance/{lcp_score_by_month.sql => median_lcp_score_by_month.sql} (86%) diff --git a/sql/2020/09_Performance/lcp_score_by_month.sql b/sql/2020/09_Performance/median_lcp_score_by_month.sql similarity index 86% rename from sql/2020/09_Performance/lcp_score_by_month.sql rename to sql/2020/09_Performance/median_lcp_score_by_month.sql index b8b15e15718..321ca9a8337 100644 --- a/sql/2020/09_Performance/lcp_score_by_month.sql +++ b/sql/2020/09_Performance/median_lcp_score_by_month.sql @@ -1,5 +1,5 @@ #standardSQL - # Largest contentful paint score thresholds by month +# Median of Largest contentful paint 75% score by month SELECT date, From a5cf826d538c8545119b5718d39f3680372e58e2 Mon Sep 17 00:00:00 2001 From: Max Ostapenko Date: Mon, 27 Jul 2020 01:19:20 +0100 Subject: [PATCH 16/39] performance observer --- .../09_Performance/performance_observer.sql | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 sql/2020/09_Performance/performance_observer.sql diff --git a/sql/2020/09_Performance/performance_observer.sql b/sql/2020/09_Performance/performance_observer.sql new file mode 100644 index 00000000000..a5e3c3009df --- /dev/null +++ b/sql/2020/09_Performance/performance_observer.sql @@ -0,0 +1,22 @@ +#standardSQL +# Percent of pages using Performance observer + +SELECT + client, + COUNT(0) AS total_pages, + COUNTIF(performance_pages > 0) AS performance_pages, + COUNTIF(performance_pages > 0) / COUNT(0) AS pct_performance_pages, +FROM ( + SELECT + client, + COUNTIF(body LIKE '%new PerformanceObserver%') AS performance_pages, + FROM + `httparchive.almanac.summary_response_bodies` + WHERE + date = "2019-07-01" + AND type = "script" + GROUP BY + client, + page) +GROUP BY + client \ No newline at end of file From 078c50322575ac1cf7f6fe44d8534c8a007e097a Mon Sep 17 00:00:00 2001 From: Dmitry Pokidov Date: Sun, 9 Aug 2020 22:05:54 +1000 Subject: [PATCH 17/39] Distribution of LH5 and LH6 permormance scores on mobile --- .../lh5_performance_score_distribution.sql | 11 +++++++++++ .../lh6_performance_score_distribution.sql | 11 +++++++++++ 2 files changed, 22 insertions(+) create mode 100644 sql/2020/09_Performance/lh5_performance_score_distribution.sql create mode 100644 sql/2020/09_Performance/lh6_performance_score_distribution.sql diff --git a/sql/2020/09_Performance/lh5_performance_score_distribution.sql b/sql/2020/09_Performance/lh5_performance_score_distribution.sql new file mode 100644 index 00000000000..2712b0c992a --- /dev/null +++ b/sql/2020/09_Performance/lh5_performance_score_distribution.sql @@ -0,0 +1,11 @@ +SELECT + SAFE_DIVIDE(slow, slow + avg + fast + hundred) slow, + SAFE_DIVIDE(avg, slow + avg + fast + hundred) avg, + SAFE_DIVIDE(fast, slow + avg + fast + hundred) fast, + SAFE_DIVIDE(hundred, slow + avg + fast + hundred) hundred, +FROM ( + SELECT COUNTIF(score < 0.3) slow, COUNTIF(score > 0.3 and score < 0.8) avg, COUNTIF(score > 0.8 and score < 1.0) fast, COUNTIF(score = 1.0) hundred + FROM ( + SELECT CAST(JSON_EXTRACT(report, '$.categories.performance.score') AS NUMERIC) score FROM `httparchive.scratchspace.2020_03_01_lighthouse_mobile_10k` + ) +) \ No newline at end of file diff --git a/sql/2020/09_Performance/lh6_performance_score_distribution.sql b/sql/2020/09_Performance/lh6_performance_score_distribution.sql new file mode 100644 index 00000000000..1aed1167de8 --- /dev/null +++ b/sql/2020/09_Performance/lh6_performance_score_distribution.sql @@ -0,0 +1,11 @@ +SELECT + SAFE_DIVIDE(slow, slow + avg + fast + hundred) slow, + SAFE_DIVIDE(avg, slow + avg + fast + hundred) avg, + SAFE_DIVIDE(fast, slow + avg + fast + hundred) fast, + SAFE_DIVIDE(hundred, slow + avg + fast + hundred) hundred, +FROM ( + SELECT COUNTIF(score < 0.3) slow, COUNTIF(score > 0.3 and score < 0.8) avg, COUNTIF(score > 0.8 and score < 1.0) fast, COUNTIF(score = 1.0) hundred + FROM ( + SELECT CAST(JSON_EXTRACT(report, '$.categories.performance.score') AS NUMERIC) score FROM `httparchive.sample_data.lighthouse_mobile_10k` + ) +) \ No newline at end of file From 605154e9532cab5b1eb9f8cd01e0ed0d3c6429d4 Mon Sep 17 00:00:00 2001 From: "dooman87@gmail.com" Date: Fri, 14 Aug 2020 07:15:39 +1000 Subject: [PATCH 18/39] FIX: Using abs() to calculate average change between LH5 and LH6 --- .../09_Performance/lh5_performance_score_distribution.sql | 3 +++ .../09_Performance/lh6_performance_score_distribution.sql | 3 +++ sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql | 5 +++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/sql/2020/09_Performance/lh5_performance_score_distribution.sql b/sql/2020/09_Performance/lh5_performance_score_distribution.sql index 2712b0c992a..0303b132e2e 100644 --- a/sql/2020/09_Performance/lh5_performance_score_distribution.sql +++ b/sql/2020/09_Performance/lh5_performance_score_distribution.sql @@ -1,3 +1,6 @@ +#standardSQL +# Distribution of LH5 performance score. + SELECT SAFE_DIVIDE(slow, slow + avg + fast + hundred) slow, SAFE_DIVIDE(avg, slow + avg + fast + hundred) avg, diff --git a/sql/2020/09_Performance/lh6_performance_score_distribution.sql b/sql/2020/09_Performance/lh6_performance_score_distribution.sql index 1aed1167de8..97d0fcaedcb 100644 --- a/sql/2020/09_Performance/lh6_performance_score_distribution.sql +++ b/sql/2020/09_Performance/lh6_performance_score_distribution.sql @@ -1,3 +1,6 @@ +#standardSQL +# Distribution of LH6 performance score. + SELECT SAFE_DIVIDE(slow, slow + avg + fast + hundred) slow, SAFE_DIVIDE(avg, slow + avg + fast + hundred) avg, diff --git a/sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql b/sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql index 76daf3b8733..f67493f0853 100644 --- a/sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql +++ b/sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql @@ -1,14 +1,15 @@ #standardSQL # Calculates minimum, maximum and average delta between LH5 and LH6 performance score for mobile -SELECT MIN(perf_score_delta) AS min_delta, MAX(perf_score_delta) AS max_delta, AVG(perf_score_delta) AS avg_delta +SELECT MIN(perf_score_delta) AS min_delta, MAX(perf_score_delta) AS max_delta, AVG(abs_perf_score_delta) AS avg_delta FROM ( SELECT url, perf_score_lh6, perf_score_lh5, - (perf_score_lh6 - perf_score_lh5) as perf_score_delta + (perf_score_lh6 - perf_score_lh5) as perf_score_delta, + ABS(perf_score_lh6 - perf_score_lh5) as abs_perf_score_delta, FROM ( SELECT lh6.url AS url, From acc0b861c34237537a0dd001fc9e5c8945cfd435 Mon Sep 17 00:00:00 2001 From: "dooman87@gmail.com" Date: Mon, 17 Aug 2020 21:06:34 +1000 Subject: [PATCH 19/39] Updated tables and dates to use August data --- .../09_Performance/lh5_performance_score_distribution.sql | 2 +- .../09_Performance/lh6_performance_score_distribution.sql | 4 ++-- sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql | 4 ++-- sql/2020/09_Performance/lh6_vs_lh5_performance_score_02.sql | 4 ++-- sql/2020/09_Performance/median_lcp_score_by_month.sql | 2 +- sql/2020/09_Performance/offline_origins.sql | 2 +- sql/2020/09_Performance/performance_observer.sql | 2 +- sql/2020/09_Performance/web_vitals_by_country.sql | 2 +- sql/2020/09_Performance/web_vitals_by_device.sql | 2 +- sql/2020/09_Performance/web_vitals_by_ect.sql | 2 +- sql/2020/09_Performance/web_vitals_distribution_by_device.sql | 2 +- 11 files changed, 14 insertions(+), 14 deletions(-) diff --git a/sql/2020/09_Performance/lh5_performance_score_distribution.sql b/sql/2020/09_Performance/lh5_performance_score_distribution.sql index 0303b132e2e..e07f3add120 100644 --- a/sql/2020/09_Performance/lh5_performance_score_distribution.sql +++ b/sql/2020/09_Performance/lh5_performance_score_distribution.sql @@ -9,6 +9,6 @@ SELECT FROM ( SELECT COUNTIF(score < 0.3) slow, COUNTIF(score > 0.3 and score < 0.8) avg, COUNTIF(score > 0.8 and score < 1.0) fast, COUNTIF(score = 1.0) hundred FROM ( - SELECT CAST(JSON_EXTRACT(report, '$.categories.performance.score') AS NUMERIC) score FROM `httparchive.scratchspace.2020_03_01_lighthouse_mobile_10k` + SELECT CAST(JSON_EXTRACT(report, '$.categories.performance.score') AS NUMERIC) score FROM `httparchive.lighthouse.2020_05_01_mobile` ) ) \ No newline at end of file diff --git a/sql/2020/09_Performance/lh6_performance_score_distribution.sql b/sql/2020/09_Performance/lh6_performance_score_distribution.sql index 97d0fcaedcb..204f720d137 100644 --- a/sql/2020/09_Performance/lh6_performance_score_distribution.sql +++ b/sql/2020/09_Performance/lh6_performance_score_distribution.sql @@ -5,10 +5,10 @@ SELECT SAFE_DIVIDE(slow, slow + avg + fast + hundred) slow, SAFE_DIVIDE(avg, slow + avg + fast + hundred) avg, SAFE_DIVIDE(fast, slow + avg + fast + hundred) fast, - SAFE_DIVIDE(hundred, slow + avg + fast + hundred) hundred, + SAFE_DIVIDE(hundred, slow + avg + fast + hundred) hundred FROM ( SELECT COUNTIF(score < 0.3) slow, COUNTIF(score > 0.3 and score < 0.8) avg, COUNTIF(score > 0.8 and score < 1.0) fast, COUNTIF(score = 1.0) hundred FROM ( - SELECT CAST(JSON_EXTRACT(report, '$.categories.performance.score') AS NUMERIC) score FROM `httparchive.sample_data.lighthouse_mobile_10k` + SELECT CAST(JSON_EXTRACT(report, '$.categories.performance.score') AS NUMERIC) score FROM `httparchive.lighthouse.2020_08_01_mobile` ) ) \ No newline at end of file diff --git a/sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql b/sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql index f67493f0853..9a3e443a379 100644 --- a/sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql +++ b/sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql @@ -15,7 +15,7 @@ FROM SELECT lh6.url AS url, 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.sample_data.lighthouse_mobile_10k` lh6 - JOIN `httparchive.scratchspace.2020_03_01_lighthouse_mobile_10k` lh5 ON lh5.url=lh6.url + FROM `httparchive.lighthouse.2020_08_01_mobile` lh6 + JOIN `httparchive.lighthouse.2020_05_01_mobile` lh5 ON lh5.url=lh6.url ) ) \ No newline at end of file diff --git a/sql/2020/09_Performance/lh6_vs_lh5_performance_score_02.sql b/sql/2020/09_Performance/lh6_vs_lh5_performance_score_02.sql index b43a4e69062..df876ca8d0d 100644 --- a/sql/2020/09_Performance/lh6_vs_lh5_performance_score_02.sql +++ b/sql/2020/09_Performance/lh6_vs_lh5_performance_score_02.sql @@ -18,7 +18,7 @@ FROM SELECT lh6.url AS url, 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.sample_data.lighthouse_mobile_10k` lh6 - JOIN `httparchive.scratchspace.2020_03_01_lighthouse_mobile_10k` lh5 ON lh5.url=lh6.url + FROM `httparchive.lighthouse.2020_08_01_mobile` lh6 + JOIN `httparchive.lighthouse.2020_05_01_mobile` lh5 ON lh5.url=lh6.url ) ) \ No newline at end of file diff --git a/sql/2020/09_Performance/median_lcp_score_by_month.sql b/sql/2020/09_Performance/median_lcp_score_by_month.sql index 321ca9a8337..f37cee7e11c 100644 --- a/sql/2020/09_Performance/median_lcp_score_by_month.sql +++ b/sql/2020/09_Performance/median_lcp_score_by_month.sql @@ -13,7 +13,7 @@ FROM ( FROM `chrome-ux-report.materialized.device_summary` WHERE - date >= "2019-07-01" + date >= "2019-08-01" AND device IN ('desktop','phone') ) GROUP BY diff --git a/sql/2020/09_Performance/offline_origins.sql b/sql/2020/09_Performance/offline_origins.sql index 81cf6eb0024..e8b45f46a4a 100644 --- a/sql/2020/09_Performance/offline_origins.sql +++ b/sql/2020/09_Performance/offline_origins.sql @@ -12,5 +12,5 @@ FROM ( FROM `chrome-ux-report.materialized.metrics_summary` WHERE - date = '2020-06-01' + date = '2020-08-01' ) \ No newline at end of file diff --git a/sql/2020/09_Performance/performance_observer.sql b/sql/2020/09_Performance/performance_observer.sql index a5e3c3009df..f9d0f728770 100644 --- a/sql/2020/09_Performance/performance_observer.sql +++ b/sql/2020/09_Performance/performance_observer.sql @@ -13,7 +13,7 @@ FROM ( FROM `httparchive.almanac.summary_response_bodies` WHERE - date = "2019-07-01" + date = "2019-08-01" AND type = "script" GROUP BY client, diff --git a/sql/2020/09_Performance/web_vitals_by_country.sql b/sql/2020/09_Performance/web_vitals_by_country.sql index 71139f20ff0..844e7e551dd 100644 --- a/sql/2020/09_Performance/web_vitals_by_country.sql +++ b/sql/2020/09_Performance/web_vitals_by_country.sql @@ -47,7 +47,7 @@ WITH FROM `chrome-ux-report.materialized.country_summary` WHERE - yyyymm = 202006 + yyyymm = 202008 GROUP BY origin, country_code diff --git a/sql/2020/09_Performance/web_vitals_by_device.sql b/sql/2020/09_Performance/web_vitals_by_device.sql index 5105d855f09..7e5bccb854b 100644 --- a/sql/2020/09_Performance/web_vitals_by_device.sql +++ b/sql/2020/09_Performance/web_vitals_by_device.sql @@ -48,7 +48,7 @@ WITH `chrome-ux-report.materialized.device_summary` WHERE device IN ('desktop','phone') - AND date = '2020-06-01' + AND date = '2020-08-01' ) SELECT diff --git a/sql/2020/09_Performance/web_vitals_by_ect.sql b/sql/2020/09_Performance/web_vitals_by_ect.sql index baff3c9d073..0941a3d4b6c 100644 --- a/sql/2020/09_Performance/web_vitals_by_ect.sql +++ b/sql/2020/09_Performance/web_vitals_by_ect.sql @@ -29,7 +29,7 @@ WITH first_contentful_paint, experimental.time_to_first_byte AS time_to_first_byte FROM - `chrome-ux-report.all.202006` + `chrome-ux-report.all.202008` ), cls AS ( SELECT diff --git a/sql/2020/09_Performance/web_vitals_distribution_by_device.sql b/sql/2020/09_Performance/web_vitals_distribution_by_device.sql index 360be760e51..5ff83aad3d4 100644 --- a/sql/2020/09_Performance/web_vitals_distribution_by_device.sql +++ b/sql/2020/09_Performance/web_vitals_distribution_by_device.sql @@ -30,7 +30,7 @@ WITH `chrome-ux-report.materialized.device_summary` WHERE device IN ('desktop','phone') - AND date = '2020-06-01' + AND date = '2020-08-01' ), fid AS ( SELECT From 41c760cd4709e9811226e298f727647ba11a9326 Mon Sep 17 00:00:00 2001 From: "Pokidov N. Dmitry" Date: Mon, 21 Sep 2020 20:43:16 +1000 Subject: [PATCH 20/39] Update sql/2020/09_Performance/lh5_performance_score_distribution.sql Formatting Co-authored-by: Rick Viscomi --- .../09_Performance/lh5_performance_score_distribution.sql | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sql/2020/09_Performance/lh5_performance_score_distribution.sql b/sql/2020/09_Performance/lh5_performance_score_distribution.sql index e07f3add120..a3ca0347ce7 100644 --- a/sql/2020/09_Performance/lh5_performance_score_distribution.sql +++ b/sql/2020/09_Performance/lh5_performance_score_distribution.sql @@ -7,8 +7,12 @@ SELECT SAFE_DIVIDE(fast, slow + avg + fast + hundred) fast, SAFE_DIVIDE(hundred, slow + avg + fast + hundred) hundred, FROM ( - SELECT COUNTIF(score < 0.3) slow, COUNTIF(score > 0.3 and score < 0.8) avg, COUNTIF(score > 0.8 and score < 1.0) fast, COUNTIF(score = 1.0) hundred + SELECT + COUNTIF(score < 0.3) AS slow, + COUNTIF(score > 0.3 AND score < 0.8) AS avg, + COUNTIF(score > 0.8 AND score < 1.0) AS fast, + COUNTIF(score = 1.0) AS hundred FROM ( SELECT CAST(JSON_EXTRACT(report, '$.categories.performance.score') AS NUMERIC) score FROM `httparchive.lighthouse.2020_05_01_mobile` ) -) \ No newline at end of file +) From d4ce1af7b4e1e25d06f380f7bf361ff5e9ce149c Mon Sep 17 00:00:00 2001 From: "Pokidov N. Dmitry" Date: Mon, 21 Sep 2020 20:43:47 +1000 Subject: [PATCH 21/39] Update sql/2020/09_Performance/lh5_performance_score_distribution.sql Added "AS" Co-authored-by: Rick Viscomi --- .../09_Performance/lh5_performance_score_distribution.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sql/2020/09_Performance/lh5_performance_score_distribution.sql b/sql/2020/09_Performance/lh5_performance_score_distribution.sql index a3ca0347ce7..da91cb6a44e 100644 --- a/sql/2020/09_Performance/lh5_performance_score_distribution.sql +++ b/sql/2020/09_Performance/lh5_performance_score_distribution.sql @@ -2,10 +2,10 @@ # Distribution of LH5 performance score. SELECT - SAFE_DIVIDE(slow, slow + avg + fast + hundred) slow, - SAFE_DIVIDE(avg, slow + avg + fast + hundred) avg, - SAFE_DIVIDE(fast, slow + avg + fast + hundred) fast, - SAFE_DIVIDE(hundred, slow + avg + fast + hundred) hundred, + SAFE_DIVIDE(slow, slow + avg + fast + hundred) AS slow, + SAFE_DIVIDE(avg, slow + avg + fast + hundred) AS avg, + SAFE_DIVIDE(fast, slow + avg + fast + hundred) AS fast, + SAFE_DIVIDE(hundred, slow + avg + fast + hundred) AS hundred, FROM ( SELECT COUNTIF(score < 0.3) AS slow, From 6f683e472552d4a31a4ae0123f7d65f1a8a05dfe Mon Sep 17 00:00:00 2001 From: Dmitry Pokidov Date: Mon, 21 Sep 2020 20:53:44 +1000 Subject: [PATCH 22/39] Removed unused variables, formatting and using September table in queries. --- .../lh5_performance_score_distribution.sql | 2 +- .../lh6_performance_score_distribution.sql | 10 +++++----- .../lh6_vs_lh5_performance_score_01.sql | 14 +++++++------- .../lh6_vs_lh5_performance_score_02.sql | 7 +++---- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/sql/2020/09_Performance/lh5_performance_score_distribution.sql b/sql/2020/09_Performance/lh5_performance_score_distribution.sql index da91cb6a44e..cc91131ca03 100644 --- a/sql/2020/09_Performance/lh5_performance_score_distribution.sql +++ b/sql/2020/09_Performance/lh5_performance_score_distribution.sql @@ -5,7 +5,7 @@ SELECT SAFE_DIVIDE(slow, slow + avg + fast + hundred) AS slow, SAFE_DIVIDE(avg, slow + avg + fast + hundred) AS avg, SAFE_DIVIDE(fast, slow + avg + fast + hundred) AS fast, - SAFE_DIVIDE(hundred, slow + avg + fast + hundred) AS hundred, + SAFE_DIVIDE(hundred, slow + avg + fast + hundred) AS hundred FROM ( SELECT COUNTIF(score < 0.3) AS slow, diff --git a/sql/2020/09_Performance/lh6_performance_score_distribution.sql b/sql/2020/09_Performance/lh6_performance_score_distribution.sql index 204f720d137..47a844d1303 100644 --- a/sql/2020/09_Performance/lh6_performance_score_distribution.sql +++ b/sql/2020/09_Performance/lh6_performance_score_distribution.sql @@ -2,13 +2,13 @@ # Distribution of LH6 performance score. SELECT - SAFE_DIVIDE(slow, slow + avg + fast + hundred) slow, - SAFE_DIVIDE(avg, slow + avg + fast + hundred) avg, - SAFE_DIVIDE(fast, slow + avg + fast + hundred) fast, - SAFE_DIVIDE(hundred, slow + avg + fast + hundred) hundred + SAFE_DIVIDE(slow, slow + avg + fast + hundred) AS slow, + SAFE_DIVIDE(avg, slow + avg + fast + hundred) AS avg, + SAFE_DIVIDE(fast, slow + avg + fast + hundred) AS fast, + SAFE_DIVIDE(hundred, slow + avg + fast + hundred) AS hundred FROM ( SELECT COUNTIF(score < 0.3) slow, COUNTIF(score > 0.3 and score < 0.8) avg, COUNTIF(score > 0.8 and score < 1.0) fast, COUNTIF(score = 1.0) hundred FROM ( - SELECT CAST(JSON_EXTRACT(report, '$.categories.performance.score') AS NUMERIC) score FROM `httparchive.lighthouse.2020_08_01_mobile` + SELECT CAST(JSON_EXTRACT(report, '$.categories.performance.score') AS NUMERIC) score FROM `httparchive.lighthouse.2020_09_01_mobile` ) ) \ No newline at end of file diff --git a/sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql b/sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql index 9a3e443a379..74355f84f0c 100644 --- a/sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql +++ b/sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql @@ -1,21 +1,21 @@ #standardSQL # Calculates minimum, maximum and average delta between LH5 and LH6 performance score for mobile -SELECT MIN(perf_score_delta) AS min_delta, MAX(perf_score_delta) AS max_delta, AVG(abs_perf_score_delta) AS avg_delta +SELECT + MIN(perf_score_delta) AS min_delta, + MAX(perf_score_delta) AS max_delta, + AVG(abs_perf_score_delta) AS avg_delta FROM ( SELECT - url, - perf_score_lh6, - perf_score_lh5, (perf_score_lh6 - perf_score_lh5) as perf_score_delta, - ABS(perf_score_lh6 - perf_score_lh5) as abs_perf_score_delta, + ABS(perf_score_lh6 - perf_score_lh5) as abs_perf_score_delta FROM ( SELECT lh6.url AS url, 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_08_01_mobile` 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.2020_05_01_mobile` lh5 ON lh5.url=lh6.url ) ) \ No newline at end of file diff --git a/sql/2020/09_Performance/lh6_vs_lh5_performance_score_02.sql b/sql/2020/09_Performance/lh6_vs_lh5_performance_score_02.sql index df876ca8d0d..bd024184ad1 100644 --- a/sql/2020/09_Performance/lh6_vs_lh5_performance_score_02.sql +++ b/sql/2020/09_Performance/lh6_vs_lh5_performance_score_02.sql @@ -9,16 +9,15 @@ SELECT FROM ( SELECT - url, perf_score_lh6, perf_score_lh5, (perf_score_lh6 - perf_score_lh5) as perf_score_delta FROM ( - SELECT lh6.url AS url, + 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_08_01_mobile` 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.2020_05_01_mobile` lh5 ON lh5.url=lh6.url ) ) \ No newline at end of file From 818ab019526d9d57c0d9d761aa0885f6576d6597 Mon Sep 17 00:00:00 2001 From: Dmitry Pokidov Date: Mon, 21 Sep 2020 20:57:03 +1000 Subject: [PATCH 23/39] Formatting --- .../09_Performance/lh6_performance_score_distribution.sql | 6 +++++- sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql | 4 ++-- sql/2020/09_Performance/lh6_vs_lh5_performance_score_02.sql | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/sql/2020/09_Performance/lh6_performance_score_distribution.sql b/sql/2020/09_Performance/lh6_performance_score_distribution.sql index 47a844d1303..111d7d51054 100644 --- a/sql/2020/09_Performance/lh6_performance_score_distribution.sql +++ b/sql/2020/09_Performance/lh6_performance_score_distribution.sql @@ -7,7 +7,11 @@ SELECT SAFE_DIVIDE(fast, slow + avg + fast + hundred) AS fast, SAFE_DIVIDE(hundred, slow + avg + fast + hundred) AS hundred FROM ( - SELECT COUNTIF(score < 0.3) slow, COUNTIF(score > 0.3 and score < 0.8) avg, COUNTIF(score > 0.8 and score < 1.0) fast, COUNTIF(score = 1.0) hundred + SELECT + COUNTIF(score < 0.3) AS slow, + COUNTIF(score > 0.3 AND score < 0.8) AS avg, + COUNTIF(score > 0.8 AND score < 1.0) AS fast, + COUNTIF(score = 1.0) AS hundred FROM ( SELECT CAST(JSON_EXTRACT(report, '$.categories.performance.score') AS NUMERIC) score FROM `httparchive.lighthouse.2020_09_01_mobile` ) diff --git a/sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql b/sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql index 74355f84f0c..cf4dcde5d48 100644 --- a/sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql +++ b/sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql @@ -8,8 +8,8 @@ SELECT FROM ( SELECT - (perf_score_lh6 - perf_score_lh5) as perf_score_delta, - ABS(perf_score_lh6 - perf_score_lh5) as abs_perf_score_delta + (perf_score_lh6 - perf_score_lh5) AS perf_score_delta, + ABS(perf_score_lh6 - perf_score_lh5) AS abs_perf_score_delta FROM ( SELECT lh6.url AS url, diff --git a/sql/2020/09_Performance/lh6_vs_lh5_performance_score_02.sql b/sql/2020/09_Performance/lh6_vs_lh5_performance_score_02.sql index bd024184ad1..dcc1dcb16d8 100644 --- a/sql/2020/09_Performance/lh6_vs_lh5_performance_score_02.sql +++ b/sql/2020/09_Performance/lh6_vs_lh5_performance_score_02.sql @@ -11,7 +11,7 @@ FROM SELECT perf_score_lh6, perf_score_lh5, - (perf_score_lh6 - perf_score_lh5) as perf_score_delta + (perf_score_lh6 - perf_score_lh5) AS perf_score_delta FROM ( SELECT From 1ae70c0c21de6a24d73d88481b55734ed6505082 Mon Sep 17 00:00:00 2001 From: Max Ostapenko Date: Fri, 2 Oct 2020 23:25:16 +0100 Subject: [PATCH 24/39] updated dates --- sql/2020/09_Performance/median_lcp_score_by_month.sql | 3 ++- sql/2020/09_Performance/offline_origins.sql | 3 ++- sql/2020/09_Performance/performance_observer.sql | 5 +++-- sql/2020/09_Performance/web_vitals_by_country.sql | 2 +- sql/2020/09_Performance/web_vitals_by_device.sql | 3 ++- sql/2020/09_Performance/web_vitals_by_ect.sql | 2 +- .../09_Performance/web_vitals_distribution_by_device.sql | 3 ++- 7 files changed, 13 insertions(+), 8 deletions(-) diff --git a/sql/2020/09_Performance/median_lcp_score_by_month.sql b/sql/2020/09_Performance/median_lcp_score_by_month.sql index f37cee7e11c..4ab1d76e00d 100644 --- a/sql/2020/09_Performance/median_lcp_score_by_month.sql +++ b/sql/2020/09_Performance/median_lcp_score_by_month.sql @@ -13,7 +13,8 @@ FROM ( FROM `chrome-ux-report.materialized.device_summary` WHERE - date >= "2019-08-01" + date >= "2020-09-01" + AND date <= "2020-09-30" AND device IN ('desktop','phone') ) GROUP BY diff --git a/sql/2020/09_Performance/offline_origins.sql b/sql/2020/09_Performance/offline_origins.sql index e8b45f46a4a..e92699b1cce 100644 --- a/sql/2020/09_Performance/offline_origins.sql +++ b/sql/2020/09_Performance/offline_origins.sql @@ -12,5 +12,6 @@ FROM ( FROM `chrome-ux-report.materialized.metrics_summary` WHERE - date = '2020-08-01' + date >= '2020-09-01' + AND date <= "2020-09-30" ) \ No newline at end of file diff --git a/sql/2020/09_Performance/performance_observer.sql b/sql/2020/09_Performance/performance_observer.sql index f9d0f728770..d343d39bc73 100644 --- a/sql/2020/09_Performance/performance_observer.sql +++ b/sql/2020/09_Performance/performance_observer.sql @@ -13,8 +13,9 @@ FROM ( FROM `httparchive.almanac.summary_response_bodies` WHERE - date = "2019-08-01" - AND type = "script" + type = "script" + AND date >= "2020-09-01" + AND date <= "2020-09-30" GROUP BY client, page) diff --git a/sql/2020/09_Performance/web_vitals_by_country.sql b/sql/2020/09_Performance/web_vitals_by_country.sql index 844e7e551dd..08e47fba02f 100644 --- a/sql/2020/09_Performance/web_vitals_by_country.sql +++ b/sql/2020/09_Performance/web_vitals_by_country.sql @@ -47,7 +47,7 @@ WITH FROM `chrome-ux-report.materialized.country_summary` WHERE - yyyymm = 202008 + yyyymm = 202009 GROUP BY origin, country_code diff --git a/sql/2020/09_Performance/web_vitals_by_device.sql b/sql/2020/09_Performance/web_vitals_by_device.sql index 7e5bccb854b..0caaa370593 100644 --- a/sql/2020/09_Performance/web_vitals_by_device.sql +++ b/sql/2020/09_Performance/web_vitals_by_device.sql @@ -48,7 +48,8 @@ WITH `chrome-ux-report.materialized.device_summary` WHERE device IN ('desktop','phone') - AND date = '2020-08-01' + AND date >= '2020-09-01' + AND date <= "2020-09-30" ) SELECT diff --git a/sql/2020/09_Performance/web_vitals_by_ect.sql b/sql/2020/09_Performance/web_vitals_by_ect.sql index 0941a3d4b6c..a6ee9b30050 100644 --- a/sql/2020/09_Performance/web_vitals_by_ect.sql +++ b/sql/2020/09_Performance/web_vitals_by_ect.sql @@ -29,7 +29,7 @@ WITH first_contentful_paint, experimental.time_to_first_byte AS time_to_first_byte FROM - `chrome-ux-report.all.202008` + `chrome-ux-report.all.202009` ), cls AS ( SELECT diff --git a/sql/2020/09_Performance/web_vitals_distribution_by_device.sql b/sql/2020/09_Performance/web_vitals_distribution_by_device.sql index 5ff83aad3d4..23706d90ea7 100644 --- a/sql/2020/09_Performance/web_vitals_distribution_by_device.sql +++ b/sql/2020/09_Performance/web_vitals_distribution_by_device.sql @@ -30,7 +30,8 @@ WITH `chrome-ux-report.materialized.device_summary` WHERE device IN ('desktop','phone') - AND date = '2020-08-01' + AND date >= '2020-09-01' + AND date <= "2020-09-30" ), fid AS ( SELECT From 0ecea027945d69de0f7995b9eee4150fef4a8b70 Mon Sep 17 00:00:00 2001 From: Max Ostapenko Date: Sat, 3 Oct 2020 00:20:45 +0100 Subject: [PATCH 25/39] median function update --- .../median_lcp_score_by_month.sql | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/sql/2020/09_Performance/median_lcp_score_by_month.sql b/sql/2020/09_Performance/median_lcp_score_by_month.sql index 4ab1d76e00d..4936263929d 100644 --- a/sql/2020/09_Performance/median_lcp_score_by_month.sql +++ b/sql/2020/09_Performance/median_lcp_score_by_month.sql @@ -1,23 +1,17 @@ #standardSQL # Median of Largest contentful paint 75% score by month + SELECT date, device, - median_p75_lcp -FROM ( - SELECT - date, - device, - PERCENTILE_CONT(p75_lcp, 0.5) OVER(PARTITION BY date, device) AS median_p75_lcp - FROM - `chrome-ux-report.materialized.device_summary` - WHERE - date >= "2020-09-01" - AND date <= "2020-09-30" - AND device IN ('desktop','phone') -) + APPROX_QUANTILES(p75_lcp, 2 RESPECT NULLS)[OFFSET(1)] AS approx_median_p75_lcp, +FROM + `chrome-ux-report.materialized.device_summary` +WHERE + date >= "2019-09-01" + AND date <= "2020-09-30" + AND device IN ('desktop','phone') GROUP BY date, - device, - median_p75_lcp \ No newline at end of file + device \ No newline at end of file From f52241f2926ea98b28b31eef58d99aa86ddd9786 Mon Sep 17 00:00:00 2001 From: Dmitry Pokidov Date: Sun, 4 Oct 2020 21:36:40 +1100 Subject: [PATCH 26/39] * Using percentage to compare performance scores between LH5 and LH6. * Using last year dataset to show distribution of LH performance score --- .../lh5_performance_score_distribution.sql | 2 +- .../lh6_vs_lh5_performance_score_02.sql | 33 +++++++++++-------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/sql/2020/09_Performance/lh5_performance_score_distribution.sql b/sql/2020/09_Performance/lh5_performance_score_distribution.sql index cc91131ca03..4b212398836 100644 --- a/sql/2020/09_Performance/lh5_performance_score_distribution.sql +++ b/sql/2020/09_Performance/lh5_performance_score_distribution.sql @@ -13,6 +13,6 @@ FROM ( COUNTIF(score > 0.8 AND score < 1.0) AS fast, COUNTIF(score = 1.0) AS hundred FROM ( - SELECT CAST(JSON_EXTRACT(report, '$.categories.performance.score') AS NUMERIC) score FROM `httparchive.lighthouse.2020_05_01_mobile` + SELECT CAST(JSON_EXTRACT(report, '$.categories.performance.score') AS NUMERIC) score FROM `httparchive.lighthouse.2019_07_01_mobile` ) ) diff --git a/sql/2020/09_Performance/lh6_vs_lh5_performance_score_02.sql b/sql/2020/09_Performance/lh6_vs_lh5_performance_score_02.sql index dcc1dcb16d8..05e94f92ef4 100644 --- a/sql/2020/09_Performance/lh6_vs_lh5_performance_score_02.sql +++ b/sql/2020/09_Performance/lh6_vs_lh5_performance_score_02.sql @@ -1,23 +1,30 @@ #standardSQL -# Calculates number of sites where the performance score changed low ( < 10), medium (10-30) or big (> 30) between +# Calculates percentage of sites where the performance score changed low ( < 10), medium (10-30) or big (> 30) between # LH 5 and 6 versions. + 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 -( + 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 +FROM ( SELECT - perf_score_lh6, - perf_score_lh5, - (perf_score_lh6 - perf_score_lh5) AS perf_score_delta + 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 ( 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.2020_05_01_mobile` lh5 ON lh5.url=lh6.url + perf_score_lh6, + perf_score_lh5, + (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.2020_05_01_mobile` lh5 ON lh5.url=lh6.url + ) ) ) \ No newline at end of file From aeb4f150bea90e28992f55af8c29585c1dbd9b4d Mon Sep 17 00:00:00 2001 From: Dmitry Pokidov Date: Mon, 5 Oct 2020 08:47:51 +1100 Subject: [PATCH 27/39] Using raw distribution for performance score and percentiles for LH5 vs LH6 scores comparison --- .../lh5_performance_score_distribution.sql | 24 ++++++++----------- .../lh6_performance_score_distribution.sql | 24 ++++++++----------- .../lh6_vs_lh5_performance_score_01.sql | 22 ++++++++--------- 3 files changed, 31 insertions(+), 39 deletions(-) diff --git a/sql/2020/09_Performance/lh5_performance_score_distribution.sql b/sql/2020/09_Performance/lh5_performance_score_distribution.sql index 4b212398836..3a80b25e3e0 100644 --- a/sql/2020/09_Performance/lh5_performance_score_distribution.sql +++ b/sql/2020/09_Performance/lh5_performance_score_distribution.sql @@ -2,17 +2,13 @@ # Distribution of LH5 performance score. SELECT - SAFE_DIVIDE(slow, slow + avg + fast + hundred) AS slow, - SAFE_DIVIDE(avg, slow + avg + fast + hundred) AS avg, - SAFE_DIVIDE(fast, slow + avg + fast + hundred) AS fast, - SAFE_DIVIDE(hundred, slow + avg + fast + hundred) AS hundred -FROM ( - SELECT - COUNTIF(score < 0.3) AS slow, - COUNTIF(score > 0.3 AND score < 0.8) AS avg, - COUNTIF(score > 0.8 AND score < 1.0) AS fast, - COUNTIF(score = 1.0) AS hundred - FROM ( - SELECT CAST(JSON_EXTRACT(report, '$.categories.performance.score') AS NUMERIC) score FROM `httparchive.lighthouse.2019_07_01_mobile` - ) -) + JSON_EXTRACT_SCALAR(report, '$.categories.performance.score') AS score, + COUNT(0) AS freq, + SUM(COUNT(0)) OVER () AS total, + COUNT(0) / SUM(COUNT(0)) OVER () AS pct +FROM + `httparchive.lighthouse.2019_07_01_mobile` +GROUP BY + score +ORDER BY + score diff --git a/sql/2020/09_Performance/lh6_performance_score_distribution.sql b/sql/2020/09_Performance/lh6_performance_score_distribution.sql index 111d7d51054..5f6d898db7b 100644 --- a/sql/2020/09_Performance/lh6_performance_score_distribution.sql +++ b/sql/2020/09_Performance/lh6_performance_score_distribution.sql @@ -2,17 +2,13 @@ # Distribution of LH6 performance score. SELECT - SAFE_DIVIDE(slow, slow + avg + fast + hundred) AS slow, - SAFE_DIVIDE(avg, slow + avg + fast + hundred) AS avg, - SAFE_DIVIDE(fast, slow + avg + fast + hundred) AS fast, - SAFE_DIVIDE(hundred, slow + avg + fast + hundred) AS hundred -FROM ( - SELECT - COUNTIF(score < 0.3) AS slow, - COUNTIF(score > 0.3 AND score < 0.8) AS avg, - COUNTIF(score > 0.8 AND score < 1.0) AS fast, - COUNTIF(score = 1.0) AS hundred - FROM ( - SELECT CAST(JSON_EXTRACT(report, '$.categories.performance.score') AS NUMERIC) score FROM `httparchive.lighthouse.2020_09_01_mobile` - ) -) \ No newline at end of file + JSON_EXTRACT_SCALAR(report, '$.categories.performance.score') AS score, + COUNT(0) AS freq, + SUM(COUNT(0)) OVER () AS total, + COUNT(0) / SUM(COUNT(0)) OVER () AS pct +FROM + `httparchive.lighthouse.2020_09_01_mobile` +GROUP BY + score +ORDER BY + score diff --git a/sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql b/sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql index cf4dcde5d48..26d2481f751 100644 --- a/sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql +++ b/sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql @@ -1,21 +1,21 @@ #standardSQL +# Calculates percentile for delta of LH5 and LH6 performance score for mobile -# Calculates minimum, maximum and average delta between LH5 and LH6 performance score for mobile SELECT - MIN(perf_score_delta) AS min_delta, - MAX(perf_score_delta) AS max_delta, - AVG(abs_perf_score_delta) AS avg_delta -FROM -( + percentile, + APPROX_QUANTILES(abs_perf_score_delta, 1000)[OFFSET(percentile * 10)] AS abs_perf_score_delta +FROM ( SELECT - (perf_score_lh6 - perf_score_lh5) AS perf_score_delta, ABS(perf_score_lh6 - perf_score_lh5) AS abs_perf_score_delta FROM ( - SELECT lh6.url AS url, + 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.2020_05_01_mobile` lh5 ON lh5.url=lh6.url + FROM `httparchive.lighthouse.2020_09_01_mobile` lh6 + JOIN `httparchive.lighthouse.2020_05_01_mobile` lh5 ON lh5.url=lh6.url ) -) \ No newline at end of file +), +UNNEST([10, 25, 50, 75, 90]) AS percentile +GROUP BY percentile +ORDER BY percentile From 5b0f2f99a8ea6b33c4ffcaf77ab1ea5f2b2f476e Mon Sep 17 00:00:00 2001 From: Max Ostapenko Date: Tue, 6 Oct 2020 03:21:36 +0100 Subject: [PATCH 28/39] review updates + lighthouse performance audits --- .../lighthouse_performace_audits.sql | 41 +++++++++++++++++++ .../median_lcp_score_by_month.sql | 7 ++-- sql/2020/09_Performance/offline_origins.sql | 3 +- .../09_Performance/performance_observer.sql | 26 ++++-------- .../09_Performance/web_vitals_by_country.sql | 12 +++--- sql/2020/09_Performance/web_vitals_by_ect.sql | 8 ++-- .../web_vitals_distribution_by_device.sql | 5 +-- 7 files changed, 65 insertions(+), 37 deletions(-) create mode 100644 sql/2020/09_Performance/lighthouse_performace_audits.sql diff --git a/sql/2020/09_Performance/lighthouse_performace_audits.sql b/sql/2020/09_Performance/lighthouse_performace_audits.sql new file mode 100644 index 00000000000..e9c4d44eef9 --- /dev/null +++ b/sql/2020/09_Performance/lighthouse_performace_audits.sql @@ -0,0 +1,41 @@ +#standardSQL +# Get summary of all lighthouse scores for a category +# Note scores, weightings, groups and descriptions may be off in mixed months when new versions of Lighthouse roles out + +CREATE TEMPORARY FUNCTION getAudits(report STRING, category STRING) +RETURNS ARRAY> LANGUAGE js AS ''' +var $ = JSON.parse(report); +var auditrefs = $.categories[category].auditRefs; +var audits = $.audits; +$ = null; +var results = []; +for (auditref of auditrefs) { + results.push({ + id: auditref.id, + weight: auditref.weight, + audit_group: auditref.group, + description: audits[auditref.id].description, + score: audits[auditref.id].score + }); +} +return results; +'''; + +SELECT + audits.id AS id, + COUNTIF(audits.score > 0) AS num_pages, + COUNT(0) AS total, + COUNTIF(audits.score > 0) / COUNT(0) AS pct, + APPROX_QUANTILES(audits.weight, 100)[OFFSET(50)] AS median_weight, + MAX(audits.audit_group) AS audit_group, + MAX(audits.description) AS description +FROM + `httparchive.lighthouse.2020_09_01_mobile`, + UNNEST(getAudits(report, "performance")) AS audits +WHERE + LENGTH(report) < 20000000 # necessary to avoid out of memory issues. Excludes 16 very large results +GROUP BY + audits.id +ORDER BY + median_weight DESC, + id \ No newline at end of file diff --git a/sql/2020/09_Performance/median_lcp_score_by_month.sql b/sql/2020/09_Performance/median_lcp_score_by_month.sql index 4936263929d..a53c5728672 100644 --- a/sql/2020/09_Performance/median_lcp_score_by_month.sql +++ b/sql/2020/09_Performance/median_lcp_score_by_month.sql @@ -5,13 +5,12 @@ SELECT date, device, - APPROX_QUANTILES(p75_lcp, 2 RESPECT NULLS)[OFFSET(1)] AS approx_median_p75_lcp, + APPROX_QUANTILES(p75_lcp, 1000 RESPECT NULLS)[OFFSET(500)] AS median_p75_lcp, FROM `chrome-ux-report.materialized.device_summary` WHERE - date >= "2019-09-01" - AND date <= "2020-09-30" - AND device IN ('desktop','phone') + date = '2019-09-01' AND + device IN ('desktop','phone') GROUP BY date, device \ No newline at end of file diff --git a/sql/2020/09_Performance/offline_origins.sql b/sql/2020/09_Performance/offline_origins.sql index e92699b1cce..14fb8910a91 100644 --- a/sql/2020/09_Performance/offline_origins.sql +++ b/sql/2020/09_Performance/offline_origins.sql @@ -12,6 +12,5 @@ FROM ( FROM `chrome-ux-report.materialized.metrics_summary` WHERE - date >= '2020-09-01' - AND date <= "2020-09-30" + date = '2020-09-01' ) \ No newline at end of file diff --git a/sql/2020/09_Performance/performance_observer.sql b/sql/2020/09_Performance/performance_observer.sql index d343d39bc73..411df2ff2f1 100644 --- a/sql/2020/09_Performance/performance_observer.sql +++ b/sql/2020/09_Performance/performance_observer.sql @@ -3,21 +3,11 @@ SELECT client, - COUNT(0) AS total_pages, - COUNTIF(performance_pages > 0) AS performance_pages, - COUNTIF(performance_pages > 0) / COUNT(0) AS pct_performance_pages, -FROM ( - SELECT - client, - COUNTIF(body LIKE '%new PerformanceObserver%') AS performance_pages, - FROM - `httparchive.almanac.summary_response_bodies` - WHERE - type = "script" - AND date >= "2020-09-01" - AND date <= "2020-09-30" - GROUP BY - client, - page) -GROUP BY - client \ No newline at end of file + num_urls, + total_urls, + pct_urls +FROM + `httparchive.blink_features.usage` +WHERE + yyyymmdd = '20200901' AND + feature = 'PerformanceObserverForWindow' \ No newline at end of file diff --git a/sql/2020/09_Performance/web_vitals_by_country.sql b/sql/2020/09_Performance/web_vitals_by_country.sql index 08e47fba02f..e59f9baf483 100644 --- a/sql/2020/09_Performance/web_vitals_by_country.sql +++ b/sql/2020/09_Performance/web_vitals_by_country.sql @@ -2,16 +2,16 @@ # Core WebVitals by country CREATE TEMP FUNCTION IS_GOOD (good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS ( - good / (good + needs_improvement + poor) >= 0.75 + SAFE_DIVIDE(good, (good + needs_improvement + poor)) >= 0.75 ); CREATE TEMP FUNCTION IS_POOR (good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS ( - poor / (good + needs_improvement + poor) >= 0.25 + SAFE_DIVIDE(poor, (good + needs_improvement + poor)) >= 0.25 ); CREATE TEMP FUNCTION IS_NI (good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS ( - NOT IS_GOOD(good, needs_improvement, poor) - AND NOT IS_POOR(good, needs_improvement, poor) + NOT IS_GOOD(good, needs_improvement, poor) AND + NOT IS_POOR(good, needs_improvement, poor) ); CREATE TEMP FUNCTION IS_NON_ZERO (good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS ( @@ -54,7 +54,7 @@ WITH ) SELECT -  country_code, +  `chrome-ux-report`.experimental.GET_COUNTRY(country_code) AS country, COUNT(DISTINCT origin) AS total_origins, @@ -151,4 +151,4 @@ SELECT FROM base GROUP BY -  country_code \ No newline at end of file +  country \ No newline at end of file diff --git a/sql/2020/09_Performance/web_vitals_by_ect.sql b/sql/2020/09_Performance/web_vitals_by_ect.sql index a6ee9b30050..7054e53c3fd 100644 --- a/sql/2020/09_Performance/web_vitals_by_ect.sql +++ b/sql/2020/09_Performance/web_vitals_by_ect.sql @@ -2,16 +2,16 @@ # WebVitals by effective connection type CREATE TEMP FUNCTION IS_GOOD (good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS ( - good / (good + needs_improvement + poor) >= 0.75 + SAFE_DIVIDE(good, (good + needs_improvement + poor)) >= 0.75 ); CREATE TEMP FUNCTION IS_NI (good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS ( - good / (good + needs_improvement + poor) < 0.75 - AND poor / (good + needs_improvement + poor) < 0.25 + SAFE_DIVIDE(good, (good + needs_improvement + poor)) < 0.75 AND + SAFE_DIVIDE(poor, (good + needs_improvement + poor)) < 0.25 ); CREATE TEMP FUNCTION IS_POOR (good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS ( - poor / (good + needs_improvement + poor) >= 0.25 + SAFE_DIVIDE(poor, (good + needs_improvement + poor)) >= 0.25 ); CREATE TEMP FUNCTION IS_NON_ZERO (good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS ( diff --git a/sql/2020/09_Performance/web_vitals_distribution_by_device.sql b/sql/2020/09_Performance/web_vitals_distribution_by_device.sql index 23706d90ea7..d3a70b45bad 100644 --- a/sql/2020/09_Performance/web_vitals_distribution_by_device.sql +++ b/sql/2020/09_Performance/web_vitals_distribution_by_device.sql @@ -29,9 +29,8 @@ WITH FROM `chrome-ux-report.materialized.device_summary` WHERE - device IN ('desktop','phone') - AND date >= '2020-09-01' - AND date <= "2020-09-30" + device IN ('desktop','phone') AND + date = '2020-09-01' ), fid AS ( SELECT From 05b2ce2356128c82f5830b2f64a11c94ebe0d7f9 Mon Sep 17 00:00:00 2001 From: Max Ostapenko Date: Tue, 6 Oct 2020 03:27:28 +0100 Subject: [PATCH 29/39] year series fix --- sql/2020/09_Performance/median_lcp_score_by_month.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/2020/09_Performance/median_lcp_score_by_month.sql b/sql/2020/09_Performance/median_lcp_score_by_month.sql index a53c5728672..736a5e039d7 100644 --- a/sql/2020/09_Performance/median_lcp_score_by_month.sql +++ b/sql/2020/09_Performance/median_lcp_score_by_month.sql @@ -1,7 +1,6 @@ #standardSQL # Median of Largest contentful paint 75% score by month - SELECT date, device, @@ -9,7 +8,8 @@ SELECT FROM `chrome-ux-report.materialized.device_summary` WHERE - date = '2019-09-01' AND + date >= '2019-09-01' AND + date <= '2020-09-01' device IN ('desktop','phone') GROUP BY date, From 62035e7923f93dc705b2e89719166bd99d9c3da9 Mon Sep 17 00:00:00 2001 From: Max Ostapenko Date: Tue, 6 Oct 2020 03:48:04 +0100 Subject: [PATCH 30/39] fix median precision --- sql/2020/09_Performance/lighthouse_performace_audits.sql | 2 +- sql/2020/09_Performance/web_vitals_by_device.sql | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/sql/2020/09_Performance/lighthouse_performace_audits.sql b/sql/2020/09_Performance/lighthouse_performace_audits.sql index e9c4d44eef9..e8a926be935 100644 --- a/sql/2020/09_Performance/lighthouse_performace_audits.sql +++ b/sql/2020/09_Performance/lighthouse_performace_audits.sql @@ -26,7 +26,7 @@ SELECT COUNTIF(audits.score > 0) AS num_pages, COUNT(0) AS total, COUNTIF(audits.score > 0) / COUNT(0) AS pct, - APPROX_QUANTILES(audits.weight, 100)[OFFSET(50)] AS median_weight, + APPROX_QUANTILES(audits.weight, 1000)[OFFSET(500)] AS median_weight, MAX(audits.audit_group) AS audit_group, MAX(audits.description) AS description FROM diff --git a/sql/2020/09_Performance/web_vitals_by_device.sql b/sql/2020/09_Performance/web_vitals_by_device.sql index 0caaa370593..5a23f15aa35 100644 --- a/sql/2020/09_Performance/web_vitals_by_device.sql +++ b/sql/2020/09_Performance/web_vitals_by_device.sql @@ -48,8 +48,7 @@ WITH `chrome-ux-report.materialized.device_summary` WHERE device IN ('desktop','phone') - AND date >= '2020-09-01' - AND date <= "2020-09-30" + AND date = '2020-09-01' ) SELECT From 0b46b3e645293d94ba5f77e7f1cc9e48d9aa246b Mon Sep 17 00:00:00 2001 From: Max Ostapenko Date: Tue, 6 Oct 2020 13:29:52 +0100 Subject: [PATCH 31/39] Update sql/2020/09_Performance/lighthouse_performace_audits.sql Co-authored-by: Barry Pollard --- sql/2020/09_Performance/lighthouse_performace_audits.sql | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sql/2020/09_Performance/lighthouse_performace_audits.sql b/sql/2020/09_Performance/lighthouse_performace_audits.sql index e8a926be935..76089453a97 100644 --- a/sql/2020/09_Performance/lighthouse_performace_audits.sql +++ b/sql/2020/09_Performance/lighthouse_performace_audits.sql @@ -25,7 +25,8 @@ SELECT audits.id AS id, COUNTIF(audits.score > 0) AS num_pages, COUNT(0) AS total, - COUNTIF(audits.score > 0) / COUNT(0) AS pct, + COUNTIF(audits.score IS NOT NULL) AS total_applicable, + SAFE_DIVIDE(COUNTIF(audits.score > 0), COUNTIF(audits.score IS NOT NULL)) AS pct, APPROX_QUANTILES(audits.weight, 1000)[OFFSET(500)] AS median_weight, MAX(audits.audit_group) AS audit_group, MAX(audits.description) AS description @@ -38,4 +39,4 @@ GROUP BY audits.id ORDER BY median_weight DESC, - id \ No newline at end of file + id From c18af8382a6d84ca2e4bda21360315d4eee5a234 Mon Sep 17 00:00:00 2001 From: Max Ostapenko Date: Tue, 6 Oct 2020 15:09:29 +0100 Subject: [PATCH 32/39] Update sql/2020/09_Performance/web_vitals_distribution_by_device.sql Co-authored-by: Rick Viscomi --- .../09_Performance/web_vitals_distribution_by_device.sql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sql/2020/09_Performance/web_vitals_distribution_by_device.sql b/sql/2020/09_Performance/web_vitals_distribution_by_device.sql index d3a70b45bad..0fc1e197d41 100644 --- a/sql/2020/09_Performance/web_vitals_distribution_by_device.sql +++ b/sql/2020/09_Performance/web_vitals_distribution_by_device.sql @@ -179,4 +179,7 @@ FULL JOIN USING (row, device) FULL JOIN ttfb -USING (row, device) \ No newline at end of file +USING (row, device) +ORDER BY + row, + device From 9f5529ab7fd5c941b214c6136c1f205288cb909f Mon Sep 17 00:00:00 2001 From: Max Ostapenko Date: Tue, 6 Oct 2020 15:23:59 +0100 Subject: [PATCH 33/39] use August data from crux tables --- sql/2020/09_Performance/lighthouse_performace_audits.sql | 2 +- sql/2020/09_Performance/median_lcp_score_by_month.sql | 2 +- sql/2020/09_Performance/offline_origins.sql | 2 +- sql/2020/09_Performance/performance_observer.sql | 2 +- sql/2020/09_Performance/web_vitals_by_country.sql | 2 +- sql/2020/09_Performance/web_vitals_by_device.sql | 2 +- sql/2020/09_Performance/web_vitals_by_ect.sql | 2 +- sql/2020/09_Performance/web_vitals_distribution_by_device.sql | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sql/2020/09_Performance/lighthouse_performace_audits.sql b/sql/2020/09_Performance/lighthouse_performace_audits.sql index e8a926be935..e9c4d44eef9 100644 --- a/sql/2020/09_Performance/lighthouse_performace_audits.sql +++ b/sql/2020/09_Performance/lighthouse_performace_audits.sql @@ -26,7 +26,7 @@ SELECT COUNTIF(audits.score > 0) AS num_pages, COUNT(0) AS total, COUNTIF(audits.score > 0) / COUNT(0) AS pct, - APPROX_QUANTILES(audits.weight, 1000)[OFFSET(500)] AS median_weight, + APPROX_QUANTILES(audits.weight, 100)[OFFSET(50)] AS median_weight, MAX(audits.audit_group) AS audit_group, MAX(audits.description) AS description FROM diff --git a/sql/2020/09_Performance/median_lcp_score_by_month.sql b/sql/2020/09_Performance/median_lcp_score_by_month.sql index 736a5e039d7..dbb2a29d69d 100644 --- a/sql/2020/09_Performance/median_lcp_score_by_month.sql +++ b/sql/2020/09_Performance/median_lcp_score_by_month.sql @@ -9,7 +9,7 @@ FROM `chrome-ux-report.materialized.device_summary` WHERE date >= '2019-09-01' AND - date <= '2020-09-01' + date <= '2020-08-01' device IN ('desktop','phone') GROUP BY date, diff --git a/sql/2020/09_Performance/offline_origins.sql b/sql/2020/09_Performance/offline_origins.sql index 14fb8910a91..e8b45f46a4a 100644 --- a/sql/2020/09_Performance/offline_origins.sql +++ b/sql/2020/09_Performance/offline_origins.sql @@ -12,5 +12,5 @@ FROM ( FROM `chrome-ux-report.materialized.metrics_summary` WHERE - date = '2020-09-01' + date = '2020-08-01' ) \ No newline at end of file diff --git a/sql/2020/09_Performance/performance_observer.sql b/sql/2020/09_Performance/performance_observer.sql index 411df2ff2f1..5b3897c8b92 100644 --- a/sql/2020/09_Performance/performance_observer.sql +++ b/sql/2020/09_Performance/performance_observer.sql @@ -9,5 +9,5 @@ SELECT FROM `httparchive.blink_features.usage` WHERE - yyyymmdd = '20200901' AND + yyyymmdd = '20200801' AND feature = 'PerformanceObserverForWindow' \ No newline at end of file diff --git a/sql/2020/09_Performance/web_vitals_by_country.sql b/sql/2020/09_Performance/web_vitals_by_country.sql index e59f9baf483..e8d3f91d7e0 100644 --- a/sql/2020/09_Performance/web_vitals_by_country.sql +++ b/sql/2020/09_Performance/web_vitals_by_country.sql @@ -47,7 +47,7 @@ WITH FROM `chrome-ux-report.materialized.country_summary` WHERE - yyyymm = 202009 + yyyymm = 202008 GROUP BY origin, country_code diff --git a/sql/2020/09_Performance/web_vitals_by_device.sql b/sql/2020/09_Performance/web_vitals_by_device.sql index 5a23f15aa35..7e5bccb854b 100644 --- a/sql/2020/09_Performance/web_vitals_by_device.sql +++ b/sql/2020/09_Performance/web_vitals_by_device.sql @@ -48,7 +48,7 @@ WITH `chrome-ux-report.materialized.device_summary` WHERE device IN ('desktop','phone') - AND date = '2020-09-01' + AND date = '2020-08-01' ) SELECT diff --git a/sql/2020/09_Performance/web_vitals_by_ect.sql b/sql/2020/09_Performance/web_vitals_by_ect.sql index 7054e53c3fd..f326edb8c78 100644 --- a/sql/2020/09_Performance/web_vitals_by_ect.sql +++ b/sql/2020/09_Performance/web_vitals_by_ect.sql @@ -29,7 +29,7 @@ WITH first_contentful_paint, experimental.time_to_first_byte AS time_to_first_byte FROM - `chrome-ux-report.all.202009` + `chrome-ux-report.all.202008` ), cls AS ( SELECT diff --git a/sql/2020/09_Performance/web_vitals_distribution_by_device.sql b/sql/2020/09_Performance/web_vitals_distribution_by_device.sql index d3a70b45bad..9b9d6f3249b 100644 --- a/sql/2020/09_Performance/web_vitals_distribution_by_device.sql +++ b/sql/2020/09_Performance/web_vitals_distribution_by_device.sql @@ -30,7 +30,7 @@ WITH `chrome-ux-report.materialized.device_summary` WHERE device IN ('desktop','phone') AND - date = '2020-09-01' + date = '2020-08-01' ), fid AS ( SELECT From 706e35825c3fa4fa38a68acad82284bca0322fce Mon Sep 17 00:00:00 2001 From: Max Ostapenko Date: Sat, 10 Oct 2020 03:26:27 +0100 Subject: [PATCH 34/39] Update sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql Co-authored-by: Rick Viscomi --- sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql b/sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql index 26d2481f751..718993b9f62 100644 --- a/sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql +++ b/sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql @@ -13,7 +13,7 @@ FROM ( 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.2020_05_01_mobile` lh5 ON lh5.url=lh6.url + JOIN `httparchive.lighthouse.2019_07_01_mobile` lh5 ON lh5.url=lh6.url ) ), UNNEST([10, 25, 50, 75, 90]) AS percentile From 2df9022ad1b512bf29b4da8bfabee2ffe041f86d Mon Sep 17 00:00:00 2001 From: Max Ostapenko Date: Sat, 10 Oct 2020 03:26:51 +0100 Subject: [PATCH 35/39] Update sql/2020/09_Performance/lh6_vs_lh5_performance_score_02.sql Co-authored-by: Rick Viscomi --- sql/2020/09_Performance/lh6_vs_lh5_performance_score_02.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/2020/09_Performance/lh6_vs_lh5_performance_score_02.sql b/sql/2020/09_Performance/lh6_vs_lh5_performance_score_02.sql index 05e94f92ef4..0cd98215338 100644 --- a/sql/2020/09_Performance/lh6_vs_lh5_performance_score_02.sql +++ b/sql/2020/09_Performance/lh6_vs_lh5_performance_score_02.sql @@ -24,7 +24,7 @@ FROM ( 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.2020_05_01_mobile` lh5 ON lh5.url=lh6.url + JOIN `httparchive.lighthouse.2019_07_01_mobile` lh5 ON lh5.url=lh6.url ) ) -) \ No newline at end of file +) From b84733d4a2a4e85a7f1a5820013df790ccf317a7 Mon Sep 17 00:00:00 2001 From: Max Ostapenko Date: Sat, 10 Oct 2020 03:27:56 +0100 Subject: [PATCH 36/39] Update sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql Co-authored-by: Rick Viscomi --- sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql b/sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql index 718993b9f62..795fb51d75e 100644 --- a/sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql +++ b/sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql @@ -16,6 +16,6 @@ FROM ( JOIN `httparchive.lighthouse.2019_07_01_mobile` lh5 ON lh5.url=lh6.url ) ), -UNNEST([10, 25, 50, 75, 90]) AS percentile +UNNEST([0, 10, 25, 50, 75, 90, 100]) AS percentile GROUP BY percentile ORDER BY percentile From b6c5aef80ff940543e14e71406d275af17ef9ef1 Mon Sep 17 00:00:00 2001 From: Max Ostapenko Date: Sat, 10 Oct 2020 03:28:45 +0100 Subject: [PATCH 37/39] Update sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql Co-authored-by: Rick Viscomi --- sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql b/sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql index 795fb51d75e..6918f4b24a7 100644 --- a/sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql +++ b/sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql @@ -6,7 +6,7 @@ SELECT APPROX_QUANTILES(abs_perf_score_delta, 1000)[OFFSET(percentile * 10)] AS abs_perf_score_delta FROM ( SELECT - ABS(perf_score_lh6 - perf_score_lh5) AS abs_perf_score_delta + perf_score_lh6 - perf_score_lh5 AS perf_score_delta FROM ( SELECT From 4f6598a1bcec2ec036231c0d958110c240939c5b Mon Sep 17 00:00:00 2001 From: Max Ostapenko Date: Sat, 10 Oct 2020 12:37:14 +0100 Subject: [PATCH 38/39] added yesr comparison --- sql/2020/09_Performance/web_vitals_by_device.sql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sql/2020/09_Performance/web_vitals_by_device.sql b/sql/2020/09_Performance/web_vitals_by_device.sql index 7e5bccb854b..35d68fea79c 100644 --- a/sql/2020/09_Performance/web_vitals_by_device.sql +++ b/sql/2020/09_Performance/web_vitals_by_device.sql @@ -21,6 +21,7 @@ CREATE TEMP FUNCTION IS_NON_ZERO (good FLOAT64, needs_improvement FLOAT64, poor WITH base AS ( SELECT + date,   origin, device, @@ -48,10 +49,11 @@ WITH `chrome-ux-report.materialized.device_summary` WHERE device IN ('desktop','phone') - AND date = '2020-08-01' + AND date IN ('2019-08-01', '2020-08-01') ) SELECT + date,   device, COUNT(DISTINCT origin) AS total_origins, @@ -149,4 +151,5 @@ SELECT FROM base GROUP BY + date,   device \ No newline at end of file From b91ce5c46550b070af4b314d76bdc528f2927cb5 Mon Sep 17 00:00:00 2001 From: Max Ostapenko Date: Sat, 10 Oct 2020 15:45:11 +0100 Subject: [PATCH 39/39] linting --- .../09_Performance/lh6_vs_lh5_performance_score_01.sql | 2 +- sql/2020/09_Performance/median_lcp_score_by_month.sql | 8 ++++---- sql/2020/09_Performance/offline_origins.sql | 2 +- sql/2020/09_Performance/performance_observer.sql | 2 +- sql/2020/09_Performance/web_vitals_by_country.sql | 2 +- sql/2020/09_Performance/web_vitals_by_device.sql | 2 +- sql/2020/09_Performance/web_vitals_by_ect.sql | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql b/sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql index 6918f4b24a7..12f01f17354 100644 --- a/sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql +++ b/sql/2020/09_Performance/lh6_vs_lh5_performance_score_01.sql @@ -3,7 +3,7 @@ SELECT percentile, - APPROX_QUANTILES(abs_perf_score_delta, 1000)[OFFSET(percentile * 10)] AS abs_perf_score_delta + APPROX_QUANTILES(perf_score_delta, 1000)[OFFSET(percentile * 10)] AS perf_score_delta FROM ( SELECT perf_score_lh6 - perf_score_lh5 AS perf_score_delta diff --git a/sql/2020/09_Performance/median_lcp_score_by_month.sql b/sql/2020/09_Performance/median_lcp_score_by_month.sql index dbb2a29d69d..58afc6fc359 100644 --- a/sql/2020/09_Performance/median_lcp_score_by_month.sql +++ b/sql/2020/09_Performance/median_lcp_score_by_month.sql @@ -8,9 +8,9 @@ SELECT FROM `chrome-ux-report.materialized.device_summary` WHERE - date >= '2019-09-01' AND - date <= '2020-08-01' - device IN ('desktop','phone') + date >= '2019-09-01' + AND date <= '2020-08-01' + AND device IN ('desktop','phone') GROUP BY date, - device \ No newline at end of file + device diff --git a/sql/2020/09_Performance/offline_origins.sql b/sql/2020/09_Performance/offline_origins.sql index e8b45f46a4a..9085802995a 100644 --- a/sql/2020/09_Performance/offline_origins.sql +++ b/sql/2020/09_Performance/offline_origins.sql @@ -13,4 +13,4 @@ FROM ( `chrome-ux-report.materialized.metrics_summary` WHERE date = '2020-08-01' -) \ No newline at end of file +) diff --git a/sql/2020/09_Performance/performance_observer.sql b/sql/2020/09_Performance/performance_observer.sql index 5b3897c8b92..d9c410a28d0 100644 --- a/sql/2020/09_Performance/performance_observer.sql +++ b/sql/2020/09_Performance/performance_observer.sql @@ -10,4 +10,4 @@ FROM `httparchive.blink_features.usage` WHERE yyyymmdd = '20200801' AND - feature = 'PerformanceObserverForWindow' \ No newline at end of file + feature = 'PerformanceObserverForWindow' diff --git a/sql/2020/09_Performance/web_vitals_by_country.sql b/sql/2020/09_Performance/web_vitals_by_country.sql index e8d3f91d7e0..d80b7f328f1 100644 --- a/sql/2020/09_Performance/web_vitals_by_country.sql +++ b/sql/2020/09_Performance/web_vitals_by_country.sql @@ -151,4 +151,4 @@ SELECT FROM base GROUP BY -  country \ No newline at end of file +  country diff --git a/sql/2020/09_Performance/web_vitals_by_device.sql b/sql/2020/09_Performance/web_vitals_by_device.sql index 35d68fea79c..c801161bfbc 100644 --- a/sql/2020/09_Performance/web_vitals_by_device.sql +++ b/sql/2020/09_Performance/web_vitals_by_device.sql @@ -152,4 +152,4 @@ FROM base GROUP BY date, -  device \ No newline at end of file +  device diff --git a/sql/2020/09_Performance/web_vitals_by_ect.sql b/sql/2020/09_Performance/web_vitals_by_ect.sql index f326edb8c78..8dd4ce812b8 100644 --- a/sql/2020/09_Performance/web_vitals_by_ect.sql +++ b/sql/2020/09_Performance/web_vitals_by_ect.sql @@ -256,4 +256,4 @@ SELECT FROM granular_metrics GROUP BY - network \ No newline at end of file + network