QUERY PLAN
Aggregate (cost=57.45..57.46 rows=1 width=8)
-> Sort (cost=56.85..56.95 rows=40 width=228)
Sort Key: s.created_at
-> HashAggregate (cost=55.38..55.78 rows=40 width=228)
Group Key: s.id, u.id
-> Nested Loop (cost=0.00..55.18 rows=40 width=16)
-> Seq Scan on tbl_users u (cost=0.00..8.16 rows=1 width=4)
Filter: ((id = 1001) AND (department_id = 4))
-> Seq Scan on tbl_tasks s (cost=0.00..46.62 rows=40 width=24)
Filter: ((parent_id IS NULL) AND (head_of = 1001))