When I remove the constants and use a subquery like below, it times out.
SELECT v.type d, ARRAY_AGG({"v":v})[1:5] l
FROM `my-db` v
WHERE v.type IN (select distinct type from `my-db`)
GROUP BY v.type
;
I am guessing its an indexing issue? Have a new post on this here.