Need to find COUNT OF unique user accounts from table for last 5 months, this table contains millions of data.
select COUNT(distinct(account)) as total_unique,
COUNT(distinct(IF( Column1!=0 OR Column2!=0, account, null)))
from table_name where date(event_date) >= date('2014-04-01') and date(event_date) <=date('2014-08-31');
This query currently consuming more than 10 mins to get the data. We have indexes on 'event_date' column and on 'account' column in this table. We are using mysql as DB. Could you please help us.