QUERY PLAN
Aggregate (cost=44.23..44.24 rows=1 width=8)
-> Group (cost=44.21..44.21 rows=1 width=479)
Group Key: s.id
-> Sort (cost=44.21..44.21 rows=1 width=4)
Sort Key: s.id
-> Hash Right Join (cost=8.18..44.20 rows=1 width=4)
Hash Cond: (ccr.schedule_id = s.id)
Filter: (((s.created_by = ANY ('{5493,5495}'::integer[])) OR (ccr.user_id = 5495)) AND (((s.is_public = 1) AND (s.created_by <> 5495)) OR (s.created_by = 5495) OR (ccr.user_id = 5495)))
-> Seq Scan on tbl_schedule_carbon_copy_rels ccr (cost=0.00..30.40 rows=2040 width=8)
-> Hash (cost=8.17..8.17 rows=1 width=16)
-> Index Scan using tbl_schedules_created_by_idx on tbl_schedules s (cost=0.14..8.17 rows=1 width=16)
Index Cond: (created_by = 5495)
Filter: ((set_top_at IS NULL) AND (NOT is_complete) AND ((end_at > now()) OR (end_at IS NULL)))