| Limit (cost=400.35..400.40 rows=20 width=539) |
| -> Sort (cost=400.35..400.93 rows=232 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 |
| -> HashAggregate (cost=390.69..394.17 rows=232 width=539) |
| Group Key: s.id |
| -> Hash Right Join (cost=377.43..390.11 rows=232 width=519) |
| Hash Cond: (ccr.schedule_id = s.id) |
| -> Seq Scan on tbl_schedule_carbon_copy_rels ccr (cost=0.00..10.88 rows=688 width=4) |
| -> Hash (cost=374.53..374.53 rows=232 width=519) |
| -> Bitmap Heap Scan on tbl_schedules s (cost=6.08..374.53 rows=232 width=519) |
| Recheck Cond: (client_id = 149) |
| -> Bitmap Index Scan on tbl_schedules_client_id_idx (cost=0.00..6.03 rows=232 width=0) |
| Index Cond: (client_id = 149) |