QUERY PLAN
GroupAggregate (cost=2895.12..2895.34 rows=11 width=36)
Group Key: "*SELECT* 1".id
-> Sort (cost=2895.12..2895.15 rows=11 width=9)
Sort Key: "*SELECT* 1".id
-> Append (cost=1160.83..2894.93 rows=11 width=9)
-> Subquery Scan on "*SELECT* 1" (cost=1160.83..2609.96 rows=9 width=9)
-> Nested Loop (cost=1160.83..2609.87 rows=9 width=17)
-> Bitmap Heap Scan on tbl_term_taxonomy_relationships dt (cost=1160.55..2292.33 rows=57 width=13)
Recheck Cond: (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}'::integer[])))
-> Bitmap Index Scan on tbl_term_taxonomy_relationships_object_id_term_id_idx (cost=0.00..1160.54 rows=15825 width=0)
Index Cond: (term_id = 18)
-> Index Scan using tbl_erp_cash_cost_tickets_pkey on tbl_erp_cash_cost_tickets r (cost=0.28..5.57 rows=1 width=4)
Index Cond: (id = dt.object_id)
Filter: (is_payment_settle AND (created_at >= '2025-01-01 00:00:00+08'::timestamp with time zone) AND (created_at <= '2025-12-31 23:59:59+08'::timestamp with time zone) AND (status = 2))
-> Subquery Scan on "*SELECT* 2" (cost=0.29..272.21 rows=1 width=9)
-> Nested Loop (cost=0.29..272.20 rows=1 width=17)
-> Seq Scan on tbl_erp_cost_tickets r_1 (cost=0.00..2.47 rows=24 width=4)
Filter: ((created_at >= '2025-01-01 00:00:00+08'::timestamp with time zone) AND (created_at <= '2025-12-31 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.23 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}'::integer[])))
-> Subquery Scan on "*SELECT* 3" (cost=0.29..12.76 rows=1 width=9)
-> Nested Loop (cost=0.29..12.75 rows=1 width=17)
-> Seq Scan on tbl_erp_cost_convert_tickets r_2 (cost=0.00..1.07 rows=1 width=4)
Filter: ((created_at >= '2025-01-01 00:00:00+08'::timestamp with time zone) AND (created_at <= '2025-12-31 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.67 rows=1 width=13)
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}'::integer[])))