Aggregate (cost=532.76..532.77 rows=1 width=8) |
-> Sort (cost=523.65..525.17 rows=607 width=495) |
Sort Key: s.set_top_at DESC NULLS LAST, (CASE WHEN s.is_complete THEN 3 WHEN ((NOT s.is_complete) AND (s.end_at <= now())) THEN 2 ELSE 1 END), (CASE WHEN s.is_complete THEN s.complete_at ELSE NULL::timestamp with time zone END) DESC, (CASE WHEN (NOT s.is_complete) THEN s.end_at ELSE NULL::timestamp with time zone END), s.created_at DESC |
-> HashAggregate (cost=486.49..495.59 rows=607 width=495) |
Group Key: s.id |
-> Nested Loop (cost=44.12..484.97 rows=607 width=37) |
-> Seq Scan on tbl_users u (cost=0.00..8.12 rows=1 width=4) |
Filter: ((id = 5300) AND (department_id = 1)) |
-> Hash Left Join (cost=44.12..470.79 rows=607 width=41) |
Hash Cond: (s.id = ccr.schedule_id) |
Filter: ((((s.is_public = 1) AND (s.created_by <> 1000)) OR (s.created_by = 1000) OR (ccr.user_id = 1000)) AND ((s.created_by = ANY ('{1000,1001,1004,1005,1011,1013,1015,1022,1023,5016,5064,5085,5087,5248,5250,5252,5295,5300,5311,5332,5360,5388,5446,5449}'::integer[])) OR (ccr.user_id = 1000))) |
-> Bitmap Heap Scan on tbl_schedules s (cost=24.57..441.93 rows=1069 width=49) |
Recheck Cond: (created_by = 5300) |
-> Bitmap Index Scan on tbl_schedules_created_by_idx (cost=0.00..24.30 rows=1069 width=0) |
Index Cond: (created_by = 5300) |
-> Hash (cost=10.91..10.91 rows=691 width=8) |
-> Seq Scan on tbl_schedule_carbon_copy_rels ccr (cost=0.00..10.91 rows=691 width=8) |