QUERY PLAN
Aggregate (cost=63.84..63.85 rows=1 width=8)
-> Sort (cost=63.74..63.76 rows=7 width=228)
Sort Key: s.target_completed_at, s.updated_at DESC
-> Group (cost=63.59..63.64 rows=7 width=228)
Group Key: s.id, u.id
-> Sort (cost=63.59..63.61 rows=7 width=26)
Sort Key: s.id, u.id
-> Hash Join (cost=17.07..63.49 rows=7 width=26)
Hash Cond: (s.head_of = u.id)
-> Seq Scan on tbl_tasks s (cost=0.00..46.30 rows=44 width=34)
Filter: ((parent_id IS NULL) AND (status = '0'::smallint))
-> Hash (cost=16.80..16.80 rows=22 width=4)
-> Seq Scan on tbl_users u (cost=0.00..16.80 rows=22 width=4)
Filter: (department_id = 10)