QUERY PLAN
Aggregate (cost=56.26..56.27 rows=1 width=8)
-> Sort (cost=56.22..56.23 rows=3 width=228)
Sort Key: s.target_completed_at, s.updated_at DESC
-> Group (cost=56.17..56.19 rows=3 width=228)
Group Key: s.id, u.id
-> Sort (cost=56.17..56.18 rows=3 width=26)
Sort Key: s.id, u.id
-> Hash Join (cost=7.91..56.15 rows=3 width=26)
Hash Cond: (s.head_of = u.id)
-> Seq Scan on tbl_tasks s (cost=0.00..48.12 rows=42 width=34)
Filter: ((parent_id IS NULL) AND (status = '0'::smallint))
-> Hash (cost=7.80..7.80 rows=9 width=4)
-> Seq Scan on tbl_users u (cost=0.00..7.80 rows=9 width=4)
Filter: (department_id = 9)