QUERY PLAN
Aggregate (cost=45.84..45.85 rows=1 width=8)
-> Sort (cost=45.78..45.79 rows=4 width=160)
Sort Key: s.target_completed_at, s.updated_at DESC
-> Group (cost=45.71..45.74 rows=4 width=160)
Group Key: s.id, u.id
-> Sort (cost=45.71..45.72 rows=4 width=26)
Sort Key: s.id
-> Nested Loop (cost=0.00..45.67 rows=4 width=26)
-> Seq Scan on tbl_users u (cost=0.00..8.09 rows=1 width=4)
Filter: ((id = 1000) AND (department_id = 10))
-> Seq Scan on tbl_tasks s (cost=0.00..37.55 rows=4 width=34)
Filter: ((head_of = 1000) AND (status = '0'::smallint))