QUERY PLAN
Limit (cost=34.30..34.33 rows=10 width=396)
-> Sort (cost=34.30..34.52 rows=87 width=396)
Sort Key: s.created_at DESC
-> HashAggregate (cost=30.90..32.42 rows=87 width=396)
Group Key: s.id
-> Hash Right Join (cost=20.02..30.68 rows=87 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.82..19.82 rows=16 width=372)
-> Nested Loop (cost=7.05..19.82 rows=16 width=372)
-> Seq Scan on tbl_users thu (cost=0.00..8.16 rows=1 width=4)
Filter: ((id = 1001) AND (department_id = 4))
-> Hash Join (cost=7.05..11.50 rows=16 width=376)
Hash Cond: (thrs.task_group_id = s.id)
-> Seq Scan on tbl_task_group_head_of_relationships thrs (cost=0.00..4.41 rows=16 width=8)
Filter: (user_id = 1001)
-> Hash (cost=5.91..5.91 rows=91 width=372)
-> Seq Scan on tbl_task_groups s (cost=0.00..5.91 rows=91 width=372)