diff --git a/sql/2021/performance/lighthouse_audits_corr_with_cwv.sql b/sql/2021/performance/lighthouse_audits_corr_with_cwv.sql new file mode 100644 index 00000000000..176245790f9 --- /dev/null +++ b/sql/2021/performance/lighthouse_audits_corr_with_cwv.sql @@ -0,0 +1,158 @@ +# standardSQL +# Correlation between various lighthouse audits and core web vitals + +SELECT + CORR(CAST(JSON_QUERY(report, + '$.audits.first-contentful-paint.numericValue') AS FLOAT64), + CAST(JSON_QUERY(report, + '$.audits.server-response-time.numericValue') AS FLOAT64)) AS first_contentful_paint_on_server_response_time_score, + CORR(CAST(JSON_QUERY(report, + '$.audits.first-contentful-paint.numericValue') AS FLOAT64), + CAST(JSON_QUERY(report, + '$.audits.render-blocking-resources.numericValue') AS FLOAT64)) AS first_contentful_paint_on_render_blocking_resources_score, + CORR(CAST(JSON_QUERY(report, + '$.audits.first-contentful-paint.numericValue') AS FLOAT64), + CAST(JSON_QUERY(report, + '$.audits.redirects.numericValue') AS FLOAT64)) AS first_contentful_paint_on_redirects_score, + CORR(CAST(JSON_QUERY(report, + '$.audits.first-contentful-paint.numericValue') AS FLOAT64), + CAST(JSON_QUERY(report, + '$.audits.critical-request-chains.numericValue') AS FLOAT64)) AS first_contentful_paint_on_critical_request_chains_score, + CORR(CAST(JSON_QUERY(report, + '$.audits.first-contentful-paint.numericValue') AS FLOAT64), + CAST(JSON_QUERY(report, + '$.audits.uses-text-compression.numericValue') AS FLOAT64)) AS first_contentful_paint_on_uses_text_compression_score, + CORR(CAST(JSON_QUERY(report, + '$.audits.first-contentful-paint.numericValue') AS FLOAT64), + CAST(JSON_QUERY(report, + '$.audits.uses-rel-preconnect.numericValue') AS FLOAT64)) AS first_contentful_paint_on_uses_rel_preconnect_score, + CORR(CAST(JSON_QUERY(report, + '$.audits.first-contentful-paint.numericValue') AS FLOAT64), + CAST(JSON_QUERY(report, + '$.audits.uses-rel-preload.numericValue') AS FLOAT64)) AS first_contentful_paint_on_uses_rel_preload_score, + CORR(CAST(JSON_QUERY(report, + '$.audits.first-contentful-paint.numericValue') AS FLOAT64), + CAST(JSON_QUERY(report, + '$.audits.font-display.numericValue') AS FLOAT64)) AS first_contentful_paint_on_font_display_score, + CORR(CAST(JSON_QUERY(report, + '$.audits.first-contentful-paint.numericValue') AS FLOAT64), + CAST(JSON_QUERY(report, + '$.audits.unminified-javascript.numericValue') AS FLOAT64)) AS first_contentful_paint_on_unminified_javascript_score, + CORR(CAST(JSON_QUERY(report, + '$.audits.first-contentful-paint.numericValue') AS FLOAT64), + CAST(JSON_QUERY(report, + '$.audits.unminified-css.numericValue') AS FLOAT64)) AS first_contentful_paint_on_unminified_css_score, + CORR(CAST(JSON_QUERY(report, + '$.audits.first-contentful-paint.numericValue') AS FLOAT64), + CAST(JSON_QUERY(report, + '$.audits.unused-css-rules.numericValue') AS FLOAT64)) AS first_contentful_paint_on_unused_css_rules_score, + CORR(CAST(JSON_QUERY(report, + '$.audits.largest-contentful-paint.numericValue') AS FLOAT64), + CAST(JSON_QUERY(report, + '$.audits.server-response-time.numericValue') AS FLOAT64)) AS largest_contentful_paint_on_server_response_time_score, + CORR(CAST(JSON_QUERY(report, + '$.audits.largest-contentful-paint.numericValue') AS FLOAT64), + CAST(JSON_QUERY(report, + '$.audits.render-blocking-resources.numericValue') AS FLOAT64)) AS largest_contentful_paint_on_render_blocking_resources_score, + CORR(CAST(JSON_QUERY(report, + '$.audits.largest-contentful-paint.numericValue') AS FLOAT64), + CAST(JSON_QUERY(report, + '$.audits.redirects.numericValue') AS FLOAT64)) AS largest_contentful_paint_on_redirects_score, + CORR(CAST(JSON_QUERY(report, + '$.audits.largest-contentful-paint.numericValue') AS FLOAT64), + CAST(JSON_QUERY(report, + '$.audits.critical-request-chains.numericValue') AS FLOAT64)) AS largest_contentful_paint_on_critical_request_chains_score, + CORR(CAST(JSON_QUERY(report, + '$.audits.largest-contentful-paint.numericValue') AS FLOAT64), + CAST(JSON_QUERY(report, + '$.audits.uses-text-compression.numericValue') AS FLOAT64)) AS largest_contentful_paint_on_uses_text_compression_score, + CORR(CAST(JSON_QUERY(report, + '$.audits.largest-contentful-paint.numericValue') AS FLOAT64), + CAST(JSON_QUERY(report, + '$.audits.uses-rel-preconnect.numericValue') AS FLOAT64)) AS largest_contentful_paint_on_uses_rel_preconnect_score, + CORR(CAST(JSON_QUERY(report, + '$.audits.largest-contentful-paint.numericValue') AS FLOAT64), + CAST(JSON_QUERY(report, + '$.audits.uses-rel-preload.numericValue') AS FLOAT64)) AS largest_contentful_paint_on_uses_rel_preload_score, + CORR(CAST(JSON_QUERY(report, + '$.audits.largest-contentful-paint.numericValue') AS FLOAT64), + CAST(JSON_QUERY(report, + '$.audits.font-display.numericValue') AS FLOAT64)) AS largest_contentful_paint_on_font_display_score, + CORR(CAST(JSON_QUERY(report, + '$.audits.largest-contentful-paint.numericValue') AS FLOAT64), + CAST(JSON_QUERY(report, + '$.audits.unminified-javascript.numericValue') AS FLOAT64)) AS largest_contentful_paint_on_unminified_javascript_score, + CORR(CAST(JSON_QUERY(report, + '$.audits.largest-contentful-paint.numericValue') AS FLOAT64), + CAST(JSON_QUERY(report, + '$.audits.unminified-css.numericValue') AS FLOAT64)) AS largest_contentful_paint_on_unminified_css_score, + CORR(CAST(JSON_QUERY(report, + '$.audits.largest-contentful-paint.numericValue') AS FLOAT64), + CAST(JSON_QUERY(report, + '$.audits.unused-css-rules.numericValue') AS FLOAT64)) AS largest_contentful_paint_on_unused_css_rules_score, + CORR(CAST(JSON_QUERY(report, + '$.audits.largest-contentful-paint.numericValue') AS FLOAT64), + CAST(JSON_QUERY(report, + '$.audits.largest-contentful-paint-element.numericValue') AS FLOAT64)) AS largest_contentful_paint_on_largest_contentful_paint_element_score, + CORR(CAST(JSON_QUERY(report, + '$.audits.largest-contentful-paint.numericValue') AS FLOAT64), + CAST(JSON_QUERY(report, + '$.audits.preload-lcp-image.numericValue') AS FLOAT64)) AS largest_contentful_paint_on_preload_lcp_image_score, + CORR(CAST(JSON_QUERY(report, + '$.audits.largest-contentful-paint.numericValue') AS FLOAT64), + CAST(JSON_QUERY(report, + '$.audits.unused-javascript.numericValue') AS FLOAT64)) AS largest_contentful_paint_on_unused_javascript_score, + CORR(CAST(JSON_QUERY(report, + '$.audits.largest-contentful-paint.numericValue') AS FLOAT64), + CAST(JSON_QUERY(report, + '$.audits.efficient-animated-content.numericValue') AS FLOAT64)) AS largest_contentful_paint_on_efficient_animated_content_score, + CORR(CAST(JSON_QUERY(report, + '$.audits.largest-contentful-paint.numericValue') AS FLOAT64), + CAST(JSON_QUERY(report, + '$.audits.total-byte-weight.numericValue') AS FLOAT64)) AS largest_contentful_paint_on_total_byte_weight_score, + CORR(CAST(JSON_QUERY(report, + '$.audits.total-blocking-time.numericValue') AS FLOAT64), + CAST(JSON_QUERY(report, + '$.audits.long-tasks.numericValue') AS FLOAT64)) AS total_blocking_time_on_long_tasks_score, + CORR(CAST(JSON_QUERY(report, + '$.audits.total-blocking-time.numericValue') AS FLOAT64), + CAST(JSON_QUERY(report, + '$.audits.third-party-summary.numericValue') AS FLOAT64)) AS total_blocking_time_on_third_party_summary_score, + CORR(CAST(JSON_QUERY(report, + '$.audits.total-blocking-time.numericValue') AS FLOAT64), + CAST(JSON_QUERY(report, + '$.audits.third-party-facades.numericValue') AS FLOAT64)) AS total_blocking_time_on_third_party_facades_score, + CORR(CAST(JSON_QUERY(report, + '$.audits.total-blocking-time.numericValue') AS FLOAT64), + CAST(JSON_QUERY(report, + '$.audits.bootup-time.numericValue') AS FLOAT64)) AS total_blocking_time_on_bootup_time_score, + CORR(CAST(JSON_QUERY(report, + '$.audits.total-blocking-time.numericValue') AS FLOAT64), + CAST(JSON_QUERY(report, + '$.audits.mainthread-work-breakdown.numericValue') AS FLOAT64)) AS total_blocking_time_on_mainthread_work_breakdown_score, + CORR(CAST(JSON_QUERY(report, + '$.audits.total-blocking-time.numericValue') AS FLOAT64), + CAST(JSON_QUERY(report, + '$.audits.dom-size.numericValue') AS FLOAT64)) AS total_blocking_time_on_dom_size_score, + CORR(CAST(JSON_QUERY(report, + '$.audits.total-blocking-time.numericValue') AS FLOAT64), + CAST(JSON_QUERY(report, + '$.audits.duplicated-javascript.numericValue') AS FLOAT64)) AS total_blocking_time_on_duplicated_javascript_score, + CORR(CAST(JSON_QUERY(report, + '$.audits.total-blocking-time.numericValue') AS FLOAT64), + CAST(JSON_QUERY(report, + '$.audits.legacy-javascript.numericValue') AS FLOAT64)) AS total_blocking_time_on_legacy_javascript_score, + CORR(CAST(JSON_QUERY(report, + '$.audits.cumulative-layout-shift.numericValue') AS FLOAT64), + CAST(JSON_QUERY(report, + '$.audits.layout-shift-elements.numericValue') AS FLOAT64)) AS cumulative_layout_shift_on_layout_shift_elements_score, + CORR(CAST(JSON_QUERY(report, + '$.audits.cumulative-layout-shift.numericValue') AS FLOAT64), + CAST(JSON_QUERY(report, + '$.audits.non-composited-animations.numericValue') AS FLOAT64)) AS cumulative_layout_shift_on_non_composited_animations_score, + CORR(CAST(JSON_QUERY(report, + '$.audits.cumulative-layout-shift.numericValue') AS FLOAT64), + CAST(JSON_QUERY(report, + '$.audits.unsized-images.numericValue') AS FLOAT64)) AS cumulative_layout_shift_on_unsized_images_score +FROM + `httparchive.sample_data.lighthouse_mobile_10k` \ No newline at end of file diff --git a/sql/2021/performance/unused_css_js.sql b/sql/2021/performance/unused_css_js.sql index 3302003b03f..835fb69c2cd 100644 --- a/sql/2021/performance/unused_css_js.sql +++ b/sql/2021/performance/unused_css_js.sql @@ -1,5 +1,6 @@ +# standardSQL +# Distribution of unused CSS and JS --- credits: https://github.com/HTTPArchive/almanac.httparchive.org/blob/main/sql/2020/javascript/unused_js_bytes_distribution.sql SELECT percentile, APPROX_QUANTILES(CAST(JSON_EXTRACT_SCALAR(report, "$.audits.unused-javascript.details.overallSavingsBytes") AS INT64) / 1024, 1000)[OFFSET(percentile * 10)] AS js_kilobytes,