QUERY PLAN
Limit (cost=44.44..44.46 rows=10 width=145)
-> Sort (cost=44.44..44.48 rows=18 width=145)
Sort Key: s.status, s.target_completed_at DESC, s.updated_at DESC
-> Group (cost=43.93..44.06 rows=18 width=145)
Group Key: s.id, u.id
-> Sort (cost=43.93..43.97 rows=18 width=145)
Sort Key: s.id
-> Nested Loop (cost=0.00..43.55 rows=18 width=145)
-> Seq Scan on tbl_users u (cost=0.00..8.09 rows=1 width=4)
Filter: ((id = 1001) AND (department_id = 4))
-> Seq Scan on tbl_tasks s (cost=0.00..35.29 rows=18 width=141)
Filter: (head_of = 1001)