| Limit (cost=321.34..321.35 rows=3 width=539) |
| -> Sort (cost=321.34..321.35 rows=3 width=539) |
| 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=321.29..321.32 rows=3 width=539) |
| Group Key: s.id |
| -> Sort (cost=321.29..321.29 rows=3 width=519) |
| Sort Key: s.id |
| -> Hash Right Join (cost=308.58..321.26 rows=3 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=308.54..308.54 rows=3 width=519) |
| -> Bitmap Heap Scan on tbl_schedules s (cost=5.43..308.54 rows=3 width=519) |
| Recheck Cond: (created_by = 1001) |
| Filter: (NOT is_complete) |
| -> Bitmap Index Scan on tbl_schedules_created_by_idx (cost=0.00..5.43 rows=153 width=0) |
| Index Cond: (created_by = 1001) |