In the following query
SELECT
count(DISTINCT userId)
FROM default
WHERE
type='Order'
AND
clientId='06b08cf7-6810-4e7d-a025-c3488f2f8398'
I have index to cover it
CREATE idx1 ON default(clientId, userId) WHERE type='Order';
How long you expect to count 5 million results? for me it take 1 minute