explain.depesz.com

PostgreSQL's explain analyze made readable

Result: E5sb

Settings
# exclusive inclusive rows x rows loops node
1. 0.000 0.000 ↓ 0.0

Sort (cost=1,803,800,502.45..1,803,802,320.43 rows=727,193 width=113) (actual rows= loops=)

  • Sort Key: evnt.log_user_id, evnt.log_date
2. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=92,214,999.61..1,803,684,962.52 rows=727,193 width=113) (actual rows= loops=)

  • Hash Cond: ((evnt.account_id = agnt.account_id) AND (evnt.log_user_id = agnt.agent_id))
3. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=92,214,029.81..1,790,698,175.42 rows=727,193 width=84) (actual rows= loops=)

  • Hash Cond: ((external_lead_details.account_id = los.account_id) AND (external_lead_details.account_lead_id = los.account_lead_id) AND ((external_lead_details.cur_loan_number)::text = (los.account_loan_id)::text))
4. 0.000 0.000 ↓ 0.0

Merge Right Join (cost=92,131,225.24..1,790,581,455.91 rows=727,193 width=91) (actual rows= loops=)

  • Merge Cond: ((external_lead_details.account_lead_id = extled.account_lead_id) AND (external_lead_details.account_id = extled.account_id))
  • Filter: ((CASE WHEN (external_lead_details.account_id = 2) THEN CASE WHEN ((SubPlan 2) AND (CASE WHEN ((CASE WHEN ((external_leads.loan_amount_stated = 0) AND (external_leads.purchase_price_stated = 0) AND (external_leads.home_value_stated IS NOT NULL)) THEN (((external_leads.home_value_stated)::numeric * 0.8))::double precision WHEN ((external_leads.loan_amount_stated = 0) AND (external_leads.loan_amount_stated IS NOT NULL)) THEN (((external_leads.purchase_price_stated)::numeric * 0.8))::double precision WHEN ((external_leads.loan_amount_stated = external_leads.purchase_price_stated) AND (external_leads.loan_amount_stated > 0)) THEN (((external_leads.purchase_price_stated)::numeric * 0.8))::double precision WHEN ((external_leads.home_value_stated = external_leads.loan_amount_stated) AND (external_leads.home_value_stated > 0)) THEN (((external_leads.home_value_stated)::numeric * 0.8))::double precision WHEN ((external_lead_details.account_id = 2) AND (external_leads.purchase_price_stated IS NOT NULL) AND (external_lead_details.down_payment IS NOT NULL)) THEN ((external_leads.purchase_price_stated - external_lead_details.down_payment))::double precision WHEN (external_leads.loan_amount_stated IS NOT NULL) THEN (external_leads.loan_amount_stated)::double precision ELSE NULL::double precision END IS NULL) AND (external_leads.home_value_stated IS NOT NULL)) THEN (((external_leads.home_value_stated)::numeric * 0.8))::double precision WHEN ((CASE WHEN ((external_leads.home_value_stated IS NOT NULL) AND (external_leads.home_value_stated <> 0)) THEN (external_leads.home_value_stated)::double precision WHEN ((external_leads.purchase_price_stated IS NOT NULL) AND (external_leads.purchase_price_stated <> 0)) THEN (external_leads.purchase_price_stated)::double precision WHEN ((external_leads.loan_amount_stated IS NOT NULL) AND (external_leads.loan_amount_stated <> 0)) THEN ((external_leads.loan_amount_stated)::double precision * '0.800000000000000044'::double precision) ELSE NULL::double precision END IS NOT NULL) AND (CASE WHEN ((external_leads.loan_amount_stated = 0) AND (external_leads.purchase_price_stated = 0) AND (external_leads.home_value_stated IS NOT NULL)) THEN (((external_leads.home_value_stated)::numeric * 0.8))::double precision WHEN ((external_leads.loan_amount_stated = 0) AND (external_leads.loan_amount_stated IS NOT NULL)) THEN (((external_leads.purchase_price_stated)::numeric * 0.8))::double precision WHEN ((external_leads.loan_amount_stated = external_leads.purchase_price_stated) AND (external_leads.loan_amount_stated > 0)) THEN (((external_leads.purchase_price_stated)::numeric * 0.8))::double precision WHEN ((external_leads.home_value_stated = external_leads.loan_amount_stated) AND (external_leads.home_value_stated > 0)) THEN (((external_leads.home_value_stated)::numeric * 0.8))::double precision WHEN ((external_lead_details.account_id = 2) AND (external_leads.purchase_price_stated IS NOT NULL) AND (external_lead_details.down_payment IS NOT NULL)) THEN ((external_leads.purchase_price_stated - external_lead_details.down_payment))::double precision WHEN (external_leads.loan_amount_stated IS NOT NULL) THEN (external_leads.loan_amount_stated)::double precision ELSE NULL::double precision END IS NOT NULL) AND (CASE WHEN ((external_leads.home_value_stated IS NOT NULL) AND (external_leads.home_value_stated <> 0)) THEN (external_leads.home_value_stated)::double precision WHEN ((external_leads.purchase_price_stated IS NOT NULL) AND (external_leads.purchase_price_stated <> 0)) THEN (external_leads.purchase_price_stated)::double precision WHEN ((external_leads.loan_amount_stated IS NOT NULL) AND (external_leads.loan_amount_stated <> 0)) THEN ((external_leads.loan_amount_stated)::double precision * '0.800000000000000044'::double precision) ELSE NULL::double precision END = CASE WHEN ((external_leads.loan_amount_stated = 0) AND (external_leads.purchase_price_stated = 0) AND (external_leads.home_value_stated IS NOT NULL)) THEN (((external_leads.home_value_stated)::numeric * 0.8))::double precision WHEN ((external_leads.loan_amount_stated = 0) AND (external_leads.loan_amount_stated IS NOT NULL)) THEN (((external_leads.purchase_price_stated)::numeric * 0.8))::double precision WHEN ((external_leads.loan_amount_stated = external_leads.purchase_price_stated) AND (external_leads.loan_amount_stated > 0)) THEN (((external_leads.purchase_price_stated)::numeric * 0.8))::double precision WHEN ((external_leads.home_value_stated = external_leads.loan_amount_stated) AND (external_leads.home_value_stated > 0)) THEN (((external_leads.home_value_stated)::numeric * 0.8))::double precision WHEN ((external_lead_details.account_id = 2) AND (external_leads.purchase_price_stated IS NOT NULL) AND (external_lead_details.down_payment IS NOT NULL)) THEN ((external_leads.purchase_price_stated - external_lead_details.down_payment))::double precision WHEN (external_leads.loan_amount_stated IS NOT NULL) THEN (external_leads.loan_amount_stated)::double precision ELSE NULL::double precision END)) THEN (CASE WHEN ((external_leads.home_value_stated IS NOT NULL) AND (external_leads.home_value_stated <> 0)) THEN (external_leads.home_value_stated)::double precision WHEN ((external_leads.purchase_price_stated IS NOT NULL) AND (external_leads.purchase_price_stated <> 0)) THEN (external_leads.purchase_price_stated)::double precision WHEN ((external_leads.loan_amount_stated IS NOT NULL) AND (external_leads.loan_amount_stated <> 0)) THEN ((external_leads.loan_amount_stated)::double precision * '0.800000000000000044'::double precision) ELSE NULL::double precision END * '0.800000000000000044'::double precision) ELSE CASE WHEN ((external_leads.loan_amount_stated = 0) AND (external_leads.purchase_price_stated = 0) AND (external_leads.home_value_stated IS NOT NULL)) THEN (((external_leads.home_value_stated)::numeric * 0.8))::double precision WHEN ((external_leads.loan_amount_stated = 0) AND (external_leads.loan_amount_stated IS NOT NULL)) THEN (((external_leads.purchase_price_stated)::numeric * 0.8))::double precision WHEN ((external_leads.loan_amount_stated = external_leads.purchase_price_stated) AND (external_leads.loan_amount_stated > 0)) THEN (((external_leads.purchase_price_stated)::numeric * 0.8))::double precision WHEN ((external_leads.home_value_stated = external_leads.loan_amount_stated) AND (external_leads.home_value_stated > 0)) THEN (((external_leads.home_value_stated)::numeric * 0.8))::double precision WHEN ((external_lead_details.account_id = 2) AND (external_leads.purchase_price_stated IS NOT NULL) AND (external_lead_details.down_payment IS NOT NULL)) THEN ((external_leads.purchase_price_stated - external_lead_details.down_payment))::double precision WHEN (external_leads.loan_amount_stated IS NOT NULL) THEN (external_leads.loan_amount_stated)::double precision ELSE NULL::double precision END END IS NOT NULL) AND (CASE WHEN ((CASE WHEN ((external_leads.loan_amount_stated = 0) AND (external_leads.purchase_price_stated = 0) AND (external_leads.home_value_stated IS NOT NULL)) THEN (((external_leads.home_value_stated)::numeric * 0.8))::double precision WHEN ((external_leads.loan_amount_stated = 0) AND (external_leads.loan_amount_stated IS NOT NULL)) THEN (((external_leads.purchase_price_stated)::numeric * 0.8))::double precision WHEN ((external_leads.loan_amount_stated = external_leads.purchase_price_stated) AND (external_leads.loan_amount_stated > 0)) THEN (((external_leads.purchase_price_stated)::numeric * 0.8))::double precision WHEN ((external_leads.home_value_stated = external_leads.loan_amount_stated) AND (external_leads.home_value_stated > 0)) THEN (((external_leads.home_value_stated)::numeric * 0.8))::double precision WHEN ((external_lead_details.account_id = 2) AND (external_leads.purchase_price_stated IS NOT NULL) AND (external_lead_details.down_payment IS NOT NULL)) THEN ((external_leads.purchase_price_stated - external_lead_details.down_payment))::double precision WHEN (external_leads.loan_amount_stated IS NOT NULL) THEN (external_leads.loan_amount_stated)::double precision ELSE NULL::double precision END IS NULL) AND (external_leads.home_value_stated IS NOT NULL)) THEN (((external_leads.home_value_stated)::numeric * 0.8))::double precision WHEN ((CASE WHEN ((external_leads.home_value_stated IS NOT NULL) AND (external_leads.home_value_stated <> 0)) THEN (external_leads.home_value_stated)::double precision WHEN ((external_leads.purchase_price_stated IS NOT NULL) AND (external_leads.purchase_price_stated <> 0)) THEN (external_leads.purchase_price_stated)::double precision WHEN ((external_leads.loan_amount_stated IS NOT NULL) AND (external_leads.loan_amount_stated <> 0)) THEN ((external_leads.loan_amount_stated)::double precision * '0.800000000000000044'::double precision) ELSE NULL::double precision END IS NOT NULL) AND (CASE WHEN ((external_leads.loan_amount_stated = 0) AND (external_leads.purchase_price_stated = 0) AND (external_leads.home_value_stated IS NOT NULL)) THEN (((external_leads.home_value_stated)::numeric * 0.8))::double precision WHEN ((external_leads.loan_amount_stated = 0) AND (external_leads.loan_amount_stated IS NOT NULL)) THEN (((external_leads.purchase_price_stated)::numeric * 0.8))::double precision WHEN ((external_leads.loan_amount_stated = external_leads.purchase_price_stated) AND (external_leads.loan_amount_stated > 0)) THEN (((external_leads.purchase_price_stated)::numeric * 0.8))::double precision WHEN ((external_leads.home_value_stated = external_leads.loan_amount_stated) AND (external_leads.home_value_stated > 0)) THEN (((external_leads.home_value_stated)::numeric * 0.8))::double precision WHEN ((external_lead_details.account_id = 2) AND (external_leads.purchase_price_stated IS NOT NULL) AND (external_lead_details.down_payment IS NOT NULL)) THEN ((external_leads.purchase_price_stated - external_lead_details.down_payment))::double precision WHEN (external_leads.loan_amount_stated IS NOT NULL) THEN (external_leads.loan_amount_stated)::double precision ELSE NULL::double precision END IS NOT NULL) AND (CASE WHEN ((external_leads.home_value_stated IS NOT NULL) AND (external_leads.home_value_stated <> 0)) THEN (external_leads.home_value_stated)::double precision WHEN ((external_leads.purchase_price_stated IS NOT NULL) AND (external_leads.purchase_price_stated <> 0)) THEN (external_leads.purchase_price_stated)::double precision WHEN ((external_leads.loan_amount_stated IS NOT NULL) AND (external_leads.loan_amount_stated <> 0)) THEN ((external_leads.loan_amount_stated)::double precision * '0.800000000000000044'::double precision) ELSE NULL::double precision END = CASE WHEN ((external_leads.loan_amount_stated = 0) AND (external_leads.purchase_price_stated = 0) AND (external_leads.home_value_stated IS NOT NULL)) THEN (((external_leads.home_value_stated)::numeric * 0.8))::double precision WHEN ((external_leads.loan_amount_stated = 0) AND (external_leads.loan_amount_stated IS NOT NULL)) THEN (((external_leads.purchase_price_stated)::numeric * 0.8))::double precision WHEN ((external_leads.loan_amount_stated = external_leads.purchase_price_stated) AND (external_leads.loan_amount_stated > 0)) THEN (((external_leads.purchase_price_stated)::numeric * 0.8))::double precision WHEN ((external_leads.home_value_stated = external_leads.loan_amount_stated) AND (external_leads.home_value_stated > 0)) THEN (((external_leads.home_value_stated)::numeric * 0.8))::double precision WHEN ((external_lead_details.account_id = 2) AND (external_leads.purchase_price_stated IS NOT NULL) AND (external_lead_details.down_payment IS NOT NULL)) THEN ((external_leads.purchase_price_stated - external_lead_details.down_payment))::double precision WHEN (external_leads.loan_amount_stated IS NOT NULL) THEN (external_leads.loan_amount_stated)::double precision ELSE NULL::double precision END)) THEN (CASE WHEN ((external_leads.home_value_stated IS NOT NULL) AND (external_leads.home_value_stated <> 0)) THEN (external_leads.home_value_stated)::double precision WHEN ((external_leads.purchase_price_stated IS NOT NULL) AND (external_leads.purchase_price_stated <> 0)) THEN (external_leads.purchase_price_stated)::double precision WHEN ((external_leads.loan_amount_stated IS NOT NULL) AND (external_leads.loan_amount_stated <> 0)) THEN ((external_leads.loan_amount_stated)::double precision * '0.800000000000000044'::double precision) ELSE NULL::double precision END * '0.800000000000000044'::double precision) ELSE CASE WHEN ((external_leads.loan_amount_stated = 0) AND (external_leads.purchase_price_stated = 0) AND (external_leads.home_value_stated IS NOT NULL)) THEN (((external_leads.home_value_stated)::numeric * 0.8))::double precision WHEN ((external_leads.loan_amount_stated = 0) AND (external_leads.loan_amount_stated IS NOT NULL)) THEN (((external_leads.purchase_price_stated)::numeric * 0.8))::double precision WHEN ((external_leads.loan_amount_stated = external_leads.purchase_price_stated) AND (external_leads.loan_amount_stated > 0)) THEN (((external_leads.purchase_price_stated)::numeric * 0.8))::double precision WHEN ((external_leads.home_value_stated = external_leads.loan_amount_stated) AND (external_leads.home_value_stated > 0)) THEN (((external_leads.home_value_stated)::numeric * 0.8))::double precision WHEN ((external_lead_details.account_id = 2) AND (external_leads.purchase_price_stated IS NOT NULL) AND (external_lead_details.down_payment IS NOT NULL)) THEN ((external_leads.purchase_price_stated - external_lead_details.down_payment))::double precision WHEN (external_leads.loan_amount_stated IS NOT NULL) THEN (external_leads.loan_amount_stated)::double precision ELSE NULL::double precision END END <> '0'::double precision)) THEN 1 ELSE 0 END ELSE CASE WHEN ((SubPlan 4) OR (CASE WHEN ((CASE WHEN ((external_leads.loan_amount_stated = 0) AND (external_leads.purchase_price_stated = 0) AND (external_leads.home_value_stated IS NOT NULL)) THEN (((external_leads.home_value_stated)::numeric * 0.8))::double precision WHEN ((external_leads.loan_amount_stated = 0) AND (external_leads.loan_amount_stated IS NOT NULL)) THEN (((external_leads.purchase_price_stated)::numeric * 0.8))::double precision WHEN ((external_leads.loan_amount_stated = external_leads.purchase_price_stated) AND (external_leads.loan_amount_stated > 0)) THEN (((external_leads.purchase_price_stated)::numeric * 0.8))::double precision WHEN ((external_leads.home_value_stated = external_leads.loan_amount_stated) AND (external_leads.home_value_stated > 0)) THEN (((external_leads.home_value_stated)::numeric * 0.8))::double precision WHEN ((external_lead_details.account_id = 2) AND (external_leads.purchase_price_stated IS NOT NULL) AND (external_lead_details.down_payment IS NOT NULL)) THEN ((external_leads.purchase_price_stated - external_lead_details.down_payment))::double precision WHEN (external_leads.loan_amount_stated IS NOT NULL) THEN (external_leads.loan_amount_stated)::double precision ELSE NULL::double precision END IS NULL) AND (external_leads.home_value_stated IS NOT NULL)) THEN (((external_leads.home_value_stated)::numeric * 0.8))::double precision WHEN ((CASE WHEN ((external_leads.home_value_stated IS NOT NULL) AND (external_leads.home_value_stated <> 0)) THEN (external_leads.home_value_stated)::double precision WHEN ((external_leads.purchase_price_stated IS NOT NULL) AND (external_leads.purchase_price_stated <> 0)) THEN (external_leads.purchase_price_stated)::double precision WHEN ((external_leads.loan_amount_stated IS NOT NULL) AND (external_leads.loan_amount_stated <> 0)) THEN ((external_leads.loan_amount_stated)::double precision * '0.800000000000000044'::double precision) ELSE NULL::double precision END IS NOT NULL) AND (CASE WHEN ((external_leads.loan_amount_stated = 0) AND (external_leads.purchase_price_stated = 0) AND (external_leads.home_value_stated IS NOT NULL)) THEN (((external_leads.home_value_stated)::numeric * 0.8))::double precision WHEN ((external_leads.loan_amount_stated = 0) AND (external_leads.loan_amount_stated IS NOT NULL)) THEN (((external_leads.purchase_price_stated)::numeric * 0.8))::double precision WHEN ((external_leads.loan_amount_stated = external_leads.purchase_price_stated) AND (external_leads.loan_amount_stated > 0)) THEN (((external_leads.purchase_price_stated)::numeric * 0.8))::double precision WHEN ((external_leads.home_value_stated = external_leads.loan_amount_stated) AND (external_leads.home_value_stated > 0)) THEN (((external_leads.home_value_stated)::numeric * 0.8))::double precision WHEN ((external_lead_details.account_id = 2) AND (external_leads.purchase_price_stated IS NOT NULL) AND (external_lead_details.down_payment IS NOT NULL)) THEN ((external_leads.purchase_price_stated - external_lead_details.down_payment))::double precision WHEN (external_leads.loan_amount_stated IS NOT NULL) THEN (external_leads.loan_amount_stated)::double precision ELSE NULL::double precision END IS NOT NULL) AND (CASE WHEN ((external_leads.home_value_stated IS NOT NULL) AND (external_leads.home_value_stated <> 0)) THEN (external_leads.home_value_stated)::double precision WHEN ((external_leads.purchase_price_stated IS NOT NULL) AND (external_leads.purchase_price_stated <> 0)) THEN (external_leads.purchase_price_stated)::double precision WHEN ((external_leads.loan_amount_stated IS NOT NULL) AND (external_leads.loan_amount_stated <> 0)) THEN ((external_leads.loan_amount_stated)::double precision * '0.800000000000000044'::double precision) ELSE NULL::double precision END = CASE WHEN ((external_leads.loan_amount_stated = 0) AND (external_leads.purchase_price_stated = 0) AND (external_leads.home_value_stated IS NOT NULL)) THEN (((external_leads.home_value_stated)::numeric * 0.8))::double precision WHEN ((external_leads.loan_amount_stated = 0) AND (external_leads.loan_amount_stated IS NOT NULL)) THEN (((external_leads.purchase_price_stated)::numeric * 0.8))::double precision WHEN ((external_leads.loan_amount_stated = external_leads.purchase_price_stated) AND (external_leads.loan_amount_stated > 0)) THEN (((external_leads.purchase_price_stated)::numeric * 0.8))::double precision WHEN ((external_leads.home_value_stated = external_leads.loan_amount_stated) AND (external_leads.home_value_stated > 0)) THEN (((external_leads.home_value_stated)::numeric * 0.8))::double precision WHEN ((external_lead_details.account_id = 2) AND (external_leads.purchase_price_stated IS NOT NULL) AND (external_lead_details.down_payment IS NOT NULL)) THEN ((external_leads.purchase_price_stated - external_lead_details.down_payment))::double precision WHEN (external_leads.loan_amount_stated IS NOT NULL) THEN (external_leads.loan_amount_stated)::double precision ELSE NULL::double precision END)) THEN (CASE WHEN ((external_leads.home_value_stated IS NOT NULL) AND (external_leads.home_value_stated <> 0)) THEN (external_leads.home_value_stated)::double precision WHEN ((external_leads.purchase_price_stated IS NOT NULL) AND (external_leads.purchase_price_stated <> 0)) THEN (external_leads.purchase_price_stated)::double precision WHEN ((external_leads.loan_amount_stated IS NOT NULL) AND (external_leads.loan_amount_stated <> 0)) THEN ((external_leads.loan_amount_stated)::double precision * '0.800000000000000044'::double precision) ELSE NULL::double precision END * '0.800000000000000044'::double precision) ELSE CASE WHEN ((external_leads.loan_amount_stated = 0) AND (external_leads.purchase_price_stated = 0) AND (external_leads.home_value_stated IS NOT NULL)) THEN (((external_leads.home_value_stated)::numeric * 0.8))::double precision WHEN ((external_leads.loan_amount_stated = 0) AND (external_leads.loan_amount_stated IS NOT NULL)) THEN (((external_leads.purchase_price_stated)::numeric * 0.8))::double precision WHEN ((external_leads.loan_amount_stated = external_leads.purchase_price_stated) AND (external_leads.loan_amount_stated > 0)) THEN (((external_leads.purchase_price_stated)::numeric * 0.8))::double precision WHEN ((external_leads.home_value_stated = external_leads.loan_amount_stated) AND (external_leads.home_value_stated > 0)) THEN (((external_leads.home_value_stated)::numeric * 0.8))::double precision WHEN ((external_lead_details.account_id = 2) AND (external_leads.purchase_price_stated IS NOT NULL) AND (external_lead_details.down_payment IS NOT NULL)) THEN ((external_leads.purchase_price_stated - external_lead_details.down_payment))::double precision WHEN (external_leads.loan_amount_stated IS NOT NULL) THEN (external_leads.loan_amount_stated)::double precision ELSE NULL::double precision END END IS NULL) OR (CASE WHEN ((CASE WHEN ((external_leads.loan_amount_stated = 0) AND (external_leads.purchase_price_stated = 0) AND (external_leads.home_value_stated IS NOT NULL)) THEN (((external_leads.home_value_stated)::numeric * 0.8))::double precision WHEN ((external_leads.loan_amount_stated = 0) AND (external_leads.loan_amount_stated IS NOT NULL)) THEN (((external_leads.purchase_price_stated)::numeric * 0.8))::double precision WHEN ((external_leads.loan_amount_stated = external_leads.purchase_price_stated) AND (external_leads.loan_amount_stated > 0)) THEN (((external_leads.purchase_price_stated)::numeric * 0.8))::double precision WHEN ((external_leads.home_value_stated = external_leads.loan_amount_stated) AND (external_leads.home_value_stated > 0)) THEN (((external_leads.home_value_stated)::numeric * 0.8))::double precision WHEN ((external_lead_details.account_id = 2) AND (external_leads.purchase_price_stated IS NOT NULL) AND (external_lead_details.down_payment IS NOT NULL)) THEN ((external_leads.purchase_price_stated - external_lead_details.down_payment))::double precision WHEN (external_leads.loan_amount_stated IS NOT NULL) THEN (external_leads.loan_amount_stated)::double precision ELSE NULL::double precision END IS NULL) AND (external_leads.home_value_stated IS NOT NULL)) THEN (((external_leads.home_value_stated)::numeric * 0.8))::double precision WHEN ((CASE WHEN ((external_leads.home_value_stated IS NOT NULL) AND (external_leads.home_value_stated <> 0)) THEN (external_leads.home_value_stated)::double precision WHEN ((external_leads.purchase_price_stated IS NOT NULL) AND (external_leads.purchase_price_stated <> 0)) THEN (external_leads.purchase_price_stated)::double precision WHEN ((external_leads.loan_amount_stated IS NOT NULL) AND (external_leads.loan_amount_stated <> 0)) THEN ((external_leads.loan_amount_stated)::double precision * '0.800000000000000044'::double precision) ELSE NULL::double precision END IS NOT NULL) AND (CASE WHEN ((external_leads.loan_amount_stated = 0) AND (external_leads.purchase_price_stated = 0) AND (external_leads.home_value_stated IS NOT NULL)) THEN (((external_leads.home_value_stated)::numeric * 0.8))::double precision WHEN ((external_leads.loan_amount_stated = 0) AND (external_leads.loan_amount_stated IS NOT NULL)) THEN (((external_leads.purchase_price_stated)::numeric * 0.8))::double precision WHEN ((external_leads.loan_amount_stated = external_leads.purchase_price_stated) AND (external_leads.loan_amount_stated > 0)) THEN (((external_leads.purchase_price_stated)::numeric * 0.8))::double precision WHEN ((external_leads.home_value_stated = external_leads.loan_amount_stated) AND (external_leads.home_value_stated > 0)) THEN (((external_leads.home_value_stated)::numeric * 0.8))::double precision WHEN ((external_lead_details.account_id = 2) AND (external_leads.purchase_price_stated IS NOT NULL) AND (external_lead_details.down_payment IS NOT NULL)) THEN ((external_leads.purchase_price_stated - external_lead_details.down_payment))::double precision WHEN (external_leads.loan_amount_stated IS NOT NULL) THEN (external_leads.loan_amount_stated)::double precision ELSE NULL::double precision END IS NOT NULL) AND (CASE WHEN ((external_leads.home_value_stated IS NOT NULL) AND (external_leads.home_value_stated <> 0)) THEN (external_leads.home_value_stated)::double precision WHEN ((external_leads.purchase_price_stated IS NOT NULL) AND (external_leads.purchase_price_stated <> 0)) THEN (external_leads.purchase_price_stated)::double precision WHEN ((external_leads.loan_amount_stated IS NOT NULL) AND (external_leads.loan_amount_stated <> 0)) THEN ((external_leads.loan_amount_stated)::double precision * '0.800000000000000044'::double precision) ELSE NULL::double precision END = CASE WHEN ((external_leads.loan_amount_stated = 0) AND (external_leads.purchase_price_stated = 0) AND (external_leads.home_value_stated IS NOT NULL)) THEN (((external_leads.home_value_stated)::numeric * 0.8))::double precision WHEN ((external_leads.loan_amount_stated = 0) AND (external_leads.loan_amount_stated IS NOT NULL)) THEN (((external_leads.purchase_price_stated)::numeric * 0.8))::double precision WHEN ((external_leads.loan_amount_stated = external_leads.purchase_price_stated) AND (external_leads.loan_amount_stated > 0)) THEN (((external_leads.purchase_price_stated)::numeric * 0.8))::double precision WHEN ((external_leads.home_value_stated = external_leads.loan_amount_stated) AND (external_leads.home_value_stated > 0)) THEN (((external_leads.home_value_stated)::numeric * 0.8))::double precision WHEN ((external_lead_details.account_id = 2) AND (external_leads.purchase_price_stated IS NOT NULL) AND (external_lead_details.down_payment IS NOT NULL)) THEN ((external_leads.purchase_price_stated - external_lead_details.down_payment))::double precision WHEN (external_leads.loan_amount_stated IS NOT NULL) THEN (external_leads.loan_amount_stated)::double precision ELSE NULL::double precision END)) THEN (CASE WHEN ((external_leads.home_value_stated IS NOT NULL) AND (external_leads.home_value_stated <> 0)) THEN (external_leads.home_value_stated)::double precision WHEN ((external_leads.purchase_price_stated IS NOT NULL) AND (external_leads.purchase_price_stated <> 0)) THEN (external_leads.purchase_price_stated)::double precision WHEN ((external_leads.loan_amount_stated IS NOT NULL) AND (external_leads.loan_amount_stated <> 0)) THEN ((external_leads.loan_amount_stated)::double precision * '0.800000000000000044'::double precision) ELSE NULL::double precision END * '0.800000000000000044'::double precision) ELSE CASE WHEN ((external_leads.loan_amount_stated = 0) AND (external_leads.purchase_price_stated = 0) AND (external_leads.home_value_stated IS NOT NULL)) THEN (((external_leads.home_value_stated)::numeric * 0.8))::double precision WHEN ((external_leads.loan_amount_stated = 0) AND (external_leads.loan_amount_stated IS NOT NULL)) THEN (((external_leads.purchase_price_stated)::numeric * 0.8))::double precision WHEN ((external_leads.loan_amount_stated = external_leads.purchase_price_stated) AND (external_leads.loan_amount_stated > 0)) THEN (((external_leads.purchase_price_stated)::numeric * 0.8))::double precision WHEN ((external_leads.home_value_stated = external_leads.loan_amount_stated) AND (external_leads.home_value_stated > 0)) THEN (((external_leads.home_value_stated)::numeric * 0.8))::double precision WHEN ((external_lead_details.account_id = 2) AND (external_leads.purchase_price_stated IS NOT NULL) AND (external_lead_details.down_payment IS NOT NULL)) THEN ((external_leads.purchase_price_stated - external_lead_details.down_payment))::double precision WHEN (external_leads.loan_amount_stated IS NOT NULL) THEN (external_leads.loan_amount_stated)::double precision ELSE NULL::double precision END END = '0'::double precision)) THEN 0 ELSE 1 END END) = 1)
5. 0.000 0.000 ↓ 0.0

Merge Join (cost=3,321,682.68..3,464,841.51 rows=4,527,265 width=31) (actual rows= loops=)

  • Merge Cond: ((external_lead_details.account_lead_id = external_leads.account_lead_id) AND (external_lead_details.account_id = external_leads.account_id))
6. 0.000 0.000 ↓ 0.0

Sort (cost=1,747,190.40..1,761,257.69 rows=5,626,915 width=43) (actual rows= loops=)

  • Sort Key: external_lead_details.account_lead_id, external_lead_details.account_id
7. 0.000 0.000 ↓ 0.0

Seq Scan on external_lead_details (cost=0.00..770,111.15 rows=5,626,915 width=43) (actual rows= loops=)

8. 0.000 0.000 ↓ 0.0

Materialize (cost=1,574,440.31..1,602,308.72 rows=5,573,681 width=54) (actual rows= loops=)

9. 0.000 0.000 ↓ 0.0

Sort (cost=1,574,440.31..1,588,374.51 rows=5,573,681 width=54) (actual rows= loops=)

  • Sort Key: external_leads.account_lead_id, external_leads.account_id
10. 0.000 0.000 ↓ 0.0

Seq Scan on external_leads (cost=0.00..568,886.81 rows=5,573,681 width=54) (actual rows= loops=)

11.          

SubPlan (forMerge Join)

12. 0.000 0.000 ↓ 0.0

Result (cost=8.31..8.32 rows=1 width=0) (actual rows= loops=)

13.          

Initplan (forResult)

14. 0.000 0.000 ↓ 0.0

Index Only Scan using ix1_source_detail_lookup on source_detail_lookup (cost=0.29..8.31 rows=1 width=0) (actual rows= loops=)

  • Index Cond: ((account_id = external_lead_details.account_id) AND (source = upper(regexp_replace((external_leads.source)::text, '[^a-zA-Z0-9.+@]'::text, ''::text, 'g'::text))) AND (source_detail = upper(regexp_replace((external_lead_details.source_detail)::text, '[^a-zA-Z0-9.+@]'::text, ''::text, 'g'::text))) AND (campaign_group = '3RDPARTY'::text))
15. 0.000 0.000 ↓ 0.0

Result (cost=8.32..8.33 rows=1 width=0) (actual rows= loops=)

16.          

Initplan (forResult)

17. 0.000 0.000 ↓ 0.0

Index Only Scan using ix1_source_detail_lookup on source_detail_lookup source_detail_lookup_1 (cost=0.29..8.32 rows=1 width=0) (actual rows= loops=)

  • Index Cond: ((account_id = external_lead_details.account_id) AND (source = upper(regexp_replace((external_leads.source)::text, '[^a-zA-Z0-9.+@]'::text, ''::text, 'g'::text))) AND (source_detail = upper(regexp_replace((external_lead_details.source_detail)::text, '[^a-zA-Z0-9.+@]'::text, ''::text, 'g'::text))) AND (campaign_group = upper(regexp_replace((external_leads.campaign_group)::text, '[^a-zA-Z0-9.+@]'::text, ''::text, 'g'::text))) AND (ialgo_source = 0))
18. 0.000 0.000 ↓ 0.0

Materialize (cost=88,809,542.55..89,536,735.94 rows=145,438,678 width=68) (actual rows= loops=)

19. 0.000 0.000 ↓ 0.0

Sort (cost=88,809,542.55..89,173,139.25 rows=145,438,678 width=68) (actual rows= loops=)

  • Sort Key: extled.account_lead_id, extled.account_id
20. 0.000 0.000 ↓ 0.0

Merge Left Join (cost=47,996,031.95..51,195,306.03 rows=145,438,678 width=68) (actual rows= loops=)

  • Merge Cond: ((evnt.account_id = extled.account_id) AND (evnt.account_lead_id = extled.account_lead_id))
21. 0.000 0.000 ↓ 0.0

Sort (cost=47,996,031.52..48,359,628.22 rows=145,438,678 width=60) (actual rows= loops=)

  • Sort Key: evnt.account_id, evnt.account_lead_id
22. 0.000 0.000 ↓ 0.0

Seq Scan on external_events evnt (cost=0.00..11,873,110.00 rows=145,438,678 width=60) (actual rows= loops=)

  • Filter: (log_user_id IS NOT NULL)
23. 0.000 0.000 ↓ 0.0

Materialize (cost=0.43..159,263.85 rows=5,573,681 width=8) (actual rows= loops=)

24. 0.000 0.000 ↓ 0.0

Index Only Scan using ix_1_external_leads on external_leads extled (cost=0.43..145,329.65 rows=5,573,681 width=8) (actual rows= loops=)

25. 0.000 0.000 ↓ 0.0

Hash (cost=67,041.30..67,041.30 rows=647,730 width=27) (actual rows= loops=)

26. 0.000 0.000 ↓ 0.0

Seq Scan on los (cost=0.00..67,041.30 rows=647,730 width=27) (actual rows= loops=)

27. 0.000 0.000 ↓ 0.0

Hash (cost=908.12..908.12 rows=4,112 width=33) (actual rows= loops=)

28. 0.000 0.000 ↓ 0.0

Seq Scan on agent_profiles agnt (cost=0.00..908.12 rows=4,112 width=33) (actual rows= loops=)