Limit (cost=15508.41..15508.46 rows=20 width=1074) |
-> Sort (cost=15508.41..15508.93 rows=206 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=15438.04..15502.93 rows=206 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 (tmp7.work_times IS NOT NULL) THEN tmp7.work_times ELSE '00:00:00'::interval END), (CASE WHEN (tmp7.work_count IS NOT NULL) THEN tmp7.work_count ELSE '0'::bigint END), (max(p.bargain_date)), (CASE WHEN (tmp8.reimbursement_amount IS NOT NULL) THEN tmp8.reimbursement_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 '233'::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 '233'::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=15438.04..15438.55 rows=206 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 (tmp7.work_times IS NOT NULL) THEN tmp7.work_times ELSE '00:00:00'::interval END), (CASE WHEN (tmp7.work_count IS NOT NULL) THEN tmp7.work_count ELSE '0'::bigint END), (max(p.bargain_date)), (CASE WHEN (tmp8.reimbursement_amount IS NOT NULL) THEN tmp8.reimbursement_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 '233'::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 '233'::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=15004.58..15430.12 rows=206 width=1089) |
Join Filter: (egr.engineer_id = ca.engineer_id) |
-> Hash Left Join (cost=15004.58..15306.21 rows=206 width=1105) |
Hash Cond: (cas.id = ca.case_id) |
-> Nested Loop Left Join (cost=14741.71..15040.01 rows=205 width=1105) |
Join Filter: (ct.id = c.client_type) |
-> Hash Left Join (cost=14741.71..15022.60 rows=205 width=959) |
Hash Cond: (c.client_industry = ci.id) |
-> Hash Right Join (cost=14740.17..15020.44 rows=205 width=813) |
Hash Cond: (cas.client_id = c.id) |
-> Seq Scan on tbl_cases cas (cost=0.00..248.43 rows=7943 width=8) |
-> Hash (cost=14739.53..14739.53 rows=51 width=809) |
-> Nested Loop Left Join (cost=14727.23..14739.53 rows=51 width=809) |
Join Filter: (cc.id = c.client_class) |
-> Merge Left Join (cost=14727.23..14735.71 rows=51 width=769) |
Merge Cond: (c.id = wl_5.client_id) |
-> Merge Left Join (cost=12988.41..12996.71 rows=51 width=745) |
Merge Cond: (c.id = wl_4.client_id) |
-> Merge Left Join (cost=11249.59..11257.72 rows=51 width=721) |
Merge Cond: (c.id = wl_3.client_id) |
-> Merge Left Join (cost=9509.78..9516.46 rows=51 width=697) |
Merge Cond: (c.id = tmp15.client_id) |
-> Merge Left Join (cost=7699.68..7701.83 rows=51 width=673) |
Merge Cond: (c.id = p_5.client_id) |
-> Sort (cost=7448.44..7448.57 rows=51 width=609) |
Sort Key: c.id |
-> Hash Right Join (cost=7417.87..7446.99 rows=51 width=609) |
Hash Cond: (wl.client_id = c.id) |
-> HashAggregate (cost=2068.80..2080.93 rows=1213 width=28) |
Group Key: wl.client_id |
-> Seq Scan on tbl_work_logs wl (cost=0.00..1738.81 rows=32999 width=24) |
Filter: ((NOT is_draft) AND (scenario_id = 1)) |
-> Hash (cost=5348.43..5348.43 rows=51 width=585) |
-> Merge Left Join (cost=5347.97..5348.43 rows=51 width=585) |
Merge Cond: (c.id = csrr.client_id) |
Join Filter: (csrr.sales_rep = c.sales_rep) |
-> Sort (cost=5220.76..5220.88 rows=51 width=585) |
Sort Key: c.id |
-> Hash Left Join (cost=5139.00..5219.31 rows=51 width=585) |
Hash Cond: (c.id = tmp12.client_id) |
-> Hash Left Join (cost=4862.58..4942.75 rows=51 width=553) |
Hash Cond: (c.id = tmp10.client_id) |
-> Hash Left Join (cost=4666.36..4746.39 rows=51 width=489) |
Hash Cond: (c.id = tmp9.client_id) |
-> Hash Left Join (cost=3757.77..3837.68 rows=51 width=457) |
Hash Cond: (c.id = tmp8.client_id) |
-> Hash Left Join (cost=3483.04..3562.81 rows=51 width=425) |
Hash Cond: (c.id = tmp7.client_id) |
-> Hash Left Join (cost=1808.29..1887.93 rows=51 width=401) |
Hash Cond: (c.id = tmp11.client_id) |
-> Merge Left Join (cost=1529.81..1609.32 rows=51 width=393) |
Merge Cond: (c.id = p_2.client_id) |
-> Merge Left Join (cost=1286.47..1364.85 rows=51 width=353) |
Merge Cond: (c.id = p_1.client_id) |
-> Merge Left Join (cost=1043.44..1121.10 rows=51 width=313) |
Merge Cond: (c.id = p.client_id) |
-> Sort (cost=717.61..717.74 rows=51 width=165) |
Sort Key: c.id |
-> Hash Left Join (cost=625.94..716.16 rows=51 width=165) |
Hash Cond: (c.id = tmp4.client_id) |
-> Hash Left Join (cost=490.98..581.07 rows=51 width=141) |
Hash Cond: (c.id = tmp5.client_id) |
-> Nested Loop (cost=14.48..104.43 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.48..102.19 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.71 rows=58 width=0) |
Index Cond: (sales_rep = 1001) |
-> Hash (cost=473.46..473.46 rows=244 width=28) |
-> Subquery Scan on tmp5 (cost=468.58..473.46 rows=244 width=28) |
-> HashAggregate (cost=468.58..471.02 rows=244 width=28) |
Group Key: ir.client_id |
-> Hash Left Join (cost=1.61..403.41 rows=6517 width=24) |
Hash Cond: (ir.created_by = egr_1.engineer_id) |
-> Seq Scan on tbl_implement_records ir (cost=0.00..312.19 rows=6517 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.06..131.06 rows=312 width=28) |
-> Subquery Scan on tmp4 (cost=124.82..131.06 rows=312 width=28) |
-> HashAggregate (cost=124.82..127.94 rows=312 width=28) |
Group Key: ps.client_id |
-> Hash Left Join (cost=1.61..109.06 rows=1576 width=24) |
Hash Cond: (ps.created_by = egr_2.engineer_id) |
-> Seq Scan on tbl_pre_sales ps (cost=0.00..85.78 rows=1576 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=325.83..392.92 rows=808 width=152) |
Group Key: p.client_id |
-> Sort (cost=325.83..329.75 rows=1567 width=30) |
Sort Key: p.client_id |
-> Seq Scan on tbl_projects p (cost=0.00..242.68 rows=1567 width=30) |
Filter: (project_status = 3) |
-> GroupAggregate (cost=243.02..243.40 rows=17 width=44) |
Group Key: p_1.client_id |
-> Sort (cost=243.02..243.06 rows=17 width=13) |
Sort Key: p_1.client_id |
-> Seq Scan on tbl_projects p_1 (cost=0.00..242.68 rows=17 width=13) |
Filter: (project_status = 1) |
-> GroupAggregate (cost=243.35..243.98 rows=28 width=44) |
Group Key: p_2.client_id |
-> Sort (cost=243.35..243.42 rows=28 width=13) |
Sort Key: p_2.client_id |
-> Seq Scan on tbl_projects p_2 (cost=0.00..242.68 rows=28 width=13) |
Filter: (project_status = 2) |
-> Hash (cost=267.53..267.53 rows=876 width=12) |
-> Subquery Scan on tmp11 (cost=250.01..267.53 rows=876 width=12) |
-> HashAggregate (cost=250.01..258.77 rows=876 width=44) |
Group Key: p_3.client_id |
-> Seq Scan on tbl_projects p_3 (cost=0.00..235.34 rows=2934 width=8) |
-> Hash (cost=1668.63..1668.63 rows=489 width=28) |
-> Subquery Scan on tmp7 (cost=1658.85..1668.63 rows=489 width=28) |
-> HashAggregate (cost=1658.85..1663.74 rows=489 width=28) |
Group Key: wl_1.client_id |
-> Seq Scan on tbl_work_logs wl_1 (cost=0.00..1652.65 rows=620 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=269.43..269.43 rows=425 width=36) |
-> Subquery Scan on tmp8 (cost=259.86..269.43 rows=425 width=36) |
-> HashAggregate (cost=259.86..265.18 rows=425 width=36) |
Group Key: r.client_id |
-> Seq Scan on tbl_reimbursements r (cost=0.00..222.94 rows=7385 width=9) |
Filter: (status = ANY ('{2,3}'::integer[])) |
-> Hash (cost=906.08..906.08 rows=200 width=36) |
-> Subquery Scan on tmp9 (cost=901.58..906.08 rows=200 width=36) |
-> HashAggregate (cost=901.58..904.08 rows=200 width=36) |
Group Key: c_1.client_id |
-> HashAggregate (cost=683.15..782.44 rows=7943 width=40) |
Group Key: c_1.id |
-> Hash Left Join (cost=349.32..643.18 rows=7994 width=16) |
Hash Cond: (ca_1.engineer_id = egr_3.engineer_id) |
-> Hash Right Join (cost=347.72..531.65 rows=7994 width=20) |
Hash Cond: (ca_1.case_id = c_1.id) |
-> Seq Scan on tbl_case_assignments ca_1 (cost=0.00..162.94 rows=7994 width=16) |
-> Hash (cost=248.43..248.43 rows=7943 width=8) |
-> Seq Scan on tbl_cases c_1 (cost=0.00..248.43 rows=7943 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) |
-> Hash (cost=193.72..193.72 rows=200 width=68) |
-> Subquery Scan on tmp10 (cost=188.72..193.72 rows=200 width=68) |
-> HashAggregate (cost=188.72..191.72 rows=200 width=68) |
Group Key: sc.client_id |
-> HashAggregate (cost=133.21..153.04 rows=1586 width=47) |
Group Key: sc.id |
-> Hash Right Join (cost=80.69..123.99 rows=1845 width=21) |
Hash Cond: (sci.contract_id = sc.id) |
-> Seq Scan on tbl_sales_contract_invoices sci (cost=0.00..38.45 rows=1845 width=10) |
-> Hash (cost=60.86..60.86 rows=1586 width=15) |
-> Seq Scan on tbl_sales_contracts sc (cost=0.00..60.86 rows=1586 width=15) |
-> Hash (cost=266.81..266.81 rows=769 width=36) |
-> Subquery Scan on tmp12 (cost=249.51..266.81 rows=769 width=36) |
-> HashAggregate (cost=249.51..259.12 rows=769 width=44) |
Group Key: p_4.client_id |
-> Seq Scan on tbl_projects p_4 (cost=0.00..242.68 rows=1367 width=9) |
Filter: (project_status <> 3) |
-> Sort (cost=127.21..127.31 rows=40 width=8) |
Sort Key: csrr.client_id |
-> Hash Join (cost=73.08..126.15 rows=40 width=8) |
Hash Cond: (csrr.id = "ANY_subquery".max) |
-> Seq Scan on tbl_client_sales_rep_rels csrr (cost=0.00..52.41 rows=80 width=12) |
Filter: (sales_rep = 1001) |
-> Hash (cost=70.58..70.58 rows=200 width=4) |
-> HashAggregate (cost=68.58..70.58 rows=200 width=4) |
Group Key: "ANY_subquery".max |
-> Subquery Scan on "ANY_subquery" (cost=50.47..66.56 rows=805 width=4) |
-> HashAggregate (cost=50.47..58.52 rows=805 width=8) |
Group Key: csrrs.client_id |
-> Seq Scan on tbl_client_sales_rep_rels csrrs (cost=0.00..45.73 rows=947 width=8) |
Filter: (end_at IS NULL) |
-> GroupAggregate (cost=251.25..252.58 rows=44 width=68) |
Group Key: p_5.client_id |
-> Sort (cost=251.25..251.36 rows=45 width=14) |
Sort Key: p_5.client_id |
-> Seq Scan on tbl_projects p_5 (cost=0.00..250.01 rows=45 width=14) |
Filter: ((project_status = 1) OR (project_status = 2)) |
-> Sort (cost=1810.10..1812.19 rows=837 width=28) |
Sort Key: tmp15.client_id |
-> Subquery Scan on tmp15 (cost=1752.72..1769.46 rows=837 width=28) |
-> HashAggregate (cost=1752.72..1761.09 rows=837 width=28) |
Group Key: wl_2.client_id |
-> Seq Scan on tbl_work_logs wl_2 (cost=0.00..1738.81 rows=1391 width=24) |
Filter: ((NOT is_draft) AND (scenario_id = 2)) |
-> GroupAggregate (cost=1739.81..1740.65 rows=37 width=28) |
Group Key: wl_3.client_id |
-> Sort (cost=1739.81..1739.90 rows=38 width=24) |
Sort Key: wl_3.client_id |
-> Seq Scan on tbl_work_logs wl_3 (cost=0.00..1738.81 rows=38 width=24) |
Filter: ((NOT is_draft) AND (scenario_id = 3)) |
-> GroupAggregate (cost=1738.82..1738.85 rows=1 width=28) |
Group Key: wl_4.client_id |
-> Sort (cost=1738.82..1738.83 rows=1 width=24) |
Sort Key: wl_4.client_id |
-> Seq Scan on tbl_work_logs wl_4 (cost=0.00..1738.81 rows=1 width=24) |
Filter: ((NOT is_draft) AND (scenario_id = 4)) |
-> GroupAggregate (cost=1738.82..1738.85 rows=1 width=28) |
Group Key: wl_5.client_id |
-> Sort (cost=1738.82..1738.83 rows=1 width=24) |
Sort Key: wl_5.client_id |
-> Seq Scan on tbl_work_logs wl_5 (cost=0.00..1738.81 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=162.94..162.94 rows=7994 width=8) |
-> Seq Scan on tbl_case_assignments ca (cost=0.00..162.94 rows=7994 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) |