QUERY PLAN
Sort (cost=1166.28..1166.46 rows=71 width=88)
Sort Key: (COALESCE(sum(r.amount), '0'::numeric)) DESC
-> GroupAggregate (cost=1162.50..1164.10 rows=71 width=88)
Group Key: r.created_by, tt.id
-> Sort (cost=1162.50..1162.68 rows=71 width=25)
Sort Key: r.created_by, tt.id
-> Nested Loop Left Join (cost=0.44..1160.32 rows=71 width=25)
-> Nested Loop Left Join (cost=0.29..1147.82 rows=71 width=13)
-> Seq Scan on tbl_reimbursements r (cost=0.00..428.06 rows=71 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..10.13 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)