QUERY PLAN
Limit (cost=84.21..84.24 rows=10 width=204)
-> Sort (cost=84.21..85.61 rows=560 width=204)
Sort Key: s.status, s.target_completed_at, s.updated_at DESC
-> HashAggregate (cost=66.51..72.11 rows=560 width=204)
Group Key: s.id, u.id
-> Hash Join (cost=17.66..63.71 rows=560 width=204)
Hash Cond: (s.head_of = u.id)
-> Seq Scan on tbl_tasks s (cost=0.00..42.89 rows=1169 width=200)
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)