| Limit (cost=7350.31..7350.53 rows=1 width=1050) |
| -> Result (cost=7350.31..7350.53 rows=1 width=1050) |
| -> Sort (cost=7350.31..7350.31 rows=1 width=1134) |
| Sort Key: (CASE WHEN ((sum(CASE WHEN (p.project_status = 3) THEN p.budget ELSE '0'::numeric END)) IS NULL) THEN '0'::numeric ELSE (sum(CASE WHEN (p.project_status = 3) THEN p.budget ELSE '0'::numeric END)) END) DESC, c.created_at DESC |
| -> Nested Loop Left Join (cost=6640.40..7350.30 rows=1 width=1134) |
| Join Filter: (ct.id = c.client_type) |
| -> Nested Loop Left Join (cost=6640.40..7349.14 rows=1 width=955) |
| Join Filter: (ci.id = c.client_industry) |
| -> Nested Loop Left Join (cost=6640.40..7347.57 rows=1 width=809) |
| Join Filter: (cc.id = c.client_class) |
| -> Nested Loop Left Join (cost=6640.40..7346.48 rows=1 width=769) |
| Join Filter: (sc.client_id = c.id) |
| -> Nested Loop Left Join (cost=6378.61..7077.19 rows=1 width=705) |
| Join Filter: (c_1.client_id = c.id) |
| -> Nested Loop Left Join (cost=5411.41..6102.99 rows=1 width=673) |
| Join Filter: (r.client_id = c.id) |
| -> Nested Loop Left Join (cost=5120.43..5796.88 rows=1 width=641) |
| Join Filter: (wl.client_id = c.id) |
| -> Nested Loop Left Join (cost=1213.56..1849.78 rows=1 width=497) |
| Join Filter: (ir.client_id = c.id) |
| -> Nested Loop Left Join (cost=704.87..1333.07 rows=1 width=473) |
| Join Filter: (ps.client_id = c.id) |
| -> Nested Loop Left Join (cost=576.30..1194.23 rows=1 width=449) |
| Join Filter: (p_1.client_id = c.id) |
| -> Nested Loop Left Join (cost=368.46..953.56 rows=1 width=409) |
| Join Filter: (p.client_id = c.id) |
| -> Nested Loop Left Join (cost=85.56..475.22 rows=1 width=117) |
| Join Filter: ((csrr.client_id = c.id) AND (csrr.sales_rep = c.sales_rep)) |
| -> Seq Scan on tbl_clients c (cost=9.67..308.51 rows=1 width=117) |
| Filter: ((NOT deleted) AND ((lower((name)::text) ~~ '%测阿斯顿%'::text) OR (pinyin_shortcut ~~ '%测阿斯顿%'::text)) AND ((sales_rep = ANY ('{1001,5049,5301,5022,5209,5026,5293,5309,5356,5329,5299,5303,5302,5332,5047,1026,5096,5070,5448,5420,1029,5037,5087,1008,5048,5043,5045,5230,5031,5088,5208,1003,5467,5294,5357,5044,1030,5076,5300,5027,5089,5311,5066,5069,5364,1009,5295,1013,5128,5203,1025,5032,5075,5476,1004,5072,5033,5359,5412,5409,5229,1005,5304,5449,5358,1006,5093}'::integer[])) OR (sales_rep IS NULL) OR (hashed SubPlan 1))) |
| SubPlan 1 |
| -> Seq Scan on tbl_user_visit_clients (cost=0.00..9.66 rows=1 width=4) |
| Filter: (user_id = 1001) |
| -> Hash Join (cost=75.90..146.04 rows=1378 width=8) |
| Hash Cond: (csrr.id = "ANY_subquery".max) |
| -> Seq Scan on tbl_client_sales_rep_rels csrr (cost=0.00..47.57 rows=2757 width=12) |
| -> Hash (cost=73.40..73.40 rows=200 width=4) |
| -> HashAggregate (cost=71.40..73.40 rows=200 width=4) |
| Group Key: "ANY_subquery".max |
| -> Subquery Scan on "ANY_subquery" (cost=52.50..69.30 rows=840 width=4) |
| -> HashAggregate (cost=52.50..60.90 rows=840 width=8) |
| Group Key: csrrs.client_id |
| -> Seq Scan on tbl_client_sales_rep_rels csrrs (cost=0.00..47.57 rows=986 width=8) |
| Filter: (end_at IS NULL) |
| -> GroupAggregate (cost=282.90..458.58 rows=878 width=296) |
| Group Key: p.client_id |
| -> Sort (cost=282.90..287.29 rows=1757 width=34) |
| Sort Key: p.client_id |
| -> Seq Scan on tbl_projects p (cost=0.00..188.20 rows=1757 width=34) |
| Filter: (project_status = ANY ('{1,2,3}'::integer[])) |
| -> HashAggregate (cost=207.84..219.56 rows=938 width=44) |
| Group Key: p_1.client_id |
| -> Seq Scan on tbl_projects p_1 (cost=0.00..176.42 rows=3142 width=17) |
| -> HashAggregate (cost=128.57..131.73 rows=316 width=28) |
| Group Key: ps.client_id |
| -> Hash Left Join (cost=1.61..112.29 rows=1628 width=24) |
| Hash Cond: (ps.created_by = egr.engineer_id) |
| -> Seq Scan on tbl_pre_sales ps (cost=0.00..88.30 rows=1628 width=28) |
| Filter: (NOT is_draft) |
| -> Hash (cost=1.27..1.27 rows=27 width=4) |
| -> Seq Scan on tbl_engineer_group_relationships egr (cost=0.00..1.27 rows=27 width=4) |
| -> HashAggregate (cost=508.68..511.15 rows=247 width=28) |
| Group Key: ir.client_id |
| -> Hash Left Join (cost=1.61..438.45 rows=7023 width=24) |
| Hash Cond: (ir.created_by = egr_1.engineer_id) |
| -> Seq Scan on tbl_implement_records ir (cost=0.00..340.28 rows=7023 width=28) |
| Filter: (NOT is_draft) |
| -> Hash (cost=1.27..1.27 rows=27 width=4) |
| -> Seq Scan on tbl_engineer_group_relationships egr_1 (cost=0.00..1.27 rows=27 width=4) |
| -> HashAggregate (cost=3906.87..3919.25 rows=1238 width=148) |
| Group Key: wl.client_id |
| -> Seq Scan on tbl_work_logs wl (cost=0.00..1713.31 rows=30256 width=36) |
| Filter: ((NOT is_draft) AND (client_id IS NOT NULL)) |
| -> HashAggregate (cost=290.98..296.38 rows=432 width=36) |
| Group Key: r.client_id |
| -> Seq Scan on tbl_reimbursements r (cost=0.00..249.84 rows=8229 width=9) |
| Filter: (status = ANY ('{2,3}'::integer[])) |
| -> HashAggregate (cost=967.20..969.70 rows=200 width=36) |
| Group Key: c_1.client_id |
| -> HashAggregate (cost=733.07..839.49 rows=8514 width=40) |
| Group Key: c_1.id |
| -> Hash Left Join (cost=375.17..690.22 rows=8570 width=16) |
| Hash Cond: (ca.engineer_id = egr_2.engineer_id) |
| -> Hash Right Join (cost=373.56..570.77 rows=8570 width=20) |
| Hash Cond: (ca.case_id = c_1.id) |
| -> Seq Scan on tbl_case_assignments ca (cost=0.00..174.70 rows=8570 width=16) |
| -> Hash (cost=267.14..267.14 rows=8514 width=8) |
| -> Seq Scan on tbl_cases c_1 (cost=0.00..267.14 rows=8514 width=8) |
| -> Hash (cost=1.27..1.27 rows=27 width=4) |
| -> Seq Scan on tbl_engineer_group_relationships egr_2 (cost=0.00..1.27 rows=27 width=4) |
| -> HashAggregate (cost=261.79..264.79 rows=200 width=68) |
| Group Key: sc.client_id |
| -> HashAggregate (cost=201.42..222.98 rows=1725 width=47) |
| Group Key: sc.id |
| -> Hash Right Join (cost=139.81..190.75 rows=2133 width=21) |
| Hash Cond: (sci.contract_id = sc.id) |
| -> Seq Scan on tbl_sales_contract_invoices sci (cost=0.00..45.33 rows=2133 width=10) |
| -> Hash (cost=118.25..118.25 rows=1725 width=15) |
| -> Seq Scan on tbl_sales_contracts sc (cost=0.00..118.25 rows=1725 width=15) |
| -> Seq Scan on tbl_client_classes cc (cost=0.00..1.04 rows=4 width=44) |
| -> Seq Scan on tbl_client_industries ci (cost=0.00..1.25 rows=25 width=150) |
| -> Seq Scan on tbl_client_types ct (cost=0.00..1.06 rows=6 width=150) |