Hello all,So i am not sure why this is happening but when I execute this code everything is fine and it returns quicklyselect distinct x.ref, count(x.id)as leads, sum(case x.doubleoptin when '1' then 1 when '0' then 0 end) as DoubleOptin, sum(case x.bademail when '1' then 1 when '0' then 0 end) as bademails, count(C.adid) as ClickActivity from signups x left outer join advertsclickedbyuser c on c.userid = x.sessionid where x.signupsite = '1111' and x.firstname is not null group by x.ref order by leads desc
but when I try to add a date range to it, it slows way down... it got up to 8 min of executing time before i just cancelled itselect distinct x.ref, count(x.id)as leads, sum(case x.doubleoptin when '1' then 1 when '0' then 0 end) as DoubleOptin, sum(case x.bademail when '1' then 1 when '0' then 0 end) as bademails, count(C.adid) as ClickActivity from signups x left outer join advertsclickedbyuser c on c.userid = x.sessionid where x.signupsite = '1111' and x.signupdate > '2010/1/1' and x.signupdate < '2010/1/10' and x.firstname is not null group by x.ref order by leads desc
I tried a few things like changing From signups to a select statement so that it was like from (select * from signups where "daterange") but the execution time was still extremely long.Does anyone have any ideas?Thanks and much appreciated