QUERY PLAN
Aggregate (cost=428.41..428.42 rows=1 width=8)
-> Sort (cost=428.39..428.40 rows=1 width=870)
Sort Key: p.bargain_date DESC, p.updated_at DESC
-> Hash Left Join (cost=310.03..428.38 rows=1 width=870)
Hash Cond: (p.created_by = u2.id)
Filter: (((c.name)::text ~~* '%北京贝瑞和康生物技术有限公司%'::text) OR (c.pinyin_shortcut ~~* '%北京贝瑞和康生物技术有限公司%'::text) OR (p.pinyin_shortcut ~~* '%北京贝瑞和康生物技术有限公司%'::text) OR ((p.project_title)::text ~~* '%北京贝瑞和康生物技术有限公司%'::text) OR ((u2.name)::text ~~* '%北京贝瑞和康生物技术有限公司%'::text))
-> Hash Right Join (cost=291.79..410.00 rows=53 width=102)
Hash Cond: (c.id = p.client_id)
-> Seq Scan on tbl_clients c (cost=0.00..110.13 rows=2013 width=59)
-> Hash (cost=291.13..291.13 rows=53 width=51)
-> Subquery Scan on p (cost=289.54..291.13 rows=53 width=51)
-> GroupAggregate (cost=289.54..290.60 rows=53 width=567)
Group Key: p_1.id, pd.user_id, pd.pct
-> Sort (cost=289.54..289.67 rows=53 width=91)
Sort Key: p_1.id, pd.user_id, pd.pct
-> Hash Left Join (cost=214.76..288.02 rows=53 width=91)
Hash Cond: (p_1.id = pd.project_id)
-> Hash Right Join (cost=200.65..273.70 rows=53 width=55)
Hash Cond: (sc.from_project = p_1.id)
-> Seq Scan on tbl_sales_contracts sc (cost=0.00..68.46 rows=1746 width=4)
-> Hash (cost=199.99..199.99 rows=53 width=55)
-> Seq Scan on tbl_projects p_1 (cost=0.00..199.99 rows=53 width=55)
Filter: ((bargain_date >= '2026-01-01'::date) AND (bargain_date <= '2026-12-31'::date) AND (project_status = 3))
-> Hash (cost=14.10..14.10 rows=1 width=40)
-> Subquery Scan on pd (cost=14.06..14.10 rows=1 width=40)
-> GroupAggregate (cost=14.06..14.09 rows=1 width=40)
Group Key: t.project_id, r.user_id
-> Sort (cost=14.06..14.07 rows=1 width=13)
Sort Key: t.project_id, r.user_id
-> Nested Loop Left Join (cost=0.00..14.05 rows=1 width=13)
Join Filter: (t.id = r.erp_profit_distribute_id)
-> Seq Scan on tbl_erp_profit_distributes t (cost=0.00..12.88 rows=1 width=8)
Filter: ((project_id IS NOT NULL) AND (status = 2))
-> Seq Scan on tbl_erp_profit_distribute_pcts r (cost=0.00..1.08 rows=8 width=13)
-> Hash (cost=16.44..16.44 rows=144 width=13)
-> Seq Scan on tbl_users u2 (cost=0.00..16.44 rows=144 width=13)