QUERY PLAN
Limit (cost=451.30..451.37 rows=28 width=260)
-> Sort (cost=451.30..451.37 rows=28 width=260)
Sort Key: r.created_at DESC
-> Append (cost=8.66..450.63 rows=28 width=260)
-> Group (cost=8.66..8.68 rows=1 width=190)
Group Key: r.id
-> Sort (cost=8.66..8.67 rows=1 width=73)
Sort Key: r.id
-> Result (cost=0.00..8.65 rows=1 width=73)
One-Time Filter: false
-> Seq Scan on tbl_erp_purchase_inbounds r (cost=0.00..8.65 rows=1 width=73)
Filter: (status = 2)
-> Group (cost=104.69..104.70 rows=1 width=221)
Group Key: r_1.id
-> Sort (cost=104.69..104.69 rows=1 width=104)
Sort Key: r_1.id
-> Result (cost=0.00..104.67 rows=1 width=104)
One-Time Filter: false
-> Seq Scan on tbl_erp_purchase_orders r_1 (cost=0.00..104.67 rows=1 width=104)
Filter: (status = 2)
-> Group (cost=1.02..1.04 rows=1 width=329)
Group Key: r_2.id
-> Sort (cost=1.02..1.03 rows=1 width=212)
Sort Key: r_2.id
-> Result (cost=0.00..1.01 rows=1 width=212)
One-Time Filter: false
-> Seq Scan on tbl_erp_purchase_returns r_2 (cost=0.00..1.01 rows=1 width=212)
Filter: (status = 2)
-> Group (cost=1.06..1.08 rows=1 width=329)
Group Key: r_3.id
-> Sort (cost=1.06..1.07 rows=1 width=208)
Sort Key: r_3.id
-> Seq Scan on tbl_erp_inventory_losts r_3 (cost=0.00..1.05 rows=1 width=208)
Filter: ((verify_at >= '2026-06-01 00:00:00+08'::timestamp with time zone) AND (verify_at <= '2026-06-30 23:59:59+08'::timestamp with time zone) AND (status = 2))
-> Group (cost=1.11..1.12 rows=1 width=234)
Group Key: r_4.id
-> Sort (cost=1.11..1.11 rows=1 width=113)
Sort Key: r_4.id
-> Result (cost=0.00..1.10 rows=1 width=113)
One-Time Filter: false
-> Seq Scan on tbl_erp_inventory_overflows r_4 (cost=0.00..1.10 rows=1 width=113)
Filter: (status = 2)
-> Group (cost=1.03..1.05 rows=1 width=329)
Group Key: r_5.id
-> Sort (cost=1.03..1.04 rows=1 width=208)
Sort Key: r_5.id
-> Result (cost=0.00..1.02 rows=1 width=208)
One-Time Filter: false
-> Seq Scan on tbl_erp_inventory_builds r_5 (cost=0.00..1.02 rows=1 width=208)
Filter: (status = 2)
-> Group (cost=12.26..12.28 rows=1 width=329)
Group Key: r_6.id
-> Sort (cost=12.26..12.27 rows=1 width=208)
Sort Key: r_6.id
-> Result (cost=0.00..12.25 rows=1 width=208)
One-Time Filter: false
-> Seq Scan on tbl_erp_inventory_disassembles r_6 (cost=0.00..12.25 rows=1 width=208)
Filter: (status = 2)
-> Group (cost=91.45..91.46 rows=1 width=229)
Group Key: r_7.id
-> Sort (cost=91.45..91.45 rows=1 width=112)
Sort Key: r_7.id
-> Result (cost=0.00..91.44 rows=1 width=112)
One-Time Filter: false
-> Seq Scan on tbl_erp_sales_orders r_7 (cost=0.00..91.44 rows=1 width=112)
Filter: (status = 2)
-> HashAggregate (cost=0.00..0.02 rows=1 width=238)
Group Key: id
-> Result (cost=0.00..0.00 rows=0 width=126)
One-Time Filter: false
-> Group (cost=1.02..1.04 rows=1 width=329)
Group Key: r_8.id
-> Sort (cost=1.02..1.03 rows=1 width=212)
Sort Key: r_8.id
-> Result (cost=0.00..1.01 rows=1 width=212)
One-Time Filter: false
-> Seq Scan on tbl_erp_sales_returns r_8 (cost=0.00..1.01 rows=1 width=212)
Filter: (status = 2)
-> Group (cost=1.26..1.27 rows=1 width=192)
Group Key: r_9.id
-> Sort (cost=1.26..1.26 rows=1 width=79)
Sort Key: r_9.id
-> Result (cost=0.00..1.25 rows=1 width=79)
One-Time Filter: false
-> Seq Scan on tbl_erp_purchase_gifts r_9 (cost=0.00..1.25 rows=1 width=79)
Filter: (status = 2)
-> HashAggregate (cost=0.00..0.02 rows=1 width=248)
Group Key: id
-> Result (cost=0.00..0.00 rows=0 width=104)
One-Time Filter: false
-> Group (cost=95.44..95.45 rows=1 width=170)
Group Key: r_10.id
-> Sort (cost=95.44..95.44 rows=1 width=97)
Sort Key: r_10.id
-> Result (cost=0.00..95.42 rows=1 width=97)
One-Time Filter: false
-> Seq Scan on tbl_erp_collect_tickets r_10 (cost=0.00..95.42 rows=1 width=97)
Filter: (status = 2)
-> Group (cost=103.40..103.41 rows=1 width=175)
Group Key: r_11.id
-> Sort (cost=103.40..103.40 rows=1 width=103)
Sort Key: r_11.id
-> Result (cost=0.00..103.39 rows=1 width=103)
One-Time Filter: false
-> Seq Scan on tbl_erp_payment_tickets r_11 (cost=0.00..103.39 rows=1 width=103)
Filter: (status = 2)
-> HashAggregate (cost=0.00..0.02 rows=1 width=194)
Group Key: id
-> Result (cost=0.00..0.00 rows=0 width=113)
One-Time Filter: false
-> HashAggregate (cost=0.00..0.02 rows=1 width=196)
Group Key: id
-> Result (cost=0.00..0.00 rows=0 width=123)
One-Time Filter: false
-> HashAggregate (cost=0.00..0.02 rows=1 width=329)
Group Key: id
-> Result (cost=0.00..0.00 rows=0 width=208)
One-Time Filter: false
-> Group (cost=1.28..1.30 rows=1 width=329)
Group Key: r_12.id
-> Sort (cost=1.28..1.29 rows=1 width=208)
Sort Key: r_12.id
-> Result (cost=0.00..1.27 rows=1 width=208)
One-Time Filter: false
-> Seq Scan on tbl_erp_bank_transfer_tickets r_12 (cost=0.00..1.27 rows=1 width=208)
Filter: (status = 2)
-> HashAggregate (cost=0.00..0.02 rows=1 width=183)
Group Key: id
-> Result (cost=0.00..0.00 rows=0 width=95)
One-Time Filter: false
-> Group (cost=12.01..12.03 rows=1 width=329)
Group Key: r_13.id
-> Sort (cost=12.01..12.02 rows=1 width=249)
Sort Key: r_13.id
-> Result (cost=0.00..12.00 rows=1 width=249)
One-Time Filter: false
-> Seq Scan on tbl_erp_advance_payment_tickets r_13 (cost=0.00..12.00 rows=1 width=249)
Filter: (status = 2)
-> Group (cost=3.56..3.57 rows=1 width=183)
Group Key: r_14.id
-> Sort (cost=3.56..3.56 rows=1 width=110)
Sort Key: r_14.id
-> Result (cost=0.00..3.55 rows=1 width=110)
One-Time Filter: false
-> Seq Scan on tbl_erp_other_payment_tickets r_14 (cost=0.00..3.55 rows=1 width=110)
Filter: (status = 2)
-> Group (cost=2.48..2.50 rows=1 width=188)
Group Key: r_15.id
-> Sort (cost=2.48..2.49 rows=1 width=115)
Sort Key: r_15.id
-> Result (cost=0.00..2.48 rows=1 width=115)
One-Time Filter: false
-> Seq Scan on tbl_erp_other_collect_tickets r_15 (cost=0.00..2.48 rows=1 width=115)
Filter: (status = 2)
-> Group (cost=2.58..2.60 rows=1 width=272)
Group Key: r_16.id
-> Sort (cost=2.58..2.59 rows=1 width=155)
Sort Key: r_16.id
-> Result (cost=0.00..2.58 rows=1 width=155)
One-Time Filter: false
-> Seq Scan on tbl_erp_purchase_costs r_16 (cost=0.00..2.58 rows=1 width=155)
Filter: (status = 2)
-> Group (cost=1.19..1.20 rows=1 width=228)
Group Key: r_17.id
-> Sort (cost=1.19..1.19 rows=1 width=140)
Sort Key: r_17.id
-> Result (cost=0.00..1.18 rows=1 width=140)
One-Time Filter: false
-> Seq Scan on tbl_erp_wage_tickets r_17 (cost=0.00..1.18 rows=1 width=140)
Filter: (status = 2)
-> Group (cost=1.14..1.15 rows=1 width=329)
Group Key: r_18.id
-> Sort (cost=1.14..1.14 rows=1 width=241)
Sort Key: r_18.id
-> Result (cost=0.00..1.12 rows=1 width=241)
One-Time Filter: false
-> Seq Scan on tbl_erp_social_insurances r_18 (cost=0.00..1.12 rows=1 width=241)
Filter: (status = 2)
-> Group (cost=1.10..1.11 rows=1 width=329)
Group Key: r_19.id
-> Sort (cost=1.10..1.10 rows=1 width=241)
Sort Key: r_19.id
-> Result (cost=0.00..1.09 rows=1 width=241)
One-Time Filter: false
-> Seq Scan on tbl_erp_provident_funds r_19 (cost=0.00..1.09 rows=1 width=241)
Filter: (status = 2)
-> Group (cost=1.11..1.12 rows=1 width=329)
Group Key: r_20.id
-> Sort (cost=1.11..1.11 rows=1 width=241)
Sort Key: r_20.id
-> Result (cost=0.00..1.10 rows=1 width=241)
One-Time Filter: false
-> Seq Scan on tbl_erp_personal_taxs r_20 (cost=0.00..1.10 rows=1 width=241)
Filter: (status = 2)
-> Group (cost=1.06..1.07 rows=1 width=329)
Group Key: r_21.id
-> Sort (cost=1.06..1.06 rows=1 width=241)
Sort Key: r_21.id
-> Result (cost=0.00..1.05 rows=1 width=241)
One-Time Filter: false
-> Seq Scan on tbl_erp_wage_prizes r_21 (cost=0.00..1.05 rows=1 width=241)
Filter: (status = 2)