| Limit (cost=268.42..268.43 rows=4 width=362) |
| -> Sort (cost=268.42..268.43 rows=4 width=362) |
| Sort Key: p.bargain_date DESC, p.created_at DESC |
| -> Nested Loop (cost=240.40..268.38 rows=4 width=362) |
| -> Nested Loop (cost=240.12..265.60 rows=5 width=362) |
| -> Hash Join (cost=239.84..253.44 rows=22 width=362) |
| Hash Cond: (subpsl.project_id = p.id) |
| -> HashAggregate (cost=91.42..97.43 rows=601 width=12) |
| Group Key: subpsl.project_id |
| Filter: ((min(subpsl.id) IS NOT NULL) AND (max(subpsl.id) IS NOT NULL)) |
| -> Seq Scan on tbl_project_status_logs subpsl (cost=0.00..82.79 rows=690 width=8) |
| Filter: ((created_at >= '2025-01-01 00:00:00+08'::timestamp with time zone) AND (created_at < '2026-01-01 00:00:00'::timestamp without time zone)) |
| -> Hash (cost=147.02..147.02 rows=112 width=354) |
| -> Bitmap Heap Scan on tbl_projects p (cost=5.15..147.02 rows=112 width=354) |
| Recheck Cond: (created_by = 1001) |
| -> Bitmap Index Scan on tbl_projects_created_by_idx (cost=0.00..5.12 rows=112 width=0) |
| Index Cond: (created_by = 1001) |
| -> Index Scan using tbl_project_status_logs_pkey on tbl_project_status_logs maxpsl (cost=0.28..0.55 rows=1 width=8) |
| Index Cond: (id = (max(subpsl.id))) |
| Filter: (new_status = 0) |
| -> Index Scan using tbl_project_status_logs_pkey on tbl_project_status_logs minpsl (cost=0.28..0.56 rows=1 width=8) |
| Index Cond: (id = (min(subpsl.id))) |
| Filter: ((old_status <> 0) OR ((old_status IS NULL) AND (new_status <> 0))) |