QUERY PLAN
Hash Right Join (cost=559.87..572.94 rows=41 width=20)
Hash Cond: (ccr.schedule_id = tbl_schedules.id)
Filter: (((tbl_schedules.is_public = 1) AND (tbl_schedules.created_by <> 1004)) OR (tbl_schedules.created_by = 1004) OR (ccr.user_id = 1004))
-> Seq Scan on tbl_schedule_carbon_copy_rels ccr (cost=0.00..10.45 rows=645 width=8)
-> Hash (cost=559.32..559.32 rows=44 width=45)
-> Bitmap Heap Scan on tbl_schedules (cost=110.15..559.32 rows=44 width=45)
Recheck Cond: ((created_by = ANY ('{1004,1004,1001,5446,5087,1015,1023,5064,5440,5360,1022,5311,5248,1000,5420,5445,5388,5404,5252,1013,5300,5250,5296,1005,1017,5085,5332,1011,5329,5016,5295}'::integer[])) AND (created_by = 1004))
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..110.13 rows=940 width=0)
Index Cond: ((created_by = ANY ('{1004,1004,1001,5446,5087,1015,1023,5064,5440,5360,1022,5311,5248,1000,5420,5445,5388,5404,5252,1013,5300,5250,5296,1005,1017,5085,5332,1011,5329,5016,5295}'::integer[])) AND (created_by = 1004))