| Limit (cost=7393.89..7398.19 rows=20 width=1050) |
| -> Result (cost=7393.89..7409.15 rows=71 width=1050) |
| -> Sort (cost=7393.89..7394.06 rows=71 width=1134) |
| Sort Key: (CASE WHEN ((sum(CASE WHEN (p_1.project_status = 3) THEN p_1.budget ELSE '0'::numeric END)) IS NULL) THEN '0'::numeric ELSE (sum(CASE WHEN (p_1.project_status = 3) THEN p_1.budget ELSE '0'::numeric END)) END) DESC, c.created_at DESC |
| -> Nested Loop Left Join (cost=7166.01..7392.00 rows=71 width=1134) |
| Join Filter: (ct.id = c.client_type) |
| -> Nested Loop Left Join (cost=7166.01..7383.29 rows=71 width=955) |
| -> Nested Loop Left Join (cost=7165.88..7360.80 rows=71 width=809) |
| Join Filter: (cc.id = c.client_class) |
| -> Hash Left Join (cost=7165.88..7355.88 rows=71 width=769) |
| Hash Cond: (c.id = tmp8.client_id) |
| -> Merge Left Join (cost=6859.77..7049.59 rows=71 width=737) |
| Merge Cond: (c.id = tmp10.client_id) |
| -> Merge Left Join (cost=6585.34..6773.91 rows=71 width=673) |
| Merge Cond: (c.id = tmp9.client_id) |
| -> Merge Left Join (cost=5605.99..5793.32 rows=71 width=641) |
| Merge Cond: (c.id = p_1.client_id) |
| -> Sort (cost=5323.10..5323.27 rows=71 width=349) |
| Sort Key: c.id |
| -> Hash Left Join (cost=5019.70..5320.91 rows=71 width=349) |
| Hash Cond: (c.id = tmp5.client_id) |
| -> Hash Left Join (cost=4502.99..4804.02 rows=71 width=325) |
| Hash Cond: (c.id = tmp4.client_id) |
| -> Hash Left Join (cost=4364.15..4664.99 rows=71 width=301) |
| Hash Cond: (c.id = tmp_project_all.client_id) |
| -> Hash Left Join (cost=4123.48..4424.13 rows=71 width=261) |
| Hash Cond: ((c.id = csrr.client_id) AND (c.sales_rep = csrr.sales_rep)) |
| -> Hash Left Join (cost=3956.77..4255.81 rows=71 width=261) |
| Hash Cond: (c.id = tmp_work.client_id) |
| -> Seq Scan on tbl_clients c (cost=9.67..308.51 rows=71 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 (cost=3931.63..3931.63 rows=1238 width=148) |
| -> Subquery Scan on tmp_work (cost=3906.87..3931.63 rows=1238 width=148) |
| -> 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)) |
| -> Hash (cost=146.04..146.04 rows=1378 width=8) |
| -> 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) |
| -> Hash (cost=228.94..228.94 rows=938 width=44) |
| -> Subquery Scan on tmp_project_all (cost=207.84..228.94 rows=938 width=44) |
| -> HashAggregate (cost=207.84..219.56 rows=938 width=44) |
| Group Key: p.client_id |
| -> Seq Scan on tbl_projects p (cost=0.00..176.42 rows=3142 width=17) |
| -> Hash (cost=134.89..134.89 rows=316 width=28) |
| -> Subquery Scan on tmp4 (cost=128.57..134.89 rows=316 width=28) |
| -> 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) |
| -> Hash (cost=513.62..513.62 rows=247 width=28) |
| -> Subquery Scan on tmp5 (cost=508.68..513.62 rows=247 width=28) |
| -> 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) |
| -> GroupAggregate (cost=282.90..458.58 rows=878 width=296) |
| Group Key: p_1.client_id |
| -> Sort (cost=282.90..287.29 rows=1757 width=34) |
| Sort Key: p_1.client_id |
| -> Seq Scan on tbl_projects p_1 (cost=0.00..188.20 rows=1757 width=34) |
| Filter: (project_status = ANY ('{1,2,3}'::integer[])) |
| -> Sort (cost=979.35..979.85 rows=200 width=36) |
| Sort Key: tmp9.client_id |
| -> Subquery Scan on tmp9 (cost=967.20..971.70 rows=200 width=36) |
| -> 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) |
| -> Sort (cost=274.44..274.94 rows=200 width=68) |
| Sort Key: tmp10.client_id |
| -> Subquery Scan on tmp10 (cost=261.79..266.79 rows=200 width=68) |
| -> 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) |
| -> Hash (cost=300.70..300.70 rows=432 width=36) |
| -> Subquery Scan on tmp8 (cost=290.98..300.70 rows=432 width=36) |
| -> 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[])) |
| -> Materialize (cost=0.00..1.06 rows=4 width=44) |
| -> Seq Scan on tbl_client_classes cc (cost=0.00..1.04 rows=4 width=44) |
| -> Index Scan using tbl_client_industries_pkey on tbl_client_industries ci (cost=0.14..0.32 rows=1 width=150) |
| Index Cond: (id = c.client_industry) |
| -> Materialize (cost=0.00..1.09 rows=6 width=150) |
| -> Seq Scan on tbl_client_types ct (cost=0.00..1.06 rows=6 width=150) |