QUERY PLAN
Aggregate (cost=21.92..21.93 rows=1 width=8)
-> Sort (cost=21.89..21.90 rows=2 width=218)
Sort Key: s.created_at DESC
-> HashAggregate (cost=21.86..21.88 rows=2 width=218)
Group Key: s.id
-> Hash Right Join (cost=10.89..21.80 rows=24 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=10.84..10.84 rows=4 width=12)
-> Hash Right Join (cost=6.21..10.84 rows=4 width=12)
Hash Cond: (thrs.task_group_id = s.id)
-> Seq Scan on tbl_task_group_head_of_relationships thrs (cost=0.00..4.06 rows=206 width=4)
-> Hash (cost=6.19..6.19 rows=2 width=16)
-> Seq Scan on tbl_task_groups s (cost=0.00..6.19 rows=2 width=16)
Filter: (client_id = 982)