QUERY PLAN
Aggregate (cost=45.34..45.35 rows=1 width=8)
-> Sort (cost=45.33..45.33 rows=1 width=160)
Sort Key: s.target_completed_at, s.updated_at DESC
-> Group (cost=45.30..45.32 rows=1 width=160)
Group Key: s.id, u.id
-> Sort (cost=45.30..45.31 rows=1 width=26)
Sort Key: s.id, u.id
-> Nested Loop Left Join (cost=0.00..45.30 rows=1 width=26)
Join Filter: (u.id = s.head_of)
-> Seq Scan on tbl_tasks s (cost=0.00..37.55 rows=1 width=34)
Filter: ((head_of = 5295) AND (status = 0))
-> Seq Scan on tbl_users u (cost=0.00..7.74 rows=1 width=4)
Filter: (id = 5295)