QUERY PLAN
Limit (cost=35.05..35.07 rows=10 width=396)
-> Sort (cost=35.05..35.28 rows=91 width=396)
Sort Key: s.created_at DESC
-> HashAggregate (cost=31.49..33.08 rows=91 width=396)
Group Key: s.id
-> Hash Right Join (cost=19.73..31.09 rows=160 width=372)
Hash Cond: (turs.task_group_id = s.id)
-> Seq Scan on tbl_task_group_user_relationships turs (cost=0.00..7.94 rows=494 width=4)
-> Hash (cost=19.36..19.36 rows=29 width=372)
-> Hash Right Join (cost=14.41..19.36 rows=29 width=372)
Hash Cond: (thrs.task_group_id = s.id)
-> Seq Scan on tbl_task_group_head_of_relationships thrs (cost=0.00..3.93 rows=193 width=4)
-> Hash (cost=14.23..14.23 rows=14 width=372)
-> Hash Join (cost=8.07..14.23 rows=14 width=372)
Hash Cond: (s.head_of = u.id)
-> Seq Scan on tbl_task_groups s (cost=0.00..5.91 rows=91 width=372)
-> Hash (cost=7.80..7.80 rows=22 width=4)
-> Seq Scan on tbl_users u (cost=0.00..7.80 rows=22 width=4)
Filter: (department_id = 10)