Well I did this query in order to return true if there’s a coicidence on my bucket:
SELECT RAW CASE COUNT(1)
WHEN 1 THEN TRUE
ELSE FALSE
END
FROM `Bucket_XXX` AS b
WHERE b.type="donut"
AND b.deleted = false
LIMIT 1;
Well I’m trying to use the count in order to return true if there’s a coicidence but it always return false, althought the query is working normal only with the select
SELECT RAW CASE COUNT(1) WHEN 1 THEN TRUE ELSE FALSE END FROM [{"a":1}] AS d WHERE d.a = 1;
Simplified one will be
SELECT RAW COUNT(1) == 1 FROM [{"a":1}] AS d WHERE d.a = 1;
Count is aggregate, can you tell me how using and what not working.
Aggregate means it need to process all the qualified documents, LIMIT 1 applied on aggregated results.
Is the following helpful.
EXISTS(SELECT RAW 1
FROM `Bucket_XXX` AS b
WHERE b.type="donut" AND b.deleted = false
LIMIT 1)
I see the issue seems to be that it need to process all the qualified documents, so in this case I need a query to check if there’s at least one coicidence in order to return true; is it possible to not evaluate all the coicidences? in order to optimize it?