Skip to content

Commit eb051e0

Browse files
authored
Additional Performance 2022 queries (#3206)
* render blocking * desktop render-blocking * additional queries * lcp loading stats * linter * lcp wasted bytes * updates * tbt and long tasks * fix viewport audit * 🥱 * cls queries * last one!!
1 parent df65073 commit eb051e0

24 files changed

Lines changed: 831 additions & 45 deletions
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
CREATE TEMP FUNCTION HAS_NO_STORE_DIRECTIVE(cache_control STRING) RETURNS BOOL AS (
2+
REGEXP_CONTAINS(cache_control, r'(?i)\bno-store\b')
3+
);
4+
5+
WITH requests AS (
6+
SELECT
7+
client,
8+
rank,
9+
LOGICAL_OR(HAS_NO_STORE_DIRECTIVE(JSON_VALUE(payload, '$._cacheControl'))) AS includes_ccns
10+
FROM
11+
`httparchive.almanac.summary_response_bodies`
12+
WHERE
13+
date = '2022-06-01' AND
14+
firstHtml
15+
GROUP BY
16+
client,
17+
rank,
18+
page
19+
)
20+
21+
SELECT
22+
client,
23+
_rank AS rank,
24+
COUNTIF(includes_ccns) AS pages,
25+
COUNT(0) AS total,
26+
COUNTIF(includes_ccns) / COUNT(0) AS pct
27+
FROM
28+
requests,
29+
UNNEST([1000, 10000, 100000, 1000000, 10000000]) AS _rank
30+
WHERE
31+
rank <= _rank
32+
GROUP BY
33+
client,
34+
rank
35+
ORDER BY
36+
rank,
37+
client
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
WITH lh AS (
2+
SELECT
3+
_TABLE_SUFFIX AS client,
4+
url AS page,
5+
JSON_VALUE(report, '$.audits.no-unload-listeners.score') = '0' AS has_unload
6+
FROM
7+
`httparchive.lighthouse.2022_06_01_*`
8+
),
9+
10+
pages AS (
11+
SELECT
12+
_TABLE_SUFFIX AS client,
13+
url AS page,
14+
rank
15+
FROM
16+
`httparchive.summary_pages.2022_06_01_*`
17+
)
18+
19+
20+
SELECT
21+
client,
22+
_rank AS rank,
23+
COUNTIF(has_unload) AS pages,
24+
COUNT(0) AS total,
25+
COUNTIF(has_unload) / COUNT(0) AS pct
26+
FROM
27+
lh
28+
JOIN
29+
pages
30+
USING
31+
(client, page),
32+
UNNEST([1000, 10000, 100000, 1000000, 10000000]) AS _rank
33+
WHERE
34+
rank <= _rank
35+
GROUP BY
36+
client,
37+
rank
38+
ORDER BY
39+
rank,
40+
client
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
WITH lh AS (
2+
SELECT
3+
_TABLE_SUFFIX AS client,
4+
ARRAY_LENGTH(JSON_QUERY_ARRAY(report, '$.audits.non-composited-animations.details.items')) AS num_animations
5+
FROM
6+
`httparchive.lighthouse.2022_06_01_*`
7+
)
8+
9+
10+
SELECT
11+
percentile,
12+
client,
13+
APPROX_QUANTILES(num_animations, 1000)[OFFSET(percentile * 10)] AS num_animations,
14+
COUNTIF(num_animations > 0) AS pages,
15+
COUNT(0) AS total,
16+
COUNTIF(num_animations > 0) / COUNT(0) AS pct
17+
FROM
18+
lh,
19+
UNNEST([10, 25, 50, 75, 90, 100]) AS percentile
20+
GROUP BY
21+
percentile,
22+
client
23+
ORDER BY
24+
percentile,
25+
client
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
WITH lh AS (
2+
SELECT
3+
_TABLE_SUFFIX AS client,
4+
CAST(JSON_VALUE(unsized_image, '$.node.boundingRect.height') AS INT64) AS height
5+
FROM
6+
`httparchive.lighthouse.2022_06_01_*`,
7+
UNNEST(JSON_QUERY_ARRAY(report, '$.audits.unsized-images.details.items')) AS unsized_image
8+
)
9+
10+
11+
SELECT
12+
percentile,
13+
client,
14+
APPROX_QUANTILES(height, 1000)[OFFSET(percentile * 10)] AS height,
15+
COUNT(0) AS unsized_images
16+
FROM
17+
lh,
18+
UNNEST([10, 25, 50, 75, 90, 100]) AS percentile
19+
GROUP BY
20+
percentile,
21+
client
22+
ORDER BY
23+
percentile,
24+
client
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
WITH lh AS (
2+
SELECT
3+
_TABLE_SUFFIX AS client,
4+
ARRAY_LENGTH(JSON_QUERY_ARRAY(report, '$.audits.unsized-images.details.items')) AS num_unsized_images
5+
FROM
6+
`httparchive.lighthouse.2022_06_01_*`
7+
)
8+
9+
10+
SELECT
11+
percentile,
12+
client,
13+
APPROX_QUANTILES(num_unsized_images, 1000)[OFFSET(percentile * 10)] AS num_unsized_images,
14+
COUNTIF(num_unsized_images > 0) AS pages,
15+
COUNT(0) AS total,
16+
COUNTIF(num_unsized_images > 0) / COUNT(0) AS pct
17+
FROM
18+
lh,
19+
UNNEST([10, 25, 50, 75, 90, 100]) AS percentile
20+
GROUP BY
21+
percentile,
22+
client
23+
ORDER BY
24+
percentile,
25+
client
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
WITH long_tasks AS (
2+
SELECT
3+
_TABLE_SUFFIX AS client,
4+
url AS page,
5+
CAST(JSON_QUERY(item, '$.duration') AS FLOAT64) AS long_task_duration
6+
FROM
7+
`lighthouse.2022_06_01_*`,
8+
UNNEST(JSON_QUERY_ARRAY(report, '$.audits.long-tasks.details.items')) AS item
9+
),
10+
11+
per_page AS (
12+
SELECT
13+
client,
14+
page,
15+
SUM(long_task_duration) AS long_tasks
16+
FROM
17+
long_tasks
18+
GROUP BY
19+
client,
20+
page
21+
)
22+
23+
SELECT
24+
percentile,
25+
client,
26+
APPROX_QUANTILES(long_tasks, 1000)[OFFSET(percentile * 10)] AS long_tasks
27+
FROM
28+
per_page,
29+
UNNEST([10, 25, 50, 75, 90, 100]) AS percentile
30+
GROUP BY
31+
percentile,
32+
client
33+
ORDER BY
34+
percentile,
35+
client

sql/2022/performance/fid_tbt.sql

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
SELECT
2+
percentile,
3+
_TABLE_SUFFIX AS client,
4+
APPROX_QUANTILES(CAST(JSON_QUERY(report, '$.audits.total-blocking-time.numericValue') AS FLOAT64), 1000)[OFFSET(percentile * 10)] AS tbt
5+
FROM
6+
`httparchive.lighthouse.2022_06_01_*`,
7+
UNNEST([10, 25, 50, 75, 90, 100]) AS percentile
8+
GROUP BY
9+
percentile,
10+
client
11+
ORDER BY
12+
percentile,
13+
client
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
WITH pages AS (
2+
SELECT
3+
_TABLE_SUFFIX AS client,
4+
CAST(JSON_VALUE(payload, '$._metadata.page_id') AS INT64) AS pageid,
5+
JSON_VALUE(payload, '$._performance.lcp_elem_stats.url') AS url
6+
FROM
7+
`httparchive.pages.2022_06_01_*`
8+
),
9+
10+
requests AS (
11+
SELECT
12+
_TABLE_SUFFIX AS client,
13+
pageid,
14+
url,
15+
respSize / 1024 AS kbytes
16+
FROM
17+
`httparchive.summary_requests.2022_06_01_*`
18+
)
19+
20+
SELECT
21+
percentile,
22+
client,
23+
APPROX_QUANTILES(kbytes, 1000)[OFFSET(percentile * 10)] AS kbytes
24+
FROM
25+
pages
26+
JOIN
27+
requests
28+
USING
29+
(client, pageid, url),
30+
UNNEST([10, 25, 50, 75, 90, 100]) AS percentile
31+
GROUP BY
32+
percentile,
33+
client
34+
ORDER BY
35+
percentile,
36+
client
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
WITH pages AS (
2+
SELECT
3+
_TABLE_SUFFIX AS client,
4+
CAST(JSON_VALUE(payload, '$._metadata.page_id') AS INT64) AS pageid,
5+
JSON_VALUE(payload, '$._performance.lcp_elem_stats.url') AS url
6+
FROM
7+
`httparchive.pages.2022_06_01_*`
8+
),
9+
10+
requests AS (
11+
SELECT
12+
_TABLE_SUFFIX AS client,
13+
pageid,
14+
url,
15+
respSize / 1024 AS kbytes
16+
FROM
17+
`httparchive.summary_requests.2022_06_01_*`
18+
)
19+
20+
SELECT
21+
client,
22+
IF(CEILING(kbytes / 100) * 100 < 1000, CAST(CEILING(kbytes / 100) * 100 AS STRING), '1000+') AS kbytes,
23+
COUNT(0) AS freq,
24+
SUM(COUNT(0)) OVER (PARTITION BY client) AS total,
25+
COUNT(0) / SUM(COUNT(0)) OVER (PARTITION BY client) AS pct
26+
FROM
27+
pages
28+
JOIN
29+
requests
30+
USING
31+
(client, pageid, url)
32+
GROUP BY
33+
client,
34+
kbytes
35+
ORDER BY
36+
client,
37+
kbytes

sql/2022/performance/lcp_discoverability.sql

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)