Using ruby ruby 1.9.3p194, rails 3.2.8, postgresql 9.2
The controller dies with this query
@jobs = Job.select([:user_id, :job_actual_wall_time, :job_processor_count, :job_requested_memory, :job_started_at, :job_ended_at]).joins(:account).where("(job_started_at between :start_date and :end_date) or
(job_ended_at between :start_date and :end_date ) or
(job_started_at < :start_date and job_ended_at > :end_date)",
{start_date: @start_date, end_date: @end_date}).where(:account_id => account_id).order(:user_id).order(:job_started_at)
where @start_date is July 1, 2012 and @end_date is July 4, 2012 and account_id = 8
I can set the variables by hand at the console and the query executes without error (there are about 95,000 jobs in that interval). If I set the end date back by a day, there are about 50,000 such jobs and in rails the query executes. It seems to be the number of records requested.
Not sure where to debug this one. There doesn't seem to be a question quite like this on SO; but if there is, please point me to it.