QUERY PLAN
GroupAggregate (cost=2716.38..2716.46 rows=4 width=36)
Group Key: "*SELECT* 1".id
-> Sort (cost=2716.38..2716.39 rows=4 width=9)
Sort Key: "*SELECT* 1".id
-> Append (cost=0.29..2716.34 rows=4 width=9)
-> Subquery Scan on "*SELECT* 1" (cost=0.29..2594.40 rows=2 width=9)
-> Nested Loop (cost=0.29..2594.38 rows=2 width=17)
-> Seq Scan on tbl_erp_cash_cost_tickets r (cost=0.00..487.21 rows=288 width=4)
Filter: (is_payment_settle AND (bank_settle_at >= '2026-01-01 00:00:00+08'::timestamp with time zone) AND (bank_settle_at <= '2026-06-30 23:59:59+08'::timestamp with time zone) AND (status = 2))
-> Index Scan using tbl_term_taxonomy_relationships_object_id_term_id_idx on tbl_term_taxonomy_relationships dt (cost=0.29..7.31 rows=1 width=13)
Index Cond: ((object_id = r.id) AND (term_id = 18))
Filter: ((object_type = 11) AND (taxonomy_id = ANY ('{386,387,388,389,390,391,392,393,394,395,396,397,426,427,428,425,429,432,433,434,435,438,440}'::integer[])))
-> Subquery Scan on "*SELECT* 2" (cost=0.29..109.13 rows=1 width=9)
-> Nested Loop (cost=0.29..109.12 rows=1 width=17)
-> Seq Scan on tbl_erp_cost_tickets r_1 (cost=0.00..4.44 rows=9 width=4)
Filter: ((verify_at >= '2026-01-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))
-> Index Scan using tbl_term_taxonomy_relationships_object_id_term_id_idx on tbl_term_taxonomy_relationships dt_1 (cost=0.29..11.62 rows=1 width=13)
Index Cond: ((object_id = r_1.id) AND (term_id = 18))
Filter: ((object_type = 9) AND (taxonomy_id = ANY ('{386,387,388,389,390,391,392,393,394,395,396,397,426,427,428,425,429,432,433,434,435,438,440}'::integer[])))
-> Subquery Scan on "*SELECT* 3" (cost=0.29..12.82 rows=1 width=10)
-> Nested Loop (cost=0.29..12.81 rows=1 width=18)
-> Seq Scan on tbl_erp_cost_convert_tickets r_2 (cost=0.00..1.18 rows=1 width=4)
Filter: ((verify_at >= '2026-01-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))
-> Index Scan using tbl_term_taxonomy_relationships_object_id_term_id_idx on tbl_term_taxonomy_relationships dt_2 (cost=0.29..11.62 rows=1 width=14)
Index Cond: ((object_id = r_2.id) AND (term_id = 18))
Filter: ((object_type = 10) AND (taxonomy_id = ANY ('{386,387,388,389,390,391,392,393,394,395,396,397,426,427,428,425,429,432,433,434,435,438,440}'::integer[])))