| Limit (cost=7528.48..7532.78 rows=20 width=1050) |
| -> Result (cost=7528.48..7907.31 rows=1762 width=1050) |
| -> Sort (cost=7528.48..7532.89 rows=1762 width=1134) |
| Sort Key: (CASE WHEN (tmp_project_period.status3_budgets IS NULL) THEN '0'::numeric ELSE tmp_project_period.status3_budgets END) DESC, c.created_at DESC |
| -> Hash Left Join (cost=7051.42..7481.59 rows=1762 width=1134) |
| Hash Cond: (c.client_type = ct.id) |
| -> Hash Left Join (cost=7050.29..7424.21 rows=1762 width=955) |
| Hash Cond: (c.client_industry = ci.id) |
| -> Hash Left Join (cost=7048.72..7417.26 rows=1762 width=809) |
| Hash Cond: (c.client_class = cc.id) |
| -> Hash Left Join (cost=7047.63..7408.60 rows=1762 width=769) |
| Hash Cond: (c.id = tmp10.client_id) |
| -> Hash Left Join (cost=6778.34..7134.67 rows=1762 width=705) |
| Hash Cond: (c.id = tmp9.client_id) |
| -> Hash Left Join (cost=5804.14..6155.83 rows=1762 width=673) |
| Hash Cond: (c.id = tmp8.client_id) |
| -> Hash Left Join (cost=5498.04..5845.09 rows=1762 width=641) |
| Hash Cond: (c.id = tmp5.client_id) |
| -> Hash Left Join (cost=4981.32..5323.75 rows=1762 width=617) |
| Hash Cond: (c.id = tmp4.client_id) |
| -> Hash Left Join (cost=4842.48..5180.27 rows=1762 width=593) |
| Hash Cond: (c.id = tmp_project_all.client_id) |
| -> Hash Left Join (cost=4601.81..4934.96 rows=1762 width=553) |
| Hash Cond: (c.id = tmp_project_period.client_id) |
| -> Hash Left Join (cost=4123.48..4451.99 rows=1762 width=261) |
| Hash Cond: ((c.id = csrr.client_id) AND (c.sales_rep = csrr.sales_rep)) |
| -> Hash Left Join (cost=3956.77..4245.16 rows=1762 width=261) |
| Hash Cond: (c.id = tmp_work.client_id) |
| -> Seq Scan on tbl_clients c (cost=9.67..293.42 rows=1762 width=117) |
| Filter: ((NOT deleted) 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=467.36..467.36 rows=878 width=296) |
| -> Subquery Scan on tmp_project_period (cost=282.90..467.36 rows=878 width=296) |
| -> 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[])) |
| -> 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_1.client_id |
| -> Seq Scan on tbl_projects p_1 (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) |
| -> 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[])) |
| -> Hash (cost=971.70..971.70 rows=200 width=36) |
| -> 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) |
| -> Hash (cost=266.79..266.79 rows=200 width=68) |
| -> 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=1.04..1.04 rows=4 width=44) |
| -> Seq Scan on tbl_client_classes cc (cost=0.00..1.04 rows=4 width=44) |
| -> Hash (cost=1.25..1.25 rows=25 width=150) |
| -> Seq Scan on tbl_client_industries ci (cost=0.00..1.25 rows=25 width=150) |
| -> Hash (cost=1.06..1.06 rows=6 width=150) |
| -> Seq Scan on tbl_client_types ct (cost=0.00..1.06 rows=6 width=150) |