| Aggregate (cost=790.13..790.14 rows=1 width=8) |
| -> Sort (cost=767.66..771.40 rows=1498 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=666.18..688.65 rows=1498 width=495) |
| Group Key: s.id |
| -> Hash Left Join (cost=36.55..662.43 rows=1498 width=37) |
| Hash Cond: (s.id = ccr.schedule_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,1022,1023,5016,5064,5085,5087,5248,5250,5252,5295,5300,5311,5332,5360,5446,5461,5476}'::integer[])) OR (ccr.user_id = 1001))) |
| -> Hash Join (cost=17.07..622.94 rows=2320 width=45) |
| Hash Cond: (s.created_by = u.id) |
| -> Seq Scan on tbl_schedules s (cost=0.00..564.84 rows=15184 width=49) |
| -> Hash (cost=16.80..16.80 rows=22 width=4) |
| -> Seq Scan on tbl_users u (cost=0.00..16.80 rows=22 width=4) |
| Filter: (department_id = 10) |
| -> Hash (cost=10.88..10.88 rows=688 width=8) |
| -> Seq Scan on tbl_schedule_carbon_copy_rels ccr (cost=0.00..10.88 rows=688 width=8) |