QUERY PLAN
Limit (cost=161.21..161.23 rows=10 width=396)
-> Sort (cost=161.21..161.26 rows=23 width=396)
Sort Key: s.created_at DESC
-> Group (cost=160.42..160.71 rows=23 width=396)
Group Key: s.id
-> Sort (cost=160.42..160.48 rows=23 width=372)
Sort Key: s.id
-> Nested Loop (cost=141.50..159.90 rows=23 width=372)
-> 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=141.50..151.51 rows=23 width=376)
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=141.45..141.45 rows=4 width=376)
-> Hash Right Join (cost=12.05..141.45 rows=4 width=376)
Hash Cond: (client.id = s.client_id)
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))
-> Seq Scan on tbl_clients client (cost=0.00..108.98 rows=1998 width=59)
Filter: (NOT deleted)
-> Hash (cost=11.56..11.56 rows=39 width=376)
-> Hash Join (cost=7.05..11.56 rows=39 width=376)
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=372)
-> Seq Scan on tbl_task_groups s (cost=0.00..5.91 rows=91 width=372)