explain.depesz.com

PostgreSQL's explain analyze made readable

Result: oqN : Optimization for: Optimization for: Optimization for: Optimization for: Optimization for: plan #R6am; plan #PlFG; plan #8Mk; plan #0QSL; plan #NG4

Settings

Optimization path:

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 0.052 26.938 ↓ 11.0 11 1

Sort (cost=6,909.07..6,909.07 rows=1 width=1,056) (actual time=26.937..26.938 rows=11 loops=1)

  • Sort Key: (max(i.item_order_status_ts)) DESC
  • Sort Method: quicksort Memory: 36kB
2. 0.054 26.886 ↓ 11.0 11 1

WindowAgg (cost=6,908.95..6,909.06 rows=1 width=1,056) (actual time=26.863..26.886 rows=11 loops=1)

3. 0.048 26.832 ↓ 11.0 11 1

GroupAggregate (cost=6,908.95..6,909.04 rows=1 width=524) (actual time=26.809..26.832 rows=11 loops=1)

  • Group Key: mb.cart_id, c.master_account_id, c.cart_name, ((COALESCE((aot.order_type_override)::character varying, (c.cart_order_type)::character varying))::text), a.company_name, c.account_id, m.tp_account_id, c_1.full_name, ad.address1, ad.city, ad.region_code, ad.postal_code, p.phone_number, ei.email_address, (COALESCE(((vend.vendor_id)::text), (ra.vendor_id)::text)), (COALESCE(((av.company_name)::text), (av_1.company_name)::text)), c.coordination_contact_id, c.coordination_time_to_call, c.coordination_notes, c_2.full_name, p_1.phone_number, ei_1.email_address, c.cart_status, wts.namespace, wts.term, sw.notes
  • Filter: ((count(i.cart_item_id))::integer > 0)
4. 0.153 26.784 ↓ 17.0 17 1

Sort (cost=6,908.95..6,908.95 rows=1 width=541) (actual time=26.782..26.784 rows=17 loops=1)

  • Sort Key: mb.cart_id, c.master_account_id, c.cart_name, ((COALESCE((aot.order_type_override)::character varying, (c.cart_order_type)::character varying))::text), a.company_name, c.account_id, m.tp_account_id, c_1.full_name, ad.address1, ad.city, ad.region_code, ad.postal_code, p.phone_number, ei.email_address, (COALESCE(((vend.vendor_id)::text), (ra.vendor_id)::text)), (COALESCE(((av.company_name)::text), (av_1.company_name)::text)), c.coordination_contact_id, c.coordination_time_to_call, c.coordination_notes, c_2.full_name, p_1.phone_number, ei_1.email_address, c.cart_status, wts.namespace, wts.term, sw.notes
  • Sort Method: quicksort Memory: 33kB
5. 0.044 26.631 ↓ 17.0 17 1

Nested Loop Left Join (cost=976.46..6,908.94 rows=1 width=541) (actual time=11.621..26.631 rows=17 loops=1)

6. 0.029 26.485 ↓ 17.0 17 1

Nested Loop Left Join (cost=976.18..6,900.63 rows=1 width=572) (actual time=11.592..26.485 rows=17 loops=1)

7. 0.022 26.303 ↓ 17.0 17 1

Nested Loop Left Join (cost=975.61..6,883.62 rows=1 width=555) (actual time=11.571..26.303 rows=17 loops=1)

8. 0.029 26.196 ↓ 17.0 17 1

Nested Loop Left Join (cost=975.20..6,880.75 rows=1 width=533) (actual time=11.558..26.196 rows=17 loops=1)

9. 0.022 26.082 ↓ 17.0 17 1

Nested Loop Left Join (cost=974.78..6,878.47 rows=1 width=522) (actual time=11.542..26.082 rows=17 loops=1)

10. 0.034 25.958 ↓ 17.0 17 1

Nested Loop Left Join (cost=974.37..6,873.31 rows=1 width=507) (actual time=11.526..25.958 rows=17 loops=1)

11. 0.017 25.669 ↓ 17.0 17 1

Nested Loop Left Join (cost=973.81..6,856.61 rows=1 width=472) (actual time=11.491..25.669 rows=17 loops=1)

12. 0.035 25.414 ↓ 17.0 17 1

Nested Loop Left Join (cost=973.52..6,846.84 rows=1 width=425) (actual time=11.445..25.414 rows=17 loops=1)

13. 0.036 25.294 ↓ 17.0 17 1

Nested Loop Left Join (cost=973.24..6,843.90 rows=1 width=417) (actual time=11.428..25.294 rows=17 loops=1)

14. 0.031 25.207 ↓ 17.0 17 1

Nested Loop (cost=973.10..6,843.71 rows=1 width=385) (actual time=11.415..25.207 rows=17 loops=1)

15. 0.027 25.091 ↓ 17.0 17 1

Nested Loop (cost=972.68..6,843.09 rows=1 width=414) (actual time=11.398..25.091 rows=17 loops=1)

  • Join Filter: ((c.cart_id)::bpchar = (sw.cart_id)::bpchar)
16. 0.040 24.956 ↓ 4.5 18 1

Nested Loop Left Join (cost=972.40..6,841.81 rows=4 width=430) (actual time=11.379..24.956 rows=18 loops=1)

17. 0.022 24.880 ↓ 4.5 18 1

Nested Loop (cost=972.26..6,841.18 rows=4 width=430) (actual time=11.365..24.880 rows=18 loops=1)

18. 0.019 24.738 ↓ 6.0 12 1

Nested Loop (cost=971.85..6,825.68 rows=2 width=371) (actual time=11.346..24.738 rows=12 loops=1)

  • Join Filter: ((c_1.contact_id)::bpchar = (ad.contact_id)::bpchar)
19. 0.017 24.647 ↓ 4.0 12 1

Nested Loop (cost=971.43..6,823.93 rows=3 width=315) (actual time=11.331..24.647 rows=12 loops=1)

20. 0.016 24.546 ↓ 2.4 12 1

Nested Loop (cost=971.02..6,819.79 rows=5 width=287) (actual time=11.311..24.546 rows=12 loops=1)

21. 0.039 23.870 ↓ 2.4 12 1

Nested Loop (cost=970.60..6,781.98 rows=5 width=272) (actual time=11.290..23.870 rows=12 loops=1)

22. 7.793 23.735 ↑ 4.8 12 1

Hash Join (cost=970.32..6,676.44 rows=57 width=245) (actual time=11.265..23.735 rows=12 loops=1)

  • Hash Cond: ((c.account_id)::bpchar = (a.account_id)::bpchar)
  • Join Filter: (((c.cart_name)::text ~~* '%sudo%'::text) OR ((c.cart_id)::text ~~* '%sudo%'::text) OR ((a.account_id)::text ~~* '%sudo%'::text) OR ((a.company_name)::text ~~* '%sudo%'::text))
  • Rows Removed by Join Filter: 2488
23. 5.815 6.521 ↑ 1.0 2,500 1

Bitmap Heap Scan on sc_carts c (cost=111.97..5,811.52 rows=2,502 width=210) (actual time=1.078..6.521 rows=2,500 loops=1)

  • Recheck Cond: ((cart_type)::text = ANY ('{"MEDIA BUY CAMPAIGN","DIGITAL CAMPAIGN"}'::text[]))
  • Heap Blocks: exact=1674
24. 0.706 0.706 ↑ 1.0 2,500 1

Bitmap Index Scan on ix_sc_carts_lookup_cart_type (cost=0.00..111.34 rows=2,502 width=0) (actual time=0.706..0.706 rows=2,500 loops=1)

  • Index Cond: ((cart_type)::text = ANY ('{"MEDIA BUY CAMPAIGN","DIGITAL CAMPAIGN"}'::text[]))
25. 4.235 9.421 ↑ 1.0 12,327 1

Hash (cost=704.27..704.27 rows=12,327 width=35) (actual time=9.421..9.421 rows=12,327 loops=1)

  • Buckets: 16384 Batches: 1 Memory Usage: 946kB
26. 5.186 5.186 ↑ 1.0 12,327 1

Seq Scan on acct_accounts a (cost=0.00..704.27 rows=12,327 width=35) (actual time=0.011..5.186 rows=12,327 loops=1)

27. 0.096 0.096 ↑ 1.0 1 12

Index Scan using pk_sc_campaigns on sc_campaigns mb (cost=0.28..1.85 rows=1 width=27) (actual time=0.008..0.008 rows=1 loops=12)

  • Index Cond: ((cart_id)::bpchar = (c.cart_id)::bpchar)
28. 0.660 0.660 ↑ 1.0 1 12

Index Scan using ix_acct_contacts_account_id on acct_contacts c_1 (cost=0.41..7.55 rows=1 width=49) (actual time=0.009..0.055 rows=1 loops=12)

  • Index Cond: ((account_id)::bpchar = (a.account_id)::bpchar)
  • Filter: ((is_active IS TRUE) AND ((contact_type)::text = 'Primary'::text))
  • Rows Removed by Filter: 40
29. 0.084 0.084 ↑ 1.0 1 12

Index Scan using pk_acct_phones on acct_phones p (cost=0.41..0.83 rows=1 width=28) (actual time=0.007..0.007 rows=1 loops=12)

  • Index Cond: (((contact_id)::bpchar = (c_1.contact_id)::bpchar) AND ((phone_type)::text = 'Primary'::text))
  • Filter: (is_active IS TRUE)
30. 0.072 0.072 ↑ 1.0 1 12

Index Scan using ix_acct_addresses_contact_id on acct_addresses ad (cost=0.41..0.57 rows=1 width=56) (actual time=0.006..0.006 rows=1 loops=12)

  • Index Cond: ((contact_id)::bpchar = (p.contact_id)::bpchar)
  • Filter: ((is_active IS TRUE) AND ((address_type)::text = 'Primary'::text))
31. 0.120 0.120 ↑ 1.0 2 12

Index Scan using ix_sc_items_cart_id on sc_items i (cost=0.41..7.73 rows=2 width=59) (actual time=0.008..0.010 rows=2 loops=12)

  • Index Cond: ((cart_id)::bpchar = (c.cart_id)::bpchar)
32. 0.036 0.036 ↑ 1.0 1 18

Index Only Scan using pk_vend_vendors on vend_vendors v (cost=0.14..0.16 rows=1 width=17) (actual time=0.002..0.002 rows=1 loops=18)

  • Index Cond: (vendor_id = (i.vendor_id)::bpchar)
  • Heap Fetches: 0
33. 0.108 0.108 ↑ 1.0 1 18

Index Scan using pk_sc_workflows on sc_workflows sw (cost=0.28..0.31 rows=1 width=35) (actual time=0.006..0.006 rows=1 loops=18)

  • Index Cond: (((cart_id)::bpchar = (i.cart_id)::bpchar) AND ((wf_type)::text = 'Campaign'::text))
  • Filter: ((wf_status)::text = ANY ('{Submitted,Running,Paused,Completed,Cancelled}'::text[]))
34. 0.085 0.085 ↑ 1.0 1 17

Index Scan using ix_acct_e_info_contact_id on acct_e_info ei (cost=0.41..0.62 rows=1 width=39) (actual time=0.005..0.005 rows=1 loops=17)

  • Index Cond: ((contact_id)::bpchar = (ad.contact_id)::bpchar)
  • Filter: ((is_active IS TRUE) AND ((e_info_type)::text = 'Primary'::text))
35. 0.051 0.051 ↑ 1.0 1 17

Index Scan using pk_wf_type_statuses on wf_type_statuses wts (cost=0.14..0.17 rows=1 width=54) (actual time=0.003..0.003 rows=1 loops=17)

  • Index Cond: (((wf_type)::text = 'Campaign'::text) AND ((wf_status)::text = (sw.wf_status)::text))
36. 0.085 0.085 ↑ 1.0 1 17

Index Scan using ix_rel_masters_accounts_account_id on rel_masters_accounts m (cost=0.29..2.93 rows=1 width=42) (actual time=0.005..0.005 rows=1 loops=17)

  • Index Cond: ((account_id)::bpchar = (c.account_id)::bpchar)
  • Filter: ((master_account_id)::bpchar = (c.master_account_id)::bpchar)
37. 0.034 0.238 ↑ 1.0 1 17

Limit (cost=0.29..9.74 rows=1 width=96) (actual time=0.013..0.014 rows=1 loops=17)

38. 0.085 0.204 ↑ 1.0 1 17

Nested Loop (cost=0.29..9.74 rows=1 width=96) (actual time=0.012..0.012 rows=1 loops=17)

39. 0.051 0.051 ↑ 1.0 1 17

Seq Scan on vend_vendors vend (cost=0.00..1.44 rows=1 width=34) (actual time=0.003..0.003 rows=1 loops=17)

  • Filter: ((vendor_id)::bpchar = (v.vendor_id)::bpchar)
  • Rows Removed by Filter: 2
40. 0.068 0.068 ↑ 1.0 1 17

Index Scan using ix_acct_accounts_account_id on acct_accounts av (cost=0.29..8.30 rows=1 width=35) (actual time=0.004..0.004 rows=1 loops=17)

  • Index Cond: ((account_id)::bpchar = (vend.vendor_account_id)::bpchar)
41. 0.017 0.255 ↑ 1.0 1 17

Limit (cost=0.56..16.68 rows=1 width=67) (actual time=0.014..0.015 rows=1 loops=17)

42. 0.034 0.238 ↑ 1.0 1 17

Nested Loop (cost=0.56..16.68 rows=1 width=67) (actual time=0.014..0.014 rows=1 loops=17)

43. 0.136 0.136 ↑ 1.0 1 17

Index Scan using pk_rel_acct_vendor_services on rel_acct_vendor_services ra (cost=0.28..8.37 rows=1 width=34) (actual time=0.008..0.008 rows=1 loops=17)

  • Index Cond: (((account_id)::bpchar = (c.master_account_id)::bpchar) AND ((workflow)::text = 'MEDIA_BUY'::text))
  • Filter: (is_active IS TRUE)
44. 0.068 0.068 ↑ 1.0 1 17

Index Scan using ix_acct_accounts_account_id on acct_accounts av_1 (cost=0.29..8.30 rows=1 width=35) (actual time=0.004..0.004 rows=1 loops=17)

  • Index Cond: ((account_id)::bpchar = (c.master_account_id)::bpchar)
45. 0.102 0.102 ↑ 1.0 1 17

Index Scan using ix_acct_contacts_contact_id on acct_contacts c_2 (cost=0.41..5.13 rows=1 width=32) (actual time=0.006..0.006 rows=1 loops=17)

  • Index Cond: ((contact_id)::bpchar = (c.coordination_contact_id)::bpchar)
  • Filter: ((is_active IS TRUE) AND ((contact_type)::text = 'Coordination'::text))
46. 0.085 0.085 ↑ 1.0 1 17

Index Scan using pk_acct_phones on acct_phones p_1 (cost=0.41..2.28 rows=1 width=28) (actual time=0.005..0.005 rows=1 loops=17)

  • Index Cond: (((contact_id)::bpchar = (c.coordination_contact_id)::bpchar) AND ((phone_type)::text = 'Primary'::text))
  • Filter: (is_active IS TRUE)
47. 0.085 0.085 ↑ 1.0 1 17

Index Scan using ix_acct_e_info_contact_id on acct_e_info ei_1 (cost=0.41..2.88 rows=1 width=39) (actual time=0.005..0.005 rows=1 loops=17)

  • Index Cond: ((contact_id)::bpchar = (c.coordination_contact_id)::bpchar)
  • Filter: ((is_active IS TRUE) AND ((e_info_type)::text = 'Primary'::text))
48. 0.017 0.153 ↑ 1.0 1 17

Limit (cost=0.57..16.99 rows=1 width=17) (actual time=0.009..0.009 rows=1 loops=17)

49. 0.034 0.136 ↑ 1.0 1 17

Nested Loop (cost=0.57..16.99 rows=1 width=17) (actual time=0.008..0.008 rows=1 loops=17)

50. 0.051 0.051 ↑ 1.0 1 17

Index Scan using ix_rel_masters_accounts_account_id on rel_masters_accounts d (cost=0.29..8.30 rows=1 width=17) (actual time=0.003..0.003 rows=1 loops=17)

  • Index Cond: ((account_id)::bpchar = (c.account_id)::bpchar)
51. 0.051 0.051 ↑ 1.0 1 17

Index Scan using ix_acct_accounts_account_id on acct_accounts xa (cost=0.29..8.30 rows=1 width=17) (actual time=0.003..0.003 rows=1 loops=17)

  • Index Cond: ((account_id)::bpchar = (d.master_account_id)::bpchar)
  • Filter: (is_primary_master AND (is_active IS TRUE))
52. 0.102 0.102 ↑ 1.0 1 17

Index Scan using ix_acct_order_types_account_id_order_type on acct_order_types aot (cost=0.28..8.30 rows=1 width=43) (actual time=0.006..0.006 rows=1 loops=17)

  • Index Cond: (((account_id)::bpchar = COALESCE((d.master_account_id)::bpchar, (c.master_account_id)::bpchar)) AND ((order_type)::text = (c.cart_order_type)::text))
Planning time : 72.274 ms
Execution time : 27.587 ms