QUERY PLAN
GroupAggregate (cost=3102.08..3108.83 rows=200 width=12)
Group Key: tbl_work_logs.created_by
-> Sort (cost=3102.08..3103.66 rows=633 width=8)
Sort Key: tbl_work_logs.created_by
-> HashAggregate (cost=3059.97..3066.30 rows=633 width=8)
Group Key: tbl_work_logs.created_by, tbl_work_logs.client_id
-> Append (cost=316.80..3056.80 rows=633 width=8)
-> Bitmap Heap Scan on tbl_work_logs (cost=316.80..2263.53 rows=540 width=8)
Recheck Cond: (created_by = ANY ('{5500,5499,5332,1001,5087,5467,5300,5311,5295,1013,5476,1004,1005,5449}'::integer[]))
Filter: ((NOT is_draft) AND (client_id IS NOT NULL) AND (start_at >= '2025-01-01 00:00:00+08'::timestamp with time zone) AND (start_at <= '2025-06-29 23:59:59+08'::timestamp with time zone))
-> Bitmap Index Scan on tbl_work_logs_created_by_idx (cost=0.00..316.67 rows=18207 width=0)
Index Cond: (created_by = ANY ('{5500,5499,5332,1001,5087,5467,5300,5311,5295,1013,5476,1004,1005,5449}'::integer[]))
-> Bitmap Heap Scan on tbl_schedules (cost=145.04..786.94 rows=93 width=8)
Recheck Cond: (created_by = ANY ('{5500,5499,5332,1001,5087,5467,5300,5311,5295,1013,5476,1004,1005,5449}'::integer[]))
Filter: ((client_id IS NOT NULL) AND (created_at >= '2025-01-01 00:00:00+08'::timestamp with time zone) AND (created_at <= '2025-06-29 23:59:59+08'::timestamp with time zone))
-> Bitmap Index Scan on tbl_schedules_created_by_idx (cost=0.00..145.02 rows=7074 width=0)
Index Cond: (created_by = ANY ('{5500,5499,5332,1001,5087,5467,5300,5311,5295,1013,5476,1004,1005,5449}'::integer[]))