QUERY PLAN
Aggregate (cost=21.43..21.44 rows=1 width=8)
-> Sort (cost=21.41..21.41 rows=1 width=222)
Sort Key: s.created_at DESC
-> Group (cost=21.34..21.40 rows=1 width=222)
Group Key: s.id
-> Sort (cost=21.34..21.37 rows=11 width=12)
Sort Key: s.id
-> Hash Right Join (cost=10.63..21.15 rows=11 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=10.61..10.61 rows=2 width=12)
-> Hash Right Join (cost=6.15..10.61 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..3.93 rows=193 width=4)
-> Hash (cost=6.14..6.14 rows=1 width=20)
-> Seq Scan on tbl_task_groups s (cost=0.00..6.14 rows=1 width=20)
Filter: (client_id = 399)