| GroupAggregate (cost=8.18..8.20 rows=1 width=12) |
| Group Key: (CASE WHEN tbl_schedules.is_complete THEN 1 WHEN ((NOT tbl_schedules.is_complete) AND (tbl_schedules.end_at < '2026-06-02 16:07:23+08'::timestamp with time zone)) THEN 2 ELSE 0 END) |
| -> Sort (cost=8.18..8.19 rows=1 width=8) |
| Sort Key: (CASE WHEN tbl_schedules.is_complete THEN 1 WHEN ((NOT tbl_schedules.is_complete) AND (tbl_schedules.end_at < '2026-06-02 16:07:23+08'::timestamp with time zone)) THEN 2 ELSE 0 END) |
| -> Index Scan using tbl_schedules_created_by_idx on tbl_schedules (cost=0.14..8.17 rows=1 width=8) |
| Index Cond: (created_by = 5495) |
| Filter: ((is_public = 1) AND (CASE WHEN is_complete THEN 1 WHEN ((NOT is_complete) AND (end_at < '2026-06-02 16:07:23+08'::timestamp with time zone)) THEN 2 ELSE 0 END = ANY ('{0,2}'::integer[]))) |