QUERY PLAN
Limit (cost=38.43..38.44 rows=1 width=428)
-> Sort (cost=38.43..38.44 rows=1 width=428)
Sort Key: s.created_at DESC
-> Group (cost=38.41..38.42 rows=1 width=428)
Group Key: s.id
-> Sort (cost=38.41..38.41 rows=1 width=408)
Sort Key: s.id
-> Hash Join (cost=29.19..38.40 rows=1 width=408)
Hash Cond: (turs.task_group_id = s.id)
-> Seq Scan on tbl_task_group_user_relationships turs (cost=0.00..9.04 rows=42 width=4)
Filter: (user_id = 1000)
-> Hash (cost=29.17..29.17 rows=2 width=408)
-> Hash Right Join (cost=22.06..29.17 rows=2 width=408)
Hash Cond: (thrs.task_group_id = s.id)
-> Seq Scan on tbl_task_group_head_of_relationships thrs (cost=0.00..5.70 rows=370 width=4)
-> Hash (cost=22.05..22.05 rows=1 width=408)
-> Hash Join (cost=16.81..22.05 rows=1 width=408)
Hash Cond: (s.head_of = u.id)
-> Seq Scan on tbl_task_groups s (cost=0.00..5.06 rows=65 width=408)
Filter: (status = '1'::smallint)
-> Hash (cost=16.80..16.80 rows=1 width=4)
-> Seq Scan on tbl_users u (cost=0.00..16.80 rows=1 width=4)
Filter: (department_id = 7)