QUERY PLAN
Hash Right Join (cost=307.45..319.73 rows=6 width=20)
Hash Cond: (ccr.schedule_id = tbl_schedules.id)
Filter: (((tbl_schedules.is_public = 1) AND (tbl_schedules.created_by <> 5300)) OR (tbl_schedules.created_by = 5300) OR (ccr.user_id = 5300))
-> Seq Scan on tbl_schedule_carbon_copy_rels ccr (cost=0.00..10.45 rows=645 width=8)
-> Hash (cost=307.36..307.36 rows=7 width=45)
-> Bitmap Heap Scan on tbl_schedules (cost=14.33..307.36 rows=7 width=45)
Recheck Cond: ((created_by = ANY ('{5311,5300,5300}'::integer[])) AND (created_by = 5300))
Filter: (((start_at IS NOT NULL) OR (end_at IS NOT NULL)) AND (alarm_before IS NOT NULL))
-> Bitmap Index Scan on tbl_schedules_created_by_idx (cost=0.00..14.33 rows=148 width=0)
Index Cond: ((created_by = ANY ('{5311,5300,5300}'::integer[])) AND (created_by = 5300))