QUERY PLAN
Limit (cost=64.74..64.75 rows=1 width=194)
-> Sort (cost=64.74..64.75 rows=1 width=194)
Sort Key: s.target_completed_at, s.updated_at DESC
-> Group (cost=64.72..64.73 rows=1 width=194)
Group Key: s.id, u.id
-> Sort (cost=64.72..64.73 rows=1 width=194)
Sort Key: s.id, u.id
-> Hash Join (cost=16.85..64.71 rows=1 width=194)
Hash Cond: (s.head_of = u.id)
-> Seq Scan on tbl_tasks s (cost=0.00..47.75 rows=42 width=190)
Filter: ((parent_id IS NULL) AND (status = '0'::smallint))
-> Hash (cost=16.80..16.80 rows=4 width=4)
-> Seq Scan on tbl_users u (cost=0.00..16.80 rows=4 width=4)
Filter: (department_id = 3)