QUERY PLAN
Limit (cost=157.62..157.62 rows=2 width=252)
-> Sort (cost=157.62..157.62 rows=2 width=252)
Sort Key: s.target_completed_at, s.updated_at DESC
-> Group (cost=157.59..157.61 rows=2 width=252)
Group Key: s.id, u.id
-> Sort (cost=157.59..157.60 rows=2 width=252)
Sort Key: s.id, u.id
-> Nested Loop Left Join (cost=0.00..157.59 rows=2 width=252)
Join Filter: (u.id = s.head_of)
-> Seq Scan on tbl_tasks s (cost=0.00..149.79 rows=2 width=248)
Filter: ((parent_id IS NULL) AND (head_of = 5064) AND (status = '0'::smallint))
-> Materialize (cost=0.00..7.77 rows=1 width=4)
-> Seq Scan on tbl_users u (cost=0.00..7.76 rows=1 width=4)
Filter: (id = 5064)