QUERY PLAN
Hash Right Join (cost=138.70..151.42 rows=1 width=20)
Hash Cond: (ccr.schedule_id = tbl_schedules.id)
Filter: (((tbl_schedules.is_public = 1) AND (tbl_schedules.created_by <> 1015)) OR (tbl_schedules.created_by = 1015) OR (ccr.user_id = 1015))
-> Seq Scan on tbl_schedule_carbon_copy_rels ccr (cost=0.00..10.89 rows=689 width=8)
-> Hash (cost=138.69..138.69 rows=1 width=45)
-> Bitmap Heap Scan on tbl_schedules (cost=74.20..138.69 rows=1 width=45)
Recheck Cond: ((created_by = ANY ('{1004,1001,5087,1015,1015,1023,5360,1022,5311,5311,5248,5476,5500,5252,1013,5300,1005,5499,5332,1011,5295}'::integer[])) AND (created_by = 1015))
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..74.19 rows=19 width=0)
Index Cond: ((created_by = ANY ('{1004,1001,5087,1015,1015,1023,5360,1022,5311,5311,5248,5476,5500,5252,1013,5300,1005,5499,5332,1011,5295}'::integer[])) AND (created_by = 1015))