QUERY PLAN
Limit (cost=35.65..35.66 rows=5 width=523)
-> Sort (cost=35.65..35.66 rows=5 width=523)
Sort Key: s.is_complete, s.end_at DESC, s.created_at DESC
-> Group (cost=35.54..35.59 rows=5 width=523)
Group Key: s.id
-> Sort (cost=35.54..35.55 rows=5 width=519)
Sort Key: s.id
-> Hash Right Join (cost=22.80..35.48 rows=5 width=519)
Hash Cond: (ccr.schedule_id = s.id)
Filter: (((s.is_public = 1) AND (s.created_by <> 5064)) OR (s.created_by = 5064) OR (ccr.user_id = 5064))
-> Seq Scan on tbl_schedule_carbon_copy_rels ccr (cost=0.00..10.88 rows=688 width=8)
-> Hash (cost=22.74..22.74 rows=5 width=519)
-> Bitmap Heap Scan on tbl_schedules s (cost=4.32..22.74 rows=5 width=519)
Recheck Cond: (client_id = 3424)
-> Bitmap Index Scan on tbl_schedules_client_id_idx (cost=0.00..4.32 rows=5 width=0)
Index Cond: (client_id = 3424)