QUERY PLAN
Aggregate (cost=35.37..35.38 rows=1 width=8)
-> Sort (cost=34.41..34.57 rows=64 width=222)
Sort Key: s.created_at DESC
-> HashAggregate (cost=31.85..32.49 rows=64 width=222)
Group Key: s.id
-> Hash Right Join (cost=20.22..31.48 rows=149 width=12)
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.88..19.88 rows=27 width=12)
-> Nested Loop (cost=6.94..19.88 rows=27 width=12)
-> Seq Scan on tbl_users thu (cost=0.00..8.16 rows=1 width=4)
Filter: ((id = 1000) AND (department_id = 10))
-> Hash Join (cost=6.94..11.45 rows=27 width=16)
Hash Cond: (thrs.task_group_id = s.id)
-> Seq Scan on tbl_task_group_head_of_relationships thrs (cost=0.00..4.41 rows=39 width=8)
Filter: (user_id = 1000)
-> Hash (cost=6.14..6.14 rows=64 width=16)
-> Seq Scan on tbl_task_groups s (cost=0.00..6.14 rows=64 width=16)
Filter: (status = '1'::smallint)