QUERY PLAN
Aggregate (cost=27.56..27.57 rows=1 width=8)
-> Sort (cost=26.25..26.47 rows=87 width=214)
Sort Key: s.created_at DESC
-> HashAggregate (cost=22.58..23.45 rows=87 width=214)
Group Key: s.id
-> Hash Right Join (cost=11.70..22.36 rows=87 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=11.50..11.50 rows=16 width=12)
-> Hash Join (cost=7.05..11.50 rows=16 width=12)
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=4)
Filter: (user_id = 1001)
-> Hash (cost=5.91..5.91 rows=91 width=16)
-> Seq Scan on tbl_task_groups s (cost=0.00..5.91 rows=91 width=16)