| Limit (cost=44.36..44.37 rows=1 width=495) |
| -> Sort (cost=44.36..44.37 rows=1 width=495) |
| Sort Key: (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 |
| -> Group (cost=44.28..44.35 rows=1 width=495) |
| Group Key: s.id |
| -> Sort (cost=44.28..44.31 rows=13 width=475) |
| Sort Key: s.id |
| -> Hash Right Join (cost=8.17..44.04 rows=13 width=475) |
| Hash Cond: (ccr.schedule_id = s.id) |
| -> Seq Scan on tbl_schedule_carbon_copy_rels ccr (cost=0.00..30.40 rows=2040 width=4) |
| -> Hash (cost=8.16..8.16 rows=1 width=475) |
| -> Index Scan using tbl_schedules_created_by_idx on tbl_schedules s (cost=0.14..8.16 rows=1 width=475) |
| Index Cond: (created_by = 5495) |
| Filter: (NOT is_complete) |