QUERY PLAN
Aggregate (cost=21.93..21.94 rows=1 width=8)
-> Sort (cost=21.91..21.91 rows=1 width=218)
Sort Key: s.created_at DESC
-> Group (cost=21.84..21.90 rows=1 width=218)
Group Key: s.id
-> Sort (cost=21.84..21.87 rows=11 width=12)
Sort Key: s.id
-> Hash Right Join (cost=10.85..21.65 rows=11 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.82..10.82 rows=2 width=12)
-> Hash Right Join (cost=6.20..10.82 rows=2 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=1 width=16)
-> Seq Scan on tbl_task_groups s (cost=0.00..6.19 rows=1 width=16)
Filter: (client_id = 518)