QUERY PLAN
GroupAggregate (cost=353.03..353.09 rows=3 width=36)
Group Key: "*SELECT* 1".id
-> Sort (cost=353.03..353.03 rows=3 width=9)
Sort Key: "*SELECT* 1".id
-> Append (cost=0.29..353.00 rows=3 width=9)
-> Subquery Scan on "*SELECT* 1" (cost=0.29..326.08 rows=1 width=9)
-> Nested Loop (cost=0.29..326.07 rows=1 width=17)
-> Seq Scan on tbl_erp_cash_cost_tickets r (cost=0.00..314.39 rows=1 width=4)
Filter: (is_payment_settle AND (created_at >= '2025-12-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 (cost=0.29..11.67 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}'::integer[])))
-> Subquery Scan on "*SELECT* 2" (cost=0.29..14.16 rows=1 width=9)
-> Nested Loop (cost=0.29..14.15 rows=1 width=17)
-> Seq Scan on tbl_erp_cost_tickets r_1 (cost=0.00..2.47 rows=1 width=4)
Filter: ((created_at >= '2025-12-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.67 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-12-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[])))