QUERY PLAN
GroupAggregate (cost=304.77..304.81 rows=2 width=24)
Group Key: dt1.taxonomy_id, t1.name
-> Sort (cost=304.77..304.77 rows=2 width=20)
Sort Key: dt1.taxonomy_id, t1.name
-> Nested Loop Left Join (cost=0.44..304.76 rows=2 width=20)
-> Nested Loop Left Join (cost=0.29..304.41 rows=2 width=8)
-> Seq Scan on tbl_approves r (cost=0.00..287.77 rows=2 width=12)
Filter: ((status <> 0) AND (created_at >= '2026-03-01 00:00:00+08'::timestamp with time zone) AND (created_at <= '2026-03-31 23:59:59+08'::timestamp with time zone) AND (created_by = 5087) AND ((status = '1'::smallint) OR (status = '2'::smallint)) AND (created_by = ANY ('{1000,1001,1004,1005,1011,1013,1015,1022,1023,5016,5064,5085,5087,5248,5250,5252,5295,5300,5311,5332,5360,5446,5461,5476,5499,5500}'::integer[])))
-> 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=8)
Index Cond: ((object_id = r.id) AND (term_id = 17))
-> Index Scan using tbl_term_taxonomies_pkey on tbl_term_taxonomies t1 (cost=0.15..0.17 rows=1 width=16)
Index Cond: (dt1.taxonomy_id = id)