QUERY PLAN
Limit (cost=345.23..345.37 rows=11 width=374)
-> Sort (cost=345.23..345.26 rows=11 width=374)
Sort Key: b.is_delete, b.sort
-> GroupAggregate (cost=343.24..345.04 rows=11 width=374)
Group Key: b.id
-> Merge Left Join (cost=343.24..344.13 rows=11 width=332)
Merge Cond: (b.id = t_5.erp_bank_id)
-> Merge Left Join (cost=278.31..278.76 rows=11 width=324)
Merge Cond: (b.id = t_4.erp_bank_id)
-> Merge Left Join (cost=213.91..214.21 rows=11 width=316)
Merge Cond: (b.id = f.erp_bank_id)
-> Merge Left Join (cost=140.57..140.73 rows=11 width=252)
Merge Cond: (b.id = l.erp_bank_id)
-> Sort (cost=67.44..67.47 rows=11 width=188)
Sort Key: b.id
-> Hash Left Join (cost=66.06..67.25 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=64.75..64.75 rows=7 width=68)
-> Subquery Scan on n (cost=64.57..64.75 rows=7 width=68)
-> HashAggregate (cost=64.57..64.68 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=29 width=15)
Filter: ((settle_at >= '2026-05-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=73.13..73.15 rows=7 width=68)
Sort Key: l.erp_bank_id
-> Subquery Scan on l (cost=72.86..73.03 rows=7 width=68)
-> HashAggregate (cost=72.86..72.96 rows=7 width=68)
Group Key: t_2.erp_bank_id
-> Seq Scan on tbl_erp_bank_amount_change_logs t_2 (cost=0.00..59.96 rows=1719 width=15)
Filter: (settle_at <= '2026-05-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)
-> GroupAggregate (cost=64.40..64.46 rows=3 width=12)
Group Key: t_4.erp_bank_id
-> Sort (cost=64.40..64.41 rows=4 width=4)
Sort Key: t_4.erp_bank_id
-> Seq Scan on tbl_erp_bank_amount_change_logs t_4 (cost=0.00..64.36 rows=4 width=4)
Filter: ((in_amount IS NOT NULL) AND (settle_at >= '2026-05-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=64.94..65.19 rows=7 width=12)
Group Key: t_5.erp_bank_id
-> Sort (cost=64.94..65.00 rows=25 width=4)
Sort Key: t_5.erp_bank_id
-> Seq Scan on tbl_erp_bank_amount_change_logs t_5 (cost=0.00..64.36 rows=25 width=4)
Filter: ((out_amount IS NOT NULL) AND (settle_at >= '2026-05-01 00:00:00+08'::timestamp with time zone) AND (settle_at <= '2026-05-31 23:59:59+08'::timestamp with time zone))