QUERY PLAN
Aggregate (cost=106.07..106.08 rows=1 width=8)
-> Sort (cost=97.67..99.07 rows=560 width=228)
Sort Key: s.status, s.target_completed_at, s.updated_at DESC
-> HashAggregate (cost=66.51..72.11 rows=560 width=228)
Group Key: s.id, u.id
-> Hash Join (cost=17.66..63.71 rows=560 width=26)
Hash Cond: (s.head_of = u.id)
-> Seq Scan on tbl_tasks s (cost=0.00..42.89 rows=1169 width=34)
Filter: (parent_id IS NULL)
-> Hash (cost=16.80..16.80 rows=69 width=4)
-> Seq Scan on tbl_users u (cost=0.00..16.80 rows=69 width=4)
Filter: (department_id = 1)