QUERY PLAN
Aggregate (cost=35.50..35.51 rows=1 width=8)
-> Group (cost=35.48..35.49 rows=1 width=479)
Group Key: s.id
-> Sort (cost=35.48..35.48 rows=1 width=4)
Sort Key: s.id
-> Hash Right Join (cost=22.77..35.47 rows=1 width=4)
Hash Cond: (ccr.schedule_id = s.id)
-> Seq Scan on tbl_schedule_carbon_copy_rels ccr (cost=0.00..10.89 rows=689 width=4)
-> Hash (cost=22.76..22.76 rows=1 width=12)
-> Bitmap Heap Scan on tbl_schedules s (cost=4.32..22.76 rows=1 width=12)
Recheck Cond: (client_id = 1933)
Filter: ((set_top_at IS NULL) AND (NOT is_complete) AND (end_at <= now()))
-> Bitmap Index Scan on tbl_schedules_client_id_idx (cost=0.00..4.32 rows=5 width=0)
Index Cond: (client_id = 1933)