QUERY PLAN
Aggregate (cost=69.26..69.27 rows=1 width=8)
-> Sort (cost=66.84..67.25 rows=161 width=228)
Sort Key: s.created_at
-> HashAggregate (cost=59.33..60.94 rows=161 width=228)
Group Key: s.id, u.id
-> Hash Join (cost=8.07..58.53 rows=161 width=16)
Hash Cond: (s.head_of = u.id)
-> Seq Scan on tbl_tasks s (cost=0.00..47.61 rows=1052 width=24)
Filter: ((parent_id IS NULL) AND (status = '1'::smallint))
-> Hash (cost=7.80..7.80 rows=22 width=4)
-> Seq Scan on tbl_users u (cost=0.00..7.80 rows=22 width=4)
Filter: (department_id = 10)