explain.depesz.com

PostgreSQL's explain analyze made readable

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

Settings

Optimization path:

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 0.033 20.788 ↓ 11.0 11 1

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

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

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

3. 0.038 20.716 ↓ 11.0 11 1

GroupAggregate (cost=6,908.95..6,909.04 rows=1 width=524) (actual time=20.698..20.716 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.125 20.678 ↓ 17.0 17 1

Sort (cost=6,908.95..6,908.95 rows=1 width=541) (actual time=20.677..20.678 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.034 20.553 ↓ 17.0 17 1

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

6. 0.011 20.451 ↓ 17.0 17 1

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

7. 0.021 20.304 ↓ 17.0 17 1

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

8. 0.026 20.215 ↓ 17.0 17 1

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

9. 0.017 20.121 ↓ 17.0 17 1

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

10. 0.023 20.019 ↓ 17.0 17 1

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

11. 0.026 19.809 ↓ 17.0 17 1

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

12. 0.016 19.613 ↓ 17.0 17 1

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

13. 0.019 19.529 ↓ 17.0 17 1

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

14. 0.025 19.459 ↓ 17.0 17 1

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

15. 0.023 19.366 ↓ 17.0 17 1

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

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

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

17. 0.023 19.188 ↓ 4.5 18 1

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

18. 0.014 19.069 ↓ 6.0 12 1

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

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

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

20. 0.017 18.908 ↓ 2.4 12 1

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

21. 0.040 18.339 ↓ 2.4 12 1

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

22. 5.281 18.215 ↑ 4.8 12 1

Hash Join (cost=970.32..6,676.44 rows=57 width=245) (actual time=9.021..18.215 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. 4.749 5.279 ↑ 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=0.779..5.279 rows=2,500 loops=1)

  • Recheck Cond: ((cart_type)::text = ANY ('{"MEDIA BUY CAMPAIGN","DIGITAL CAMPAIGN"}'::text[]))
  • Heap Blocks: exact=1674
24. 0.530 0.530 ↑ 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.530..0.530 rows=2,500 loops=1)

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

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

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

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

27. 0.084 0.084 ↑ 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.007..0.007 rows=1 loops=12)

  • Index Cond: ((cart_id)::bpchar = (c.cart_id)::bpchar)
28. 0.552 0.552 ↑ 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.007..0.046 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.072 0.072 ↑ 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.006..0.006 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.060 0.060 ↑ 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.005..0.005 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.096 0.096 ↑ 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.007..0.008 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.090 0.090 ↑ 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.005..0.005 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.068 0.068 ↑ 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.004..0.004 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.068 0.068 ↑ 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.004..0.004 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.017 0.170 ↑ 1.0 1 17

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

38. 0.051 0.153 ↑ 1.0 1 17

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

39. 0.034 0.034 ↑ 1.0 1 17

Seq Scan on vend_vendors vend (cost=0.00..1.44 rows=1 width=34) (actual time=0.002..0.002 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.003..0.004 rows=1 loops=17)

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

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

42. 0.034 0.187 ↑ 1.0 1 17

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

43. 0.102 0.102 ↑ 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.006..0.006 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.051 0.051 ↑ 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.003..0.003 rows=1 loops=17)

  • Index Cond: ((account_id)::bpchar = (c.master_account_id)::bpchar)
45. 0.085 0.085 ↑ 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.005..0.005 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.068 0.068 ↑ 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.004..0.004 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.068 0.068 ↑ 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.004..0.004 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.136 ↑ 1.0 1 17

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

49. 0.017 0.119 ↑ 1.0 1 17

Nested Loop (cost=0.57..16.99 rows=1 width=17) (actual time=0.007..0.007 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.068 0.068 ↑ 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.004..0.004 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 : 73.023 ms
Execution time : 21.294 ms