I have a simple select distinct on some time series data:
SELECT DISTINCT user_id
FROM events
WHERE project_id = 6
AND time > '2015-01-11 8:00:00'
AND time < '2015-02-10 8:00:00';
And it takes 112 seconds. Here’s the query plan:
http://explain.depesz.com/s/NTyA
My application has to preform a lot of distinct operations and counts like this. Is there a faster way to get this kind of data?