QUERY PLAN
Aggregate (cost=66.80..66.81 rows=1 width=8)
-> Sort (cost=66.75..66.76 rows=3 width=218)
Sort Key: s.created_at DESC
-> HashAggregate (cost=66.70..66.73 rows=3 width=218)
Group Key: s.id
-> Nested Loop (cost=45.87..66.55 rows=59 width=12)
-> Index Scan using tbl_users_pkey on tbl_users u (cost=0.14..8.16 rows=1 width=4)
Index Cond: (id = 1000)
Filter: (department_id = 10)
-> Hash Right Join (cost=45.72..57.80 rows=59 width=16)
Hash Cond: (turs.task_group_id = s.id)
-> Seq Scan on tbl_task_group_user_relationships turs (cost=0.00..7.83 rows=483 width=4)
-> Hash (cost=45.57..45.57 rows=12 width=16)
-> Hash Right Join (cost=38.42..45.57 rows=12 width=16)
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=38.38..38.38 rows=3 width=16)
-> Nested Loop Left Join (cost=0.28..38.38 rows=3 width=16)
Filter: ((lower((client.name)::text) ~~ '%2%'::text) OR (client.pinyin_shortcut ~~ '%2%'::text) OR (lower((s.title)::text) ~~ '%2%'::text) OR (lower(s.description) ~~ '%2%'::text))
-> Seq Scan on tbl_task_groups s (cost=0.00..13.41 rows=3 width=124)
Filter: ((head_of = 1000) AND (status = '2'::smallint))
-> Index Scan using tbl_clients_pkey on tbl_clients client (cost=0.28..8.29 rows=1 width=59)
Index Cond: (id = s.client_id)
Filter: (NOT deleted)