QUERY PLAN
Sort (cost=1256.37..1256.57 rows=81 width=88)
Sort Key: (COALESCE(sum(r.amount), '0'::numeric)) DESC
-> GroupAggregate (cost=1251.98..1253.80 rows=81 width=88)
Group Key: r.created_by, tt.id
-> Sort (cost=1251.98..1252.18 rows=81 width=25)
Sort Key: r.created_by, tt.id
-> Nested Loop Left Join (cost=0.44..1249.41 rows=81 width=25)
-> Nested Loop Left Join (cost=0.29..1235.16 rows=81 width=13)
-> Seq Scan on tbl_reimbursements r (cost=0.00..429.38 rows=81 width=13)
Filter: ((occurrence_at >= '2026-01-01 00:00:00+08'::timestamp with time zone) AND (occurrence_at <= '2026-12-31 23:59:59+08'::timestamp with time zone) AND (status = ANY ('{1,2,3}'::integer[])) AND (created_by = ANY ('{5332,1001,5087,5467,5300,5311,5295,1013,5476,1004,1005,5449}'::integer[])))
-> Index Scan using tbl_term_taxonomy_relationships_object_id_term_id_idx on tbl_term_taxonomy_relationships ttr (cost=0.29..9.94 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)