QUERY PLAN
GroupAggregate (cost=773.75..773.85 rows=6 width=12)
Group Key: created_by
-> Sort (cost=773.75..773.76 rows=6 width=4)
Sort Key: created_by
-> Bitmap Heap Scan on tbl_schedules (cost=132.16..773.67 rows=6 width=4)
Recheck Cond: (created_by = ANY ('{5332,1001,5087,5467,5300,5311,5295,1013,5476,1004,1005,5449}'::integer[]))
Filter: ((created_at >= '2025-01-01 00:00:00+08'::timestamp with time zone) AND (created_at <= '2025-06-02 23:59:59+08'::timestamp with time zone) AND ((complete_at IS NULL) OR (complete_at > '2025-06-02 23:59:59+08'::timestamp with time zone)))
-> Bitmap Index Scan on tbl_schedules_created_by_idx (cost=0.00..132.16 rows=7031 width=0)
Index Cond: (created_by = ANY ('{5332,1001,5087,5467,5300,5311,5295,1013,5476,1004,1005,5449}'::integer[]))