QUERY PLAN
Sort (cost=314.05..314.05 rows=1 width=84)
Sort Key: (COALESCE(sum(r.amount), '0'::numeric)) DESC
-> GroupAggregate (cost=314.02..314.04 rows=1 width=84)
Group Key: tt.id
-> Sort (cost=314.02..314.02 rows=1 width=21)
Sort Key: tt.id
-> Nested Loop Left Join (cost=0.44..314.01 rows=1 width=21)
-> Nested Loop Left Join (cost=0.29..313.83 rows=1 width=9)
-> Seq Scan on tbl_reimbursements r (cost=0.00..302.26 rows=1 width=9)
Filter: ((occurrence_at >= '2026-05-29 00:00:00+08'::timestamp with time zone) AND (occurrence_at <= '2026-05-29 23:59:59+08'::timestamp with time zone) AND (status = ANY ('{1,2,3}'::integer[])))
-> Index Scan using tbl_term_taxonomy_relationships_object_id_term_id_idx on tbl_term_taxonomy_relationships ttr (cost=0.29..11.56 rows=1 width=8)
Index Cond: ((object_id = r.id) AND (term_id = 18))
Filter: (object_type = 7)
-> Index Scan using tbl_term_taxonomies_pkey on tbl_term_taxonomies tt (cost=0.15..0.18 rows=1 width=16)
Index Cond: (id = ttr.taxonomy_id)