QUERY PLAN
Aggregate (cost=162.38..162.39 rows=1 width=8)
-> Sort (cost=162.03..162.09 rows=23 width=222)
Sort Key: s.created_at DESC
-> Group (cost=161.40..161.51 rows=23 width=222)
Group Key: s.id
-> Sort (cost=161.40..161.46 rows=23 width=12)
Sort Key: s.id
-> Nested Loop (cost=142.48..160.88 rows=23 width=12)
-> Seq Scan on tbl_users thu (cost=0.00..8.16 rows=1 width=4)
Filter: ((id = 1000) AND (department_id = 10))
-> Hash Right Join (cost=142.48..152.49 rows=23 width=16)
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=142.43..142.43 rows=4 width=16)
-> Nested Loop Left Join (cost=7.33..142.43 rows=4 width=16)
Filter: ((lower((client.name)::text) ~~ '%bug%'::text) OR (client.pinyin_shortcut ~~ '%bug%'::text) OR (lower((s.title)::text) ~~ '%bug%'::text) OR (lower(s.description) ~~ '%bug%'::text))
-> Hash Join (cost=7.05..11.56 rows=39 width=126)
Hash Cond: (thrs.task_group_id = s.id)
-> Seq Scan on tbl_task_group_head_of_relationships thrs (cost=0.00..4.41 rows=39 width=8)
Filter: (user_id = 1000)
-> Hash (cost=5.91..5.91 rows=91 width=122)
-> Seq Scan on tbl_task_groups s (cost=0.00..5.91 rows=91 width=122)
-> Index Scan using tbl_clients_pkey on tbl_clients client (cost=0.28..3.33 rows=1 width=59)
Index Cond: (id = s.client_id)
Filter: (NOT deleted)