QUERY PLAN
Limit (cost=353.18..353.32 rows=11 width=374)
-> Sort (cost=353.18..353.21 rows=11 width=374)
Sort Key: b.is_delete, b.sort
-> GroupAggregate (cost=351.58..352.99 rows=11 width=374)
Group Key: b.id
-> Merge Left Join (cost=351.58..352.08 rows=11 width=332)
Merge Cond: (b.id = osb.erp_bank_id)
-> Merge Left Join (cost=279.57..279.94 rows=11 width=324)
Merge Cond: (b.id = isb.erp_bank_id)
-> Merge Left Join (cost=213.65..213.89 rows=11 width=316)
Merge Cond: (b.id = f.erp_bank_id)
-> Merge Left Join (cost=140.31..140.41 rows=11 width=252)
Merge Cond: (b.id = t_2.erp_bank_id)
-> Sort (cost=80.33..80.36 rows=11 width=188)
Sort Key: b.id
-> Hash Left Join (cost=78.95..80.14 rows=11 width=188)
Hash Cond: (b.id = n.erp_bank_id)
-> Hash Left Join (cost=1.22..2.38 rows=11 width=124)
Hash Cond: (b.id = t.id)
-> Seq Scan on tbl_erp_banks b (cost=0.00..1.11 rows=11 width=118)
-> Hash (cost=1.14..1.14 rows=7 width=10)
-> Seq Scan on tbl_erp_banks t (cost=0.00..1.14 rows=7 width=10)
Filter: (created_at <= '2026-05-31 23:59:59+08'::timestamp with time zone)
-> Hash (cost=77.64..77.64 rows=7 width=68)
-> Subquery Scan on n (cost=77.47..77.64 rows=7 width=68)
-> HashAggregate (cost=77.47..77.57 rows=7 width=68)
Group Key: t_1.erp_bank_id
-> Seq Scan on tbl_erp_bank_amount_change_logs t_1 (cost=0.00..64.36 rows=1748 width=15)
Filter: ((settle_at >= '2024-04-01 00:00:00+08'::timestamp with time zone) AND (settle_at <= '2026-05-31 23:59:59+08'::timestamp with time zone))
-> GroupAggregate (cost=59.97..60.00 rows=1 width=68)
Group Key: t_2.erp_bank_id
-> Sort (cost=59.97..59.98 rows=1 width=15)
Sort Key: t_2.erp_bank_id
-> Seq Scan on tbl_erp_bank_amount_change_logs t_2 (cost=0.00..59.96 rows=1 width=15)
Filter: (settle_at <= '2024-04-01 00:00:00+08'::timestamp with time zone)
-> Sort (cost=73.35..73.36 rows=7 width=68)
Sort Key: f.erp_bank_id
-> Subquery Scan on f (cost=73.07..73.25 rows=7 width=68)
-> HashAggregate (cost=73.07..73.18 rows=7 width=68)
Group Key: t_3.erp_bank_id
-> Seq Scan on tbl_erp_bank_amount_change_logs t_3 (cost=0.00..59.96 rows=1748 width=15)
Filter: (settle_at <= '2026-05-31 23:59:59+08'::timestamp with time zone)
-> Sort (cost=65.92..65.94 rows=7 width=12)
Sort Key: isb.erp_bank_id
-> Subquery Scan on isb (cost=65.69..65.83 rows=7 width=12)
-> HashAggregate (cost=65.69..65.76 rows=7 width=12)
Group Key: t_4.erp_bank_id
-> Seq Scan on tbl_erp_bank_amount_change_logs t_4 (cost=0.00..64.36 rows=266 width=4)
Filter: ((in_amount IS NOT NULL) AND (settle_at >= '2024-04-01 00:00:00+08'::timestamp with time zone) AND (settle_at <= '2026-05-31 23:59:59+08'::timestamp with time zone))
-> Sort (cost=72.00..72.02 rows=7 width=12)
Sort Key: osb.erp_bank_id
-> Subquery Scan on osb (cost=71.77..71.90 rows=7 width=12)
-> HashAggregate (cost=71.77..71.83 rows=7 width=12)
Group Key: t_5.erp_bank_id
-> Seq Scan on tbl_erp_bank_amount_change_logs t_5 (cost=0.00..64.36 rows=1482 width=4)
Filter: ((out_amount IS NOT NULL) AND (settle_at >= '2024-04-01 00:00:00+08'::timestamp with time zone) AND (settle_at <= '2026-05-31 23:59:59+08'::timestamp with time zone))