QUERY PLAN
Aggregate (cost=28.84..28.85 rows=1 width=8)
-> Sort (cost=27.41..27.65 rows=95 width=214)
Sort Key: s.created_at DESC
-> HashAggregate (cost=23.34..24.29 rows=95 width=214)
Group Key: s.id
-> Hash Right Join (cost=12.00..23.08 rows=103 width=12)
Hash Cond: (turs.task_group_id = s.id)
-> Seq Scan on tbl_task_group_user_relationships turs (cost=0.00..8.13 rows=513 width=4)
-> Hash (cost=11.76..11.76 rows=19 width=12)
-> Hash Join (cost=7.14..11.76 rows=19 width=12)
Hash Cond: (thrs.task_group_id = s.id)
-> Seq Scan on tbl_task_group_head_of_relationships thrs (cost=0.00..4.58 rows=19 width=4)
Filter: (user_id = 1001)
-> Hash (cost=5.95..5.95 rows=95 width=16)
-> Seq Scan on tbl_task_groups s (cost=0.00..5.95 rows=95 width=16)