QUERY PLAN
Aggregate (cost=18.69..18.70 rows=1 width=8)
-> Sort (cost=18.68..18.68 rows=1 width=218)
Sort Key: s.created_at DESC
-> HashAggregate (cost=18.66..18.67 rows=1 width=218)
Group Key: s.id
-> Hash Right Join (cost=8.33..18.62 rows=14 width=12)
Hash Cond: (turs.task_group_id = s.id)
-> Seq Scan on tbl_task_group_user_relationships turs (cost=0.00..7.78 rows=478 width=4)
-> Hash (cost=8.31..8.31 rows=2 width=12)
-> Hash Right Join (cost=5.01..8.31 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..2.80 rows=180 width=4)
-> Hash (cost=5.00..5.00 rows=1 width=16)
-> Seq Scan on tbl_task_groups s (cost=0.00..5.00 rows=1 width=16)
Filter: (client_id = 3081)