QUERY PLAN
Aggregate (cost=45.51..45.52 rows=1 width=8)
-> Sort (cost=45.45..45.46 rows=4 width=160)
Sort Key: s.target_completed_at, s.updated_at DESC
-> Group (cost=45.38..45.41 rows=4 width=160)
Group Key: s.id, u.id
-> Sort (cost=45.38..45.39 rows=4 width=26)
Sort Key: s.id, u.id
-> Nested Loop Left Join (cost=0.00..45.34 rows=4 width=26)
Join Filter: (u.id = s.head_of)
-> Seq Scan on tbl_tasks s (cost=0.00..37.55 rows=4 width=34)
Filter: ((head_of = 1000) AND (status = '0'::smallint))
-> Materialize (cost=0.00..7.74 rows=1 width=4)
-> Seq Scan on tbl_users u (cost=0.00..7.74 rows=1 width=4)
Filter: (id = 1000)