QUERY PLAN
Aggregate (cost=126.35..126.36 rows=1 width=8)
-> Group (cost=126.33..126.34 rows=1 width=479)
Group Key: s.id
-> Sort (cost=126.33..126.34 rows=1 width=4)
Sort Key: s.id
-> Hash Right Join (cost=114.18..126.32 rows=1 width=4)
Hash Cond: (ccr.schedule_id = s.id)
-> Seq Scan on tbl_schedule_carbon_copy_rels ccr (cost=0.00..10.45 rows=645 width=4)
-> Hash (cost=114.16..114.16 rows=1 width=12)
-> Bitmap Heap Scan on tbl_schedules s (cost=4.56..114.16 rows=1 width=12)
Recheck Cond: (client_id = 982)
Filter: ((set_top_at IS NULL) AND (NOT is_complete) AND ((end_at > now()) OR (end_at IS NULL)))
-> Bitmap Index Scan on tbl_schedules_client_id_idx (cost=0.00..4.55 rows=36 width=0)
Index Cond: (client_id = 982)