Skip to content

Commit d07751d

Browse files
Performance 2025 Queries (Part 2) (#4292)
* speculation_rules_rank.sql * early_hints_usage_rank.sql * early_hints_usage_trends.sql * Add total columns to speculation_rules_rank.sql --------- Co-authored-by: Barry Pollard <barrypollard@google.com>
1 parent 9b46601 commit d07751d

File tree

3 files changed

+95
-0
lines changed

3 files changed

+95
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#standardSQL
2+
# Early Hints (HTTP 103) usage by site rank
3+
# Measures the percentage of sites using early hints at different popularity ranks
4+
5+
SELECT
6+
IF(ranking < 100000000, CAST(ranking AS STRING), 'all') AS ranking,
7+
r.client,
8+
COUNT(DISTINCT r.page) AS total_sites,
9+
COUNTIF(JSON_QUERY_ARRAY(r.payload._early_hint_headers) IS NOT NULL) AS sites_with_early_hints,
10+
COUNTIF(JSON_QUERY_ARRAY(r.payload._early_hint_headers) IS NOT NULL) / COUNT(DISTINCT r.page) AS pct_early_hints
11+
FROM
12+
`httparchive.crawl.requests` r
13+
JOIN
14+
`httparchive.crawl.pages` p
15+
ON
16+
r.page = p.page AND
17+
r.client = p.client AND
18+
r.date = p.date,
19+
UNNEST([1000, 10000, 100000, 1000000, 10000000, 100000000]) AS ranking
20+
WHERE
21+
r.date = '2025-07-01' AND
22+
r.is_main_document AND
23+
r.is_root_page AND
24+
p.is_root_page AND
25+
p.rank <= ranking
26+
GROUP BY
27+
ranking,
28+
r.client
29+
ORDER BY
30+
ranking,
31+
r.client
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#standardSQL
2+
# Early Hints (HTTP 103) adoption trend over time
3+
# Shows usage by client (mobile, desktop) across years
4+
5+
SELECT
6+
r.client AS client,
7+
r.date AS date,
8+
COUNTIF(
9+
JSON_QUERY_ARRAY(r.payload._early_hint_headers) IS NOT NULL AND
10+
ARRAY_LENGTH(JSON_QUERY_ARRAY(r.payload._early_hint_headers)) > 0
11+
) AS sites,
12+
COUNT(0) AS total,
13+
COUNTIF(
14+
JSON_QUERY_ARRAY(r.payload._early_hint_headers) IS NOT NULL AND
15+
ARRAY_LENGTH(JSON_QUERY_ARRAY(r.payload._early_hint_headers)) > 0
16+
) / COUNT(0) AS pct
17+
FROM
18+
`httparchive.crawl.requests` r
19+
JOIN
20+
`httparchive.crawl.pages` p
21+
ON
22+
r.page = p.page AND
23+
r.client = p.client AND
24+
r.date = p.date
25+
WHERE
26+
r.date IN ('2023-07-01', '2024-07-01', '2025-07-01') AND
27+
r.is_main_document AND
28+
r.is_root_page AND
29+
p.is_root_page
30+
GROUP BY
31+
r.client,
32+
r.date
33+
ORDER BY
34+
r.client,
35+
r.date
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
SELECT
2+
IF(ranking < 100000000, CAST(ranking AS STRING), 'all') AS ranking,
3+
client,
4+
COUNT(DISTINCT page) AS total_sites,
5+
COUNTIF(
6+
custom_metrics.performance.speculation_rules IS NOT NULL AND (
7+
ARRAY_LENGTH(JSON_QUERY_ARRAY(custom_metrics.performance.speculation_rules.htmlRules)) > 0 OR
8+
ARRAY_LENGTH(JSON_QUERY_ARRAY(custom_metrics.performance.speculation_rules.httpHeaderRules)) > 0
9+
)
10+
) AS sites_with_speculation_rules,
11+
COUNTIF(
12+
custom_metrics.performance.speculation_rules IS NOT NULL AND (
13+
ARRAY_LENGTH(JSON_QUERY_ARRAY(custom_metrics.performance.speculation_rules.htmlRules)) > 0 OR
14+
ARRAY_LENGTH(JSON_QUERY_ARRAY(custom_metrics.performance.speculation_rules.httpHeaderRules)) > 0
15+
)
16+
) / COUNT(DISTINCT page) AS pct_speculation_rules
17+
FROM
18+
`httparchive.crawl.pages`,
19+
UNNEST([1000, 10000, 100000, 1000000, 10000000, 100000000]) AS ranking
20+
WHERE
21+
date = '2025-07-01' AND
22+
is_root_page AND
23+
rank <= ranking
24+
GROUP BY
25+
ranking,
26+
client
27+
ORDER BY
28+
ranking,
29+
client

0 commit comments

Comments
 (0)