Limit (cost=15201.61..15201.66 rows=20 width=1074) |
-> Sort (cost=15201.61..15202.14 rows=211 width=1074) |
Sort Key: (CASE WHEN ((sum(p.budget)) IS NULL) THEN '0'::numeric ELSE (sum(p.budget)) END) DESC, c.created_at DESC |
-> Group (cost=15129.53..15195.99 rows=211 width=1074) |
Group Key: c.id, (CASE WHEN ((sum(p.budget)) IS NULL) THEN '0'::numeric ELSE (sum(p.budget)) END), (CASE WHEN ((sum(((p.budget * p.profit_pct) / '100'::numeric))) IS NULL) THEN '0'::numeric ELSE (sum(((p.budget * p.profit_pct) / '100'::numeric))) END), (CASE WHEN ((count(p.id)) IS NULL) THEN '0'::bigint ELSE (count(p.id)) END), (CASE WHEN (((sum(p.budget)) IS NULL) OR ((sum(p.budget)) = '0'::numeric)) THEN '0'::numeric ELSE ((sum(((p.budget * p.profit_pct) / '100'::numeric))) / (sum(p.budget))) END), (CASE WHEN ((sum(p_1.budget)) IS NULL) THEN '0'::numeric ELSE (sum(p_1.budget)) END), (CASE WHEN ((count(p_1.id)) IS NULL) THEN '0'::bigint ELSE (count(p_1.id)) END), (CASE WHEN ((sum(p_2.budget)) IS NULL) THEN '0'::numeric ELSE (sum(p_2.budget)) END), (CASE WHEN ((count(p_2.id)) IS NULL) THEN '0'::bigint ELSE (count(p_2.id)) END), (CASE WHEN (tmp4.pre_sales_counts IS NULL) THEN '0'::bigint ELSE tmp4.pre_sales_counts END), (CASE WHEN (tmp5.implement_counts IS NULL) THEN '0'::bigint ELSE tmp5.implement_counts END), (CASE WHEN (tmp4.pre_sales_times IS NOT NULL) THEN (date_part('epoch'::text, tmp4.pre_sales_times) / '3600'::double precision) ELSE '0'::double precision END), (CASE WHEN (tmp5.implement_times IS NOT NULL) THEN (date_part('epoch'::text, tmp5.implement_times) / '3600'::double precision) ELSE '0'::double precision END), (CASE WHEN ((sum((wl_1.end_at - wl_1.start_at))) IS NOT NULL) THEN (sum((wl_1.end_at - wl_1.start_at))) ELSE '00:00:00'::interval END), (CASE WHEN ((count(wl_1.id)) IS NOT NULL) THEN (count(wl_1.id)) ELSE '0'::bigint END), (max(p.bargain_date)), (CASE WHEN ((sum(r.amount)) IS NOT NULL) THEN (sum(r.amount)) ELSE '0'::numeric END), (CASE WHEN (tmp9.points IS NOT NULL) THEN tmp9.points ELSE '0'::numeric END), (count(p.id)), ci.id, ct.id, (CASE WHEN (c.client_class IS NOT NULL) THEN (((((CASE WHEN (cc.contact_base > 0) THEN floor((CASE WHEN (c.contact_count > cc.contact_base) THEN '15'::bigint ELSE ((c.contact_count * 15) / cc.contact_base) END)::double precision) ELSE '15'::double precision END + floor((((c.client_base_info_count * 15) / 9))::double precision)) + CASE WHEN (cc.visit_base > 0) THEN floor(CASE WHEN ((c.visit_count)::double precision > ceil((CASE WHEN (date_part('year'::text, now()) = date_part('year'::text, ((c.created_at)::date)::timestamp without time zone)) THEN ((((now())::date - (c.created_at)::date) + 1))::double precision ELSE '254'::double precision END / (cc.visit_base)::double precision))) THEN '20'::double precision ELSE (((c.visit_count * 20))::double precision / ceil((CASE WHEN (date_part('year'::text, now()) = date_part('year'::text, ((c.created_at)::date)::timestamp without time zone)) THEN ((((now())::date - (c.created_at)::date) + 1))::double precision ELSE '254'::double precision END / (cc.visit_base)::double precision))) END) ELSE '20'::double precision END) + CASE WHEN (cc.cooperate_base > 0) THEN floor((CASE WHEN (c.cooperate_count > cc.cooperate_base) THEN '20'::bigint ELSE ((c.cooperate_count * 20) / cc.cooperate_base) END)::double precision) ELSE '20'::double precision END) + CASE WHEN (cc.case_pre_sales_base > 0) THEN floor((CASE WHEN (c.case_pre_sales_count > cc.case_pre_sales_base) THEN '15'::bigint ELSE ((c.case_pre_sales_count * 15) / cc.case_pre_sales_base) END)::double precision) ELSE '15'::double precision END) + CASE WHEN (cc.case_implement_base > 0) THEN floor((CASE WHEN (c.case_implement_count > cc.case_implement_base) THEN '15'::bigint ELSE ((c.case_implement_count * 15) / cc.case_implement_base) END)::double precision) ELSE '15'::double precision END) ELSE NULL::double precision END), (CASE WHEN ((sum(p.collected)) IS NULL) THEN '0'::numeric ELSE (sum(p.collected)) END), (CASE WHEN ((sum(CASE WHEN (p.budget >= p.collected) THEN (p.budget - p.collected) ELSE '0'::numeric END)) IS NULL) THEN '0'::numeric ELSE (sum(CASE WHEN (p.budget >= p.collected) THEN (p.budget - p.collected) ELSE '0'::numeric END)) END), (CASE WHEN (tmp10.invoices IS NULL) THEN '0'::numeric ELSE tmp10.invoices END), (CASE WHEN (tmp10.un_invoices IS NULL) THEN '0'::numeric ELSE tmp10.un_invoices END), (CASE WHEN (tmp11.count IS NULL) THEN '0'::bigint ELSE tmp11.count END), (CASE WHEN (tmp12.budgets IS NULL) THEN '0'::numeric ELSE tmp12.budgets END), (CASE WHEN ((count(DISTINCT p.used_client)) IS NULL) THEN '0'::bigint ELSE (count(DISTINCT p.used_client)) END), (CASE WHEN ((sum(p_5.budget)) IS NULL) THEN '0'::numeric ELSE (sum(p_5.budget)) END), (CASE WHEN ((sum(((p_5.budget * p_5.profit_pct) / '100'::numeric))) IS NULL) THEN '0'::numeric ELSE (sum(((p_5.budget * p_5.profit_pct) / '100'::numeric))) END), (CASE WHEN ((sum((wl.end_at - wl.start_at))) IS NOT NULL) THEN (sum((wl.end_at - wl.start_at))) ELSE '00:00:00'::interval END), (CASE WHEN ((count(wl.id)) IS NOT NULL) THEN (count(wl.id)) ELSE '0'::bigint END), (CASE WHEN (tmp15.work_times IS NOT NULL) THEN tmp15.work_times ELSE '00:00:00'::interval END), (CASE WHEN (tmp15.work_count IS NOT NULL) THEN tmp15.work_count ELSE '0'::bigint END), (CASE WHEN ((sum((wl_3.end_at - wl_3.start_at))) IS NOT NULL) THEN (sum((wl_3.end_at - wl_3.start_at))) ELSE '00:00:00'::interval END), (CASE WHEN ((count(wl_3.id)) IS NOT NULL) THEN (count(wl_3.id)) ELSE '0'::bigint END), (CASE WHEN ((sum((wl_4.end_at - wl_4.start_at))) IS NOT NULL) THEN (sum((wl_4.end_at - wl_4.start_at))) ELSE '00:00:00'::interval END), (CASE WHEN ((count(wl_4.id)) IS NOT NULL) THEN (count(wl_4.id)) ELSE '0'::bigint END), (CASE WHEN ((sum((wl_5.end_at - wl_5.start_at))) IS NOT NULL) THEN (sum((wl_5.end_at - wl_5.start_at))) ELSE '00:00:00'::interval END), (CASE WHEN ((count(wl_5.id)) IS NOT NULL) THEN (count(wl_5.id)) ELSE '0'::bigint END) |
-> Sort (cost=15129.53..15130.06 rows=211 width=1089) |
Sort Key: c.id, (CASE WHEN ((sum(p.budget)) IS NULL) THEN '0'::numeric ELSE (sum(p.budget)) END) DESC, (CASE WHEN ((sum(((p.budget * p.profit_pct) / '100'::numeric))) IS NULL) THEN '0'::numeric ELSE (sum(((p.budget * p.profit_pct) / '100'::numeric))) END), (CASE WHEN ((count(p.id)) IS NULL) THEN '0'::bigint ELSE (count(p.id)) END), (CASE WHEN (((sum(p.budget)) IS NULL) OR ((sum(p.budget)) = '0'::numeric)) THEN '0'::numeric ELSE ((sum(((p.budget * p.profit_pct) / '100'::numeric))) / (sum(p.budget))) END), (CASE WHEN ((sum(p_1.budget)) IS NULL) THEN '0'::numeric ELSE (sum(p_1.budget)) END), (CASE WHEN ((count(p_1.id)) IS NULL) THEN '0'::bigint ELSE (count(p_1.id)) END), (CASE WHEN ((sum(p_2.budget)) IS NULL) THEN '0'::numeric ELSE (sum(p_2.budget)) END), (CASE WHEN ((count(p_2.id)) IS NULL) THEN '0'::bigint ELSE (count(p_2.id)) END), (CASE WHEN (tmp4.pre_sales_counts IS NULL) THEN '0'::bigint ELSE tmp4.pre_sales_counts END), (CASE WHEN (tmp5.implement_counts IS NULL) THEN '0'::bigint ELSE tmp5.implement_counts END), (CASE WHEN (tmp4.pre_sales_times IS NOT NULL) THEN (date_part('epoch'::text, tmp4.pre_sales_times) / '3600'::double precision) ELSE '0'::double precision END), (CASE WHEN (tmp5.implement_times IS NOT NULL) THEN (date_part('epoch'::text, tmp5.implement_times) / '3600'::double precision) ELSE '0'::double precision END), (CASE WHEN ((sum((wl_1.end_at - wl_1.start_at))) IS NOT NULL) THEN (sum((wl_1.end_at - wl_1.start_at))) ELSE '00:00:00'::interval END), (CASE WHEN ((count(wl_1.id)) IS NOT NULL) THEN (count(wl_1.id)) ELSE '0'::bigint END), (max(p.bargain_date)), (CASE WHEN ((sum(r.amount)) IS NOT NULL) THEN (sum(r.amount)) ELSE '0'::numeric END), (CASE WHEN (tmp9.points IS NOT NULL) THEN tmp9.points ELSE '0'::numeric END), (count(p.id)), ci.id, ct.id, (CASE WHEN (c.client_class IS NOT NULL) THEN (((((CASE WHEN (cc.contact_base > 0) THEN floor((CASE WHEN (c.contact_count > cc.contact_base) THEN '15'::bigint ELSE ((c.contact_count * 15) / cc.contact_base) END)::double precision) ELSE '15'::double precision END + floor((((c.client_base_info_count * 15) / 9))::double precision)) + CASE WHEN (cc.visit_base > 0) THEN floor(CASE WHEN ((c.visit_count)::double precision > ceil((CASE WHEN (date_part('year'::text, now()) = date_part('year'::text, ((c.created_at)::date)::timestamp without time zone)) THEN ((((now())::date - (c.created_at)::date) + 1))::double precision ELSE '254'::double precision END / (cc.visit_base)::double precision))) THEN '20'::double precision ELSE (((c.visit_count * 20))::double precision / ceil((CASE WHEN (date_part('year'::text, now()) = date_part('year'::text, ((c.created_at)::date)::timestamp without time zone)) THEN ((((now())::date - (c.created_at)::date) + 1))::double precision ELSE '254'::double precision END / (cc.visit_base)::double precision))) END) ELSE '20'::double precision END) + CASE WHEN (cc.cooperate_base > 0) THEN floor((CASE WHEN (c.cooperate_count > cc.cooperate_base) THEN '20'::bigint ELSE ((c.cooperate_count * 20) / cc.cooperate_base) END)::double precision) ELSE '20'::double precision END) + CASE WHEN (cc.case_pre_sales_base > 0) THEN floor((CASE WHEN (c.case_pre_sales_count > cc.case_pre_sales_base) THEN '15'::bigint ELSE ((c.case_pre_sales_count * 15) / cc.case_pre_sales_base) END)::double precision) ELSE '15'::double precision END) + CASE WHEN (cc.case_implement_base > 0) THEN floor((CASE WHEN (c.case_implement_count > cc.case_implement_base) THEN '15'::bigint ELSE ((c.case_implement_count * 15) / cc.case_implement_base) END)::double precision) ELSE '15'::double precision END) ELSE NULL::double precision END), (CASE WHEN ((sum(p.collected)) IS NULL) THEN '0'::numeric ELSE (sum(p.collected)) END), (CASE WHEN ((sum(CASE WHEN (p.budget >= p.collected) THEN (p.budget - p.collected) ELSE '0'::numeric END)) IS NULL) THEN '0'::numeric ELSE (sum(CASE WHEN (p.budget >= p.collected) THEN (p.budget - p.collected) ELSE '0'::numeric END)) END), (CASE WHEN (tmp10.invoices IS NULL) THEN '0'::numeric ELSE tmp10.invoices END), (CASE WHEN (tmp10.un_invoices IS NULL) THEN '0'::numeric ELSE tmp10.un_invoices END), (CASE WHEN (tmp11.count IS NULL) THEN '0'::bigint ELSE tmp11.count END), (CASE WHEN (tmp12.budgets IS NULL) THEN '0'::numeric ELSE tmp12.budgets END), (CASE WHEN ((count(DISTINCT p.used_client)) IS NULL) THEN '0'::bigint ELSE (count(DISTINCT p.used_client)) END), (CASE WHEN ((sum(p_5.budget)) IS NULL) THEN '0'::numeric ELSE (sum(p_5.budget)) END), (CASE WHEN ((sum(((p_5.budget * p_5.profit_pct) / '100'::numeric))) IS NULL) THEN '0'::numeric ELSE (sum(((p_5.budget * p_5.profit_pct) / '100'::numeric))) END), (CASE WHEN ((sum((wl.end_at - wl.start_at))) IS NOT NULL) THEN (sum((wl.end_at - wl.start_at))) ELSE '00:00:00'::interval END), (CASE WHEN ((count(wl.id)) IS NOT NULL) THEN (count(wl.id)) ELSE '0'::bigint END), (CASE WHEN (tmp15.work_times IS NOT NULL) THEN tmp15.work_times ELSE '00:00:00'::interval END), (CASE WHEN (tmp15.work_count IS NOT NULL) THEN tmp15.work_count ELSE '0'::bigint END), (CASE WHEN ((sum((wl_3.end_at - wl_3.start_at))) IS NOT NULL) THEN (sum((wl_3.end_at - wl_3.start_at))) ELSE '00:00:00'::interval END), (CASE WHEN ((count(wl_3.id)) IS NOT NULL) THEN (count(wl_3.id)) ELSE '0'::bigint END), (CASE WHEN ((sum((wl_4.end_at - wl_4.start_at))) IS NOT NULL) THEN (sum((wl_4.end_at - wl_4.start_at))) ELSE '00:00:00'::interval END), (CASE WHEN ((count(wl_4.id)) IS NOT NULL) THEN (count(wl_4.id)) ELSE '0'::bigint END), (CASE WHEN ((sum((wl_5.end_at - wl_5.start_at))) IS NOT NULL) THEN (sum((wl_5.end_at - wl_5.start_at))) ELSE '00:00:00'::interval END), (CASE WHEN ((count(wl_5.id)) IS NOT NULL) THEN (count(wl_5.id)) ELSE '0'::bigint END) |
-> Nested Loop Left Join (cost=14689.14..15121.38 rows=211 width=1089) |
Join Filter: (egr.engineer_id = ca.engineer_id) |
-> Hash Left Join (cost=14689.14..14994.50 rows=211 width=1105) |
Hash Cond: (cas.id = ca.case_id) |
-> Nested Loop Left Join (cost=14423.29..14725.23 rows=210 width=1105) |
Join Filter: (ct.id = c.client_type) |
-> Hash Left Join (cost=14423.29..14707.44 rows=210 width=959) |
Hash Cond: (c.client_industry = ci.id) |
-> Hash Right Join (cost=14421.75..14705.26 rows=210 width=813) |
Hash Cond: (cas.client_id = c.id) |
-> Seq Scan on tbl_cases cas (cost=0.00..251.30 rows=8030 width=8) |
-> Hash (cost=14421.11..14421.11 rows=51 width=809) |
-> Nested Loop Left Join (cost=14408.92..14421.11 rows=51 width=809) |
Join Filter: (cc.id = c.client_class) |
-> Merge Left Join (cost=14408.92..14417.29 rows=51 width=769) |
Merge Cond: (c.id = wl_5.client_id) |
-> Merge Left Join (cost=12661.11..12669.31 rows=51 width=745) |
Merge Cond: (c.id = wl_4.client_id) |
-> Merge Left Join (cost=10913.30..10921.32 rows=51 width=721) |
Merge Cond: (c.id = wl_3.client_id) |
-> Merge Left Join (cost=9164.53..9171.15 rows=51 width=697) |
Merge Cond: (c.id = tmp15.client_id) |
-> Merge Left Join (cost=7346.05..7348.16 rows=51 width=673) |
Merge Cond: (c.id = p_5.client_id) |
-> Sort (cost=7162.33..7162.46 rows=51 width=609) |
Sort Key: c.id |
-> Hash Right Join (cost=7131.56..7160.88 rows=51 width=609) |
Hash Cond: (wl.client_id = c.id) |
-> HashAggregate (cost=2079.55..2091.76 rows=1221 width=28) |
Group Key: wl.client_id |
-> Seq Scan on tbl_work_logs wl (cost=0.00..1747.80 rows=33175 width=24) |
Filter: ((NOT is_draft) AND (scenario_id = 1)) |
-> Hash (cost=5051.38..5051.38 rows=51 width=585) |
-> Merge Left Join (cost=5050.07..5051.38 rows=51 width=585) |
Merge Cond: (c.id = tmp9.client_id) |
-> Sort (cost=4126.24..4126.36 rows=51 width=553) |
Sort Key: c.id |
-> Hash Left Join (cost=4070.96..4124.79 rows=51 width=553) |
Hash Cond: (c.id = tmp12.client_id) |
-> Hash Left Join (cost=3861.79..3915.49 rows=51 width=521) |
Hash Cond: (c.id = tmp11.client_id) |
-> Hash Left Join (cost=3650.54..3704.10 rows=51 width=513) |
Hash Cond: (c.id = tmp10.client_id) |
-> Hash Right Join (cost=3447.06..3500.49 rows=51 width=449) |
Hash Cond: ((csrr.sales_rep = c.sales_rep) AND (csrr.client_id = c.id)) |
-> Hash Join (cost=73.17..126.29 rows=40 width=8) |
Hash Cond: (csrr.id = "ANY_subquery".max) |
-> Seq Scan on tbl_client_sales_rep_rels csrr (cost=0.00..52.46 rows=81 width=12) |
Filter: (sales_rep = 1001) |
-> Hash (cost=70.67..70.67 rows=200 width=4) |
-> HashAggregate (cost=68.67..70.67 rows=200 width=4) |
Group Key: "ANY_subquery".max |
-> Subquery Scan on "ANY_subquery" (cost=50.52..66.66 rows=807 width=4) |
-> HashAggregate (cost=50.52..58.59 rows=807 width=8) |
Group Key: csrrs.client_id |
-> Seq Scan on tbl_client_sales_rep_rels csrrs (cost=0.00..45.77 rows=949 width=8) |
Filter: (end_at IS NULL) |
-> Hash (cost=3373.12..3373.12 rows=51 width=449) |
-> Hash Right Join (cost=3361.02..3373.12 rows=51 width=449) |
Hash Cond: (wl_1.client_id = c.id) |
-> HashAggregate (cost=1667.68..1672.72 rows=504 width=28) |
Group Key: wl_1.client_id |
-> Seq Scan on tbl_work_logs wl_1 (cost=0.00..1661.24 rows=644 width=24) |
Filter: ((NOT is_draft) AND (location_in_id IS NOT NULL) AND (location_out_id IS NOT NULL) AND (client_id IS NOT NULL)) |
-> Hash (cost=1692.70..1692.70 rows=51 width=425) |
-> Hash Right Join (cost=1681.36..1692.70 rows=51 width=425) |
Hash Cond: (r.client_id = c.id) |
-> HashAggregate (cost=265.35..270.70 rows=428 width=36) |
Group Key: r.client_id |
-> Seq Scan on tbl_reimbursements r (cost=0.00..227.71 rows=7528 width=9) |
Filter: (status = ANY ('{2,3}'::integer[])) |
-> Hash (cost=1415.37..1415.37 rows=51 width=393) |
-> Merge Left Join (cost=1335.02..1415.37 rows=51 width=393) |
Merge Cond: (c.id = p_2.client_id) |
-> Merge Left Join (cost=1159.31..1238.61 rows=51 width=353) |
Merge Cond: (c.id = p_1.client_id) |
-> Merge Left Join (cost=983.83..1062.36 rows=51 width=313) |
Merge Cond: (c.id = p.client_id) |
-> Sort (cost=724.43..724.56 rows=51 width=165) |
Sort Key: c.id |
-> Hash Left Join (cost=631.88..722.98 rows=51 width=165) |
Hash Cond: (c.id = tmp4.client_id) |
-> Hash Left Join (cost=496.76..587.72 rows=51 width=141) |
Hash Cond: (c.id = tmp5.client_id) |
-> Nested Loop (cost=14.49..105.32 rows=51 width=117) |
-> Seq Scan on tbl_sales_group_relationships sgr (cost=0.00..1.73 rows=1 width=4) |
Filter: ((sales_id = 1001) AND (group_id = 1)) |
-> Bitmap Heap Scan on tbl_clients c (cost=14.49..103.07 rows=51 width=117) |
Recheck Cond: (sales_rep = 1001) |
Filter: (NOT deleted) |
-> Bitmap Index Scan on tbl_clients_sales_rep_idx (cost=0.00..4.72 rows=59 width=0) |
Index Cond: (sales_rep = 1001) |
-> Hash (cost=479.21..479.21 rows=245 width=28) |
-> Subquery Scan on tmp5 (cost=474.31..479.21 rows=245 width=28) |
-> HashAggregate (cost=474.31..476.76 rows=245 width=28) |
Group Key: ir.client_id |
-> Hash Left Join (cost=1.61..408.33 rows=6598 width=24) |
Hash Cond: (ir.created_by = egr_1.engineer_id) |
-> Seq Scan on tbl_implement_records ir (cost=0.00..316.00 rows=6598 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=131.21..131.21 rows=313 width=28) |
-> Subquery Scan on tmp4 (cost=124.95..131.21 rows=313 width=28) |
-> HashAggregate (cost=124.95..128.08 rows=313 width=28) |
Group Key: ps.client_id |
-> Hash Left Join (cost=1.61..109.15 rows=1580 width=24) |
Hash Cond: (ps.created_by = egr_2.engineer_id) |
-> Seq Scan on tbl_pre_sales ps (cost=0.00..85.82 rows=1580 width=28) |
Filter: (NOT is_draft) |
-> 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) |
-> GroupAggregate (cost=259.41..327.27 rows=816 width=152) |
Group Key: p.client_id |
-> Sort (cost=259.41..263.37 rows=1586 width=30) |
Sort Key: p.client_id |
-> Seq Scan on tbl_projects p (cost=0.00..175.10 rows=1586 width=30) |
Filter: (project_status = 3) |
-> GroupAggregate (cost=175.48..175.88 rows=18 width=44) |
Group Key: p_1.client_id |
-> Sort (cost=175.48..175.52 rows=18 width=13) |
Sort Key: p_1.client_id |
-> Seq Scan on tbl_projects p_1 (cost=0.00..175.10 rows=18 width=13) |
Filter: (project_status = 1) |
-> GroupAggregate (cost=175.71..176.30 rows=26 width=44) |
Group Key: p_2.client_id |
-> Sort (cost=175.71..175.78 rows=26 width=13) |
Sort Key: p_2.client_id |
-> Seq Scan on tbl_projects p_2 (cost=0.00..175.10 rows=26 width=13) |
Filter: (project_status = 2) |
-> Hash (cost=200.98..200.98 rows=200 width=68) |
-> Subquery Scan on tmp10 (cost=195.98..200.98 rows=200 width=68) |
-> HashAggregate (cost=195.98..198.98 rows=200 width=68) |
Group Key: sc.client_id |
-> HashAggregate (cost=137.50..158.38 rows=1671 width=47) |
Group Key: sc.id |
-> Hash Right Join (cost=84.60..128.17 rows=1866 width=21) |
Hash Cond: (sci.contract_id = sc.id) |
-> Seq Scan on tbl_sales_contract_invoices sci (cost=0.00..38.66 rows=1866 width=10) |
-> Hash (cost=63.71..63.71 rows=1671 width=15) |
-> Seq Scan on tbl_sales_contracts sc (cost=0.00..63.71 rows=1671 width=15) |
-> Hash (cost=200.20..200.20 rows=884 width=12) |
-> Subquery Scan on tmp11 (cost=182.52..200.20 rows=884 width=12) |
-> HashAggregate (cost=182.52..191.36 rows=884 width=44) |
Group Key: p_3.client_id |
-> Seq Scan on tbl_projects p_3 (cost=0.00..167.68 rows=2968 width=8) |
-> Hash (cost=199.47..199.47 rows=776 width=36) |
-> Subquery Scan on tmp12 (cost=182.01..199.47 rows=776 width=36) |
-> HashAggregate (cost=182.01..191.71 rows=776 width=44) |
Group Key: p_4.client_id |
-> Seq Scan on tbl_projects p_4 (cost=0.00..175.10 rows=1382 width=9) |
Filter: (project_status <> 3) |
-> Sort (cost=923.84..924.34 rows=200 width=36) |
Sort Key: tmp9.client_id |
-> Subquery Scan on tmp9 (cost=911.69..916.19 rows=200 width=36) |
-> HashAggregate (cost=911.69..914.19 rows=200 width=36) |
Group Key: c_1.client_id |
-> HashAggregate (cost=690.87..791.24 rows=8030 width=40) |
Group Key: c_1.id |
-> Hash Left Join (cost=353.28..650.46 rows=8082 width=16) |
Hash Cond: (ca_1.engineer_id = egr_3.engineer_id) |
-> Hash Right Join (cost=351.68..537.72 rows=8082 width=20) |
Hash Cond: (ca_1.case_id = c_1.id) |
-> Seq Scan on tbl_case_assignments ca_1 (cost=0.00..164.82 rows=8082 width=16) |
-> Hash (cost=251.30..251.30 rows=8030 width=8) |
-> Seq Scan on tbl_cases c_1 (cost=0.00..251.30 rows=8030 width=8) |
-> Hash (cost=1.27..1.27 rows=27 width=4) |
-> Seq Scan on tbl_engineer_group_relationships egr_3 (cost=0.00..1.27 rows=27 width=4) |
-> GroupAggregate (cost=183.72..185.03 rows=43 width=68) |
Group Key: p_5.client_id |
-> Sort (cost=183.72..183.83 rows=44 width=14) |
Sort Key: p_5.client_id |
-> Seq Scan on tbl_projects p_5 (cost=0.00..182.52 rows=44 width=14) |
Filter: ((project_status = 1) OR (project_status = 2)) |
-> Sort (cost=1818.48..1820.56 rows=832 width=28) |
Sort Key: tmp15.client_id |
-> Subquery Scan on tmp15 (cost=1761.49..1778.13 rows=832 width=28) |
-> HashAggregate (cost=1761.49..1769.81 rows=832 width=28) |
Group Key: wl_2.client_id |
-> Seq Scan on tbl_work_logs wl_2 (cost=0.00..1747.80 rows=1369 width=24) |
Filter: ((NOT is_draft) AND (scenario_id = 2)) |
-> GroupAggregate (cost=1748.76..1749.59 rows=36 width=28) |
Group Key: wl_3.client_id |
-> Sort (cost=1748.76..1748.86 rows=37 width=24) |
Sort Key: wl_3.client_id |
-> Seq Scan on tbl_work_logs wl_3 (cost=0.00..1747.80 rows=37 width=24) |
Filter: ((NOT is_draft) AND (scenario_id = 3)) |
-> GroupAggregate (cost=1747.81..1747.84 rows=1 width=28) |
Group Key: wl_4.client_id |
-> Sort (cost=1747.81..1747.82 rows=1 width=24) |
Sort Key: wl_4.client_id |
-> Seq Scan on tbl_work_logs wl_4 (cost=0.00..1747.80 rows=1 width=24) |
Filter: ((NOT is_draft) AND (scenario_id = 4)) |
-> GroupAggregate (cost=1747.81..1747.84 rows=1 width=28) |
Group Key: wl_5.client_id |
-> Sort (cost=1747.81..1747.82 rows=1 width=24) |
Sort Key: wl_5.client_id |
-> Seq Scan on tbl_work_logs wl_5 (cost=0.00..1747.80 rows=1 width=24) |
Filter: ((NOT is_draft) AND (scenario_id = 5)) |
-> 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) |
-> Hash (cost=1.24..1.24 rows=24 width=150) |
-> Seq Scan on tbl_client_industries ci (cost=0.00..1.24 rows=24 width=150) |
-> 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) |
-> Hash (cost=164.82..164.82 rows=8082 width=8) |
-> Seq Scan on tbl_case_assignments ca (cost=0.00..164.82 rows=8082 width=8) |
-> Materialize (cost=0.00..1.41 rows=27 width=4) |
-> Seq Scan on tbl_engineer_group_relationships egr (cost=0.00..1.27 rows=27 width=4) |