QUERY PLAN
Limit (cost=62.39..62.40 rows=3 width=384)
-> Sort (cost=62.39..62.40 rows=3 width=384)
Sort Key: s.created_at DESC
-> HashAggregate (cost=62.31..62.36 rows=3 width=384)
Group Key: s.id
-> Nested Loop (cost=43.35..62.23 rows=31 width=364)
-> 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=43.20..53.76 rows=31 width=364)
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=43.13..43.13 rows=6 width=364)
-> Hash Right Join (cost=38.42..43.13 rows=6 width=364)
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=38.38..38.38 rows=3 width=364)
-> Nested Loop Left Join (cost=0.28..38.38 rows=3 width=364)
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=364)
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)