QUERY PLAN
Aggregate (cost=354.25..354.26 rows=1 width=8)
-> Sort (cost=354.24..354.24 rows=1 width=934)
Sort Key: p.bargain_date DESC, p.updated_at DESC
-> GroupAggregate (cost=354.20..354.23 rows=1 width=934)
Group Key: p.id, r.user_id, (sum(r.pct))
-> Sort (cost=354.20..354.21 rows=1 width=52)
Sort Key: p.id, r.user_id, (sum(r.pct))
-> Nested Loop Left Join (cost=163.84..354.19 rows=1 width=52)
Join Filter: (t.project_id = p.id)
-> Hash Left Join (cost=130.92..321.14 rows=1 width=16)
Hash Cond: (p.client_id = c.id)
Filter: (((c.name)::text ~~* '%六人%'::text) OR (c.pinyin_shortcut ~~* '%六人%'::text) OR (p.pinyin_shortcut ~~* '%六人%'::text) OR ((p.project_title)::text ~~* '%六人%'::text) OR (p.description ~~* '%六人%'::text) OR (p.comment ~~* '%六人%'::text))
-> Seq Scan on tbl_projects p (cost=0.00..189.94 rows=107 width=241)
Filter: ((bargain_date >= '2025-01-01'::date) AND (bargain_date <= '2025-12-31'::date) AND (project_status = 3))
-> Hash (cost=106.52..106.52 rows=1952 width=59)
-> Seq Scan on tbl_clients c (cost=0.00..106.52 rows=1952 width=59)
-> GroupAggregate (cost=32.92..32.98 rows=3 width=40)
Group Key: t.project_id, r.user_id
-> Sort (cost=32.92..32.92 rows=3 width=40)
Sort Key: t.project_id, r.user_id
-> Hash Right Join (cost=13.01..32.89 rows=3 width=40)
Hash Cond: (r.erp_profit_distribute_id = t.id)
-> Seq Scan on tbl_erp_profit_distribute_pcts r (cost=0.00..17.80 rows=780 width=40)
-> Hash (cost=13.00..13.00 rows=1 width=8)
-> Seq Scan on tbl_erp_profit_distributes t (cost=0.00..13.00 rows=1 width=8)
Filter: ((project_id IS NOT NULL) AND (status = 2))