| Limit (cost=131.53..131.55 rows=10 width=539) |
| -> Sort (cost=131.53..131.58 rows=20 width=539) |
| 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 |
| -> Group (cost=130.90..131.10 rows=20 width=539) |
| Group Key: s.id |
| -> Sort (cost=130.90..130.95 rows=20 width=519) |
| Sort Key: s.id |
| -> Nested Loop (cost=109.56..130.47 rows=20 width=519) |
| -> Index Scan using tbl_users_pkey on tbl_users u (cost=0.14..8.16 rows=1 width=4) |
| Index Cond: (id = 1000) |
| Filter: (department_id = 10) |
| -> Hash Right Join (cost=109.41..122.10 rows=20 width=519) |
| Hash Cond: (ccr.schedule_id = s.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,5446,5449,5461,5476}'::integer[])) OR (ccr.user_id = 1000))) |
| -> Seq Scan on tbl_schedule_carbon_copy_rels ccr (cost=0.00..10.88 rows=688 width=8) |
| -> Hash (cost=108.99..108.99 rows=34 width=519) |
| -> Bitmap Heap Scan on tbl_schedules s (cost=4.55..108.99 rows=34 width=519) |
| Recheck 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 = 1000) |