From b806458c2feb7d9cc90975c0fc4316bc32f57721 Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 29 Aug 2021 13:34:59 +0100 Subject: [PATCH] Small H2 query improvement --- sql/timeseries/h2.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/timeseries/h2.sql b/sql/timeseries/h2.sql index 9c4767d..26d4da1 100644 --- a/sql/timeseries/h2.sql +++ b/sql/timeseries/h2.sql @@ -3,9 +3,9 @@ SELECT SUBSTR(_TABLE_SUFFIX, 0, 10) AS date, UNIX_DATE(CAST(REPLACE(SUBSTR(_TABLE_SUFFIX, 0, 10), '_', '-') AS DATE)) * 1000 * 60 * 60 * 24 AS timestamp, IF(ENDS_WITH(_TABLE_SUFFIX, 'desktop'), 'desktop', 'mobile') AS client, - ROUND(SUM(IF(JSON_EXTRACT_SCALAR(payload, '$._protocol') = 'HTTP/2', 1, 0)) * 100 / COUNT(0), 2) AS percent + ROUND(SUM(IF(protocol = 'HTTP/2', 1, 0)) * 100 / COUNT(0), 2) AS percent FROM - (SELECT page AS url, payload, _TABLE_SUFFIX AS _TABLE_SUFFIX FROM `httparchive.requests.*`) + (SELECT page AS url, JSON_EXTRACT_SCALAR(payload, '$._protocol') AS protocol, _TABLE_SUFFIX AS _TABLE_SUFFIX FROM `httparchive.requests.*`) GROUP BY date, timestamp,