QUERY PLAN
Aggregate (cost=351.91..351.92 rows=1 width=8)
-> Group (cost=351.89..351.89 rows=1 width=479)
Group Key: s.id
-> Sort (cost=351.89..351.89 rows=1 width=4)
Sort Key: s.id
-> Hash Right Join (cost=339.73..351.88 rows=1 width=4)
Hash Cond: (ccr.schedule_id = s.id)
Filter: ((((s.is_public = 1) AND (s.created_by <> 1001)) OR (s.created_by = 1001) OR (ccr.user_id = 1001)) AND ((s.created_by = ANY ('{1000,1001,1004,1005,1011,1013,1015,1017,1022,1023,5016,5064,5085,5087,5248,5250,5252,5295,5296,5300,5311,5329,5332,5360,5388,5404,5420,5440,5445,5446}'::integer[])) OR (ccr.user_id = 1001)))
-> Seq Scan on tbl_schedule_carbon_copy_rels ccr (cost=0.00..10.45 rows=645 width=8)
-> Hash (cost=339.72..339.72 rows=1 width=16)
-> Bitmap Heap Scan on tbl_schedules s (cost=22.70..339.72 rows=1 width=16)
Recheck Cond: ((created_by = 1000) OR (created_by = 5250) OR (created_by = 5016) OR (created_by = 5064) OR (created_by = 5440))
Filter: (set_top_at IS NOT NULL)
-> BitmapOr (cost=22.70..22.70 rows=171 width=0)
-> Bitmap Index Scan on tbl_schedules_created_by_idx (cost=0.00..4.54 rows=34 width=0)
Index Cond: (created_by = 1000)
-> Bitmap Index Scan on tbl_schedules_created_by_idx (cost=0.00..4.54 rows=34 width=0)
Index Cond: (created_by = 5250)
-> Bitmap Index Scan on tbl_schedules_created_by_idx (cost=0.00..4.54 rows=34 width=0)
Index Cond: (created_by = 5016)
-> Bitmap Index Scan on tbl_schedules_created_by_idx (cost=0.00..4.54 rows=34 width=0)
Index Cond: (created_by = 5064)
-> Bitmap Index Scan on tbl_schedules_created_by_idx (cost=0.00..4.54 rows=34 width=0)
Index Cond: (created_by = 5440)