QUERY PLAN
Aggregate (cost=30.38..30.39 rows=1 width=32)
-> Nested Loop (cost=0.29..30.37 rows=1 width=6)
Join Filter: (dt1.taxonomy_id = tt.id)
-> Nested Loop (cost=0.29..22.12 rows=1 width=10)
-> Seq Scan on tbl_erp_cash_cost_tickets t (cost=0.00..13.80 rows=1 width=4)
Filter: ((status = ANY ('{2,5}'::integer[])) AND (settle_amount < amount) AND (created_at >= '2025-08-01 00:00:00+08'::timestamp with time zone) AND (created_at <= '2025-08-31 23:59:59+08'::timestamp with time zone))
-> Index Scan using tbl_term_taxonomy_relationships_object_id_term_id_idx on tbl_term_taxonomy_relationships dt1 (cost=0.29..8.31 rows=1 width=14)
Index Cond: ((object_id = t.id) AND (term_id = 18))
Filter: (object_type = 11)
-> Seq Scan on tbl_term_taxonomies tt (cost=0.00..8.24 rows=1 width=4)
Filter: ((serial_no)::text = '221106'::text)