QUERY PLAN
Aggregate (cost=157.96..157.97 rows=1 width=8)
-> Sort (cost=157.55..157.62 rows=27 width=228)
Sort Key: s.target_completed_at, s.updated_at DESC
-> Group (cost=156.71..156.91 rows=27 width=228)
Group Key: s.id, u.id
-> Sort (cost=156.71..156.78 rows=27 width=26)
Sort Key: s.id, u.id
-> Hash Left Join (cost=9.17..156.07 rows=27 width=26)
Hash Cond: (s.head_of = u.id)
-> Seq Scan on tbl_tasks s (cost=0.00..146.82 rows=27 width=34)
Filter: ((parent_id IS NULL) AND (status = '0'::smallint))
-> Hash (cost=7.41..7.41 rows=141 width=4)
-> Seq Scan on tbl_users u (cost=0.00..7.41 rows=141 width=4)