On Jul 22, 2015, at 11:27 PM, Mohit Sindhwani <[email protected]> wrote: > > Hi Scott, > > On 23/7/2015 11:54 AM, Scott Ribe wrote: >> On Jul 22, 2015, at 9:10 PM, Mohit Sindhwani <[email protected]> wrote: >>> We have tried this and the query is quite a bit slower. Filtering to the >>> last 900k records before doing the recorded_on part helped speed it up. >> I don't understand how that could possibly be the case if there's an index >> on recorded_on. > > Because it was the count(distinct x) that was the problem :) > Doing only a count(*) is faster without the subquery... and is what we have > switched to.
So does the limit reduce it to less than 1 day's rows? -- Scott Ribe [email protected] http://www.elevated-dev.com/ https://www.linkedin.com/in/scottribe/ (303) 722-0567 voice -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/A236FA86-7AAE-420C-B45C-5AB0A8C484D3%40elevated-dev.com. For more options, visit https://groups.google.com/d/optout.

