Sort (cost=471.81..471.82 rows=6 width=199) |
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.end_at DESC |
-> Hash Right Join (cost=459.56..471.73 rows=6 width=199) |
Hash Cond: (ccr.schedule_id = s.id) |
Filter: (((s.is_public = 1) AND (s.created_by <> 5016)) OR (s.created_by = 5016) OR (ccr.user_id = 5016)) |
-> Seq Scan on tbl_schedule_carbon_copy_rels ccr (cost=0.00..10.45 rows=645 width=8) |
-> Hash (cost=459.48..459.48 rows=6 width=183) |
-> Bitmap Heap Scan on tbl_schedules s (cost=54.41..459.48 rows=6 width=183) |
Recheck Cond: (client_id = ANY ('{982,2188,102,989,576,1016,3319,1172,97,497,106,1101,572,2116}'::integer[])) |
Filter: ((NOT is_complete) OR (complete_at >= '2025-06-20 00:00:00+08'::timestamp with time zone)) |
-> Bitmap Index Scan on tbl_schedules_client_id_idx (cost=0.00..54.41 rows=315 width=0) |
Index Cond: (client_id = ANY ('{982,2188,102,989,576,1016,3319,1172,97,497,106,1101,572,2116}'::integer[])) |