QUERY PLAN
Limit (cost=51.30..51.31 rows=4 width=149)
-> Sort (cost=51.30..51.31 rows=4 width=149)
Sort Key: s.target_completed_at, s.updated_at DESC
-> Group (cost=51.23..51.27 rows=4 width=149)
Group Key: s.id, u.id
-> Sort (cost=51.23..51.24 rows=4 width=149)
Sort Key: s.id, u.id
-> Nested Loop Left Join (cost=0.00..51.20 rows=4 width=149)
Join Filter: (u.id = s.head_of)
-> Seq Scan on tbl_tasks s (cost=0.00..43.37 rows=4 width=145)
Filter: ((head_of = 1000) 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 = 1000)