explain.depesz.com

PostgreSQL's explain analyze made readable

Result: wkl6

Settings
# exclusive inclusive rows x rows loops node
1. 5.512 29,283.464 ↓ 3,286.0 3,286 1

WindowAgg (cost=2,986,331.45..2,986,331.52 rows=1 width=340) (actual time=29,274.879..29,283.464 rows=3,286 loops=1)

2. 13.916 29,277.952 ↓ 3,286.0 3,286 1

HashAggregate (cost=2,986,331.45..2,986,331.49 rows=1 width=340) (actual time=29,274.855..29,277.952 rows=3,286 loops=1)

  • Group Key: custodial_securities.cusip, custodial_securities.fund, custodial_securities.sub_fund, programs.program_type, workgroups.name, workgroups.code, reps.last_name, reps.first_name, rep_codes.code, rep_codes.rep_type_code, rep_codes.product_type_code, rep_codes.tier_class_code, contacts_classic_users.id, contacts.classic_urn, contacts.last_name, contacts.first_name, contacts_mvbalances_mvw.contact_market_value, contacts_mvbalances_mvw.contact_money_market_balance, custodial_accounts.number, accounts.acctype, accounts.title, held_wheres.id, contacts_mvbalances_mvw.account_market_value, contacts_mvbalances_mvw.account_money_market_balance, custodial_accounts.opened_on, custodial_securities.symbol, custodial_securities.full_description, custodial_cost_basis_details.cost_basis, custodial_asset_classes.id, custodial_asset_product_subgroups.id
3. 3.643 29,264.036 ↓ 3,294.0 3,294 1

Nested Loop Semi Join (cost=2,368,493.49..2,986,331.36 rows=1 width=340) (actual time=20,148.283..29,264.036 rows=3,294 loops=1)

  • Join Filter: (account_forms_collections.contact_id = contacts_1.id)
4. 3.695 29,250.511 ↓ 3,294.0 3,294 1

Nested Loop Left Join (cost=2,368,493.06..2,986,323.90 rows=1 width=356) (actual time=20,148.251..29,250.511 rows=3,294 loops=1)

5. 4.178 29,236.973 ↓ 3,281.0 3,281 1

Nested Loop Left Join (cost=2,368,492.63..2,986,316.49 rows=1 width=337) (actual time=20,148.238..29,236.973 rows=3,281 loops=1)

6. 1.922 29,226.233 ↓ 3,281.0 3,281 1

Hash Join (cost=2,368,492.35..2,986,308.18 rows=1 width=329) (actual time=20,148.216..29,226.233 rows=3,281 loops=1)

  • Hash Cond: (owners_contacts_join.workgroup_id = workgroups.id)
7. 130.825 29,224.284 ↓ 27.3 3,281 1

Hash Join (cost=2,368,475.74..2,986,291.11 rows=120 width=303) (actual time=20,148.180..29,224.284 rows=3,281 loops=1)

  • Hash Cond: (contacts.rep_code_mapping_id = rep_code_mappings_contacts_join.id)
8. 421.268 29,093.407 ↓ 1.4 1,796,224 1

Hash Left Join (cost=2,368,436.76..2,981,284.75 rows=1,324,371 width=294) (actual time=19,927.344..29,093.407 rows=1,796,224 loops=1)

  • Hash Cond: (custodial_assets.custodial_asset_product_subgroup_id = custodial_asset_product_subgroups.id)
9. 430.352 28,672.111 ↓ 1.4 1,796,224 1

Hash Left Join (cost=2,368,433.66..2,963,071.55 rows=1,324,371 width=277) (actual time=19,927.304..28,672.111 rows=1,796,224 loops=1)

  • Hash Cond: (custodial_assets.custodial_asset_class_id = custodial_asset_classes.id)
10. 329.773 28,241.751 ↓ 1.4 1,796,224 1

Hash Left Join (cost=2,368,432.44..2,944,860.23 rows=1,324,371 width=266) (actual time=19,927.282..28,241.751 rows=1,796,224 loops=1)

  • Hash Cond: ((custodial_accounts.id = custodial_cost_basis_summaries.custodial_account_id) AND (custodial_securities.id = custodial_cost_basis_summaries.custodial_security_id))
11. 2,208.904 27,911.976 ↓ 1.4 1,796,224 1

Hash Join (cost=2,368,395.80..2,842,184.83 rows=1,324,371 width=260) (actual time=19,927.262..27,911.976 rows=1,796,224 loops=1)

  • Hash Cond: (accounts.account_forms_collection_id = account_forms_collections.id)
12. 1,303.759 16,317.193 ↑ 1.6 1,801,720 1

Hash Join (cost=846,011.00..1,128,509.74 rows=2,827,838 width=178) (actual time=10,536.261..16,317.193 rows=1,801,720 loops=1)

  • Hash Cond: (custodial_latest_positions_mvw.custodial_security_id = custodial_securities.id)
13. 2,290.157 14,723.569 ↑ 1.6 1,807,373 1

Hash Join (cost=815,361.82..1,044,778.23 rows=2,834,736 width=129) (actual time=10,246.251..14,723.569 rows=1,807,373 loops=1)

  • Hash Cond: (custodial_latest_positions_mvw.custodial_account_id = custodial_accounts.id)
14. 1,426.391 2,565.543 ↑ 1.0 2,793,495 1

Hash Left Join (cost=39,700.67..172,260.88 rows=2,799,812 width=57) (actual time=375.597..2,565.543 rows=2,793,495 loops=1)

  • Hash Cond: (custodial_latest_positions_mvw.custodial_security_id = securities_custodial_latest_positions_mvw.id)
15. 763.772 763.772 ↑ 1.0 2,793,495 1

Seq Scan on custodial_latest_positions_mvw (cost=0.00..80,131.86 rows=2,799,812 width=41) (actual time=0.016..763.772 rows=2,793,495 loops=1)

  • Filter: ((valued_on >= '2019-07-31'::date) AND (valued_on <= '2020-01-31'::date))
  • Rows Removed by Filter: 110,096
16. 124.125 375.380 ↓ 1.0 657,733 1

Hash (cost=31,479.46..31,479.46 rows=657,697 width=24) (actual time=375.380..375.380 rows=657,733 loops=1)

  • Buckets: 131,072 Batches: 1 Memory Usage: 35,957kB
17. 171.146 251.255 ↓ 1.0 657,733 1

Hash Left Join (cost=18.68..31,479.46 rows=657,697 width=24) (actual time=0.172..251.255 rows=657,733 loops=1)

  • Hash Cond: (securities_custodial_latest_positions_mvw.custodial_asset_id = custodial_assets.id)
18. 79.953 79.953 ↓ 1.0 657,733 1

Seq Scan on custodial_securities securities_custodial_latest_positions_mvw (cost=0.00..22,427.97 rows=657,697 width=16) (actual time=0.005..79.953 rows=657,733 loops=1)

19. 0.078 0.156 ↓ 1.0 521 1

Hash (cost=12.19..12.19 rows=519 width=24) (actual time=0.156..0.156 rows=521 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 29kB
20. 0.078 0.078 ↓ 1.0 521 1

Seq Scan on custodial_assets (cost=0.00..12.19 rows=519 width=24) (actual time=0.005..0.078 rows=521 loops=1)

21. 438.455 9,867.869 ↑ 1.0 1,418,567 1

Hash (cost=739,918.33..739,918.33 rows=1,418,625 width=80) (actual time=9,867.869..9,867.869 rows=1,418,567 loops=1)

  • Buckets: 65,536 Batches: 4 Memory Usage: 39,841kB
22. 324.710 9,429.414 ↑ 1.0 1,418,567 1

Hash Left Join (cost=549,595.53..739,918.33 rows=1,418,625 width=80) (actual time=4,620.485..9,429.414 rows=1,418,567 loops=1)

  • Hash Cond: (accounts.held_where_id = held_wheres.id)
23. 2,059.151 9,104.154 ↑ 1.0 1,418,567 1

Hash Join (cost=549,521.38..722,167.64 rows=1,418,625 width=59) (actual time=4,619.922..9,104.154 rows=1,418,567 loops=1)

  • Hash Cond: (accounts_custodial_accounts_mvw.account_id = accounts.id)
24. 2,126.618 4,190.324 ↑ 1.0 1,418,625 1

Hash Join (cost=218,923.92..320,602.96 rows=1,418,625 width=39) (actual time=1,760.209..4,190.324 rows=1,418,625 loops=1)

  • Hash Cond: (accounts_custodial_accounts_mvw.custodial_account_id = custodial_accounts.id)
25. 305.417 305.417 ↑ 1.0 1,418,625 1

Seq Scan on accounts_custodial_accounts_mvw (cost=0.00..32,819.82 rows=1,418,625 width=16) (actual time=0.008..305.417 rows=1,418,625 loops=1)

  • Filter: ((number)::text <> ''::text)
  • Rows Removed by Filter: 1
26. 856.110 1,758.289 ↓ 1.0 4,868,268 1

Hash (cost=129,918.52..129,918.52 rows=4,847,952 width=23) (actual time=1,758.289..1,758.289 rows=4,868,268 loops=1)

  • Buckets: 131,072 Batches: 8 Memory Usage: 33,872kB
27. 902.179 902.179 ↓ 1.0 4,868,268 1

Seq Scan on custodial_accounts (cost=0.00..129,918.52 rows=4,847,952 width=23) (actual time=0.004..902.179 rows=4,868,268 loops=1)

28. 639.579 2,854.679 ↑ 1.0 2,831,212 1

Hash (cost=272,878.87..272,878.87 rows=2,841,487 width=36) (actual time=2,854.679..2,854.679 rows=2,831,212 loops=1)

  • Buckets: 131,072 Batches: 4 Memory Usage: 44,266kB
29. 2,215.100 2,215.100 ↑ 1.0 2,831,212 1

Seq Scan on accounts (cost=0.00..272,878.87 rows=2,841,487 width=36) (actual time=0.007..2,215.100 rows=2,831,212 loops=1)

30. 0.253 0.550 ↓ 1.0 2,053 1

Hash (cost=48.51..48.51 rows=2,051 width=29) (actual time=0.550..0.550 rows=2,053 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 123kB
31. 0.297 0.297 ↓ 1.0 2,053 1

Seq Scan on held_wheres (cost=0.00..48.51 rows=2,051 width=29) (actual time=0.003..0.297 rows=2,053 loops=1)

32. 134.785 289.865 ↓ 1.0 657,733 1

Hash (cost=22,427.97..22,427.97 rows=657,697 width=57) (actual time=289.865..289.865 rows=657,733 loops=1)

  • Buckets: 131,072 Batches: 1 Memory Usage: 46,755kB
33. 155.080 155.080 ↓ 1.0 657,733 1

Seq Scan on custodial_securities (cost=0.00..22,427.97 rows=657,697 width=57) (actual time=0.006..155.080 rows=657,733 loops=1)

34. 609.783 9,385.879 ↓ 1.7 1,074,233 1

Hash (cost=1,504,923.52..1,504,923.52 rows=620,822 width=98) (actual time=9,385.879..9,385.879 rows=1,074,233 loops=1)

  • Buckets: 65,536 Batches: 4 (originally 2) Memory Usage: 65,537kB
35. 2,176.793 8,776.096 ↓ 1.7 1,074,233 1

Hash Join (cost=251,427.21..1,504,923.52 rows=620,822 width=98) (actual time=402.863..8,776.096 rows=1,074,233 loops=1)

  • Hash Cond: (contacts.id = account_forms_collections.contact_id)
36. 2,271.774 6,256.283 ↓ 1.7 1,720,235 1

Hash Join (cost=200,290.85..1,432,675.15 rows=993,586 width=82) (actual time=59.531..6,256.283 rows=1,720,235 loops=1)

  • Hash Cond: (contacts.owner_id = owners_contacts_join.id)
37. 3,925.056 3,925.056 ↓ 1.0 1,725,538 1

Seq Scan on contacts (cost=0.00..1,203,095.56 rows=1,720,256 width=59) (actual time=0.047..3,925.056 rows=1,725,538 loops=1)

38. 3.758 59.453 ↓ 1.0 14,563 1

Hash (cost=200,109.91..200,109.91 rows=14,475 width=39) (actual time=59.453..59.453 rows=14,563 loops=1)

  • Buckets: 2,048 Batches: 1 Memory Usage: 1,046kB
39. 2.234 55.695 ↓ 1.0 14,563 1

Nested Loop (cost=0.43..200,109.91 rows=14,475 width=39) (actual time=0.022..55.695 rows=14,563 loops=1)

40. 3.253 3.253 ↓ 1.0 25,104 1

Seq Scan on classic_users owners_contacts_join (cost=0.00..1,844.18 rows=25,018 width=24) (actual time=0.003..3.253 rows=25,104 loops=1)

41. 50.208 50.208 ↑ 1.0 1 25,104

Index Scan using contacts_pkey on contacts contacts_classic_users (cost=0.43..7.91 rows=1 width=23) (actual time=0.002..0.002 rows=1 loops=25,104)

  • Index Cond: (id = owners_contacts_join.contact_id)
42. 175.974 343.020 ↑ 1.2 1,076,079 1

Hash (cost=34,795.05..34,795.05 rows=1,307,305 width=16) (actual time=343.020..343.020 rows=1,076,079 loops=1)

  • Buckets: 131,072 Batches: 1 Memory Usage: 50,442kB
43. 167.046 167.046 ↓ 1.0 1,307,579 1

Seq Scan on account_forms_collections (cost=0.00..34,795.05 rows=1,307,305 width=16) (actual time=0.006..167.046 rows=1,307,579 loops=1)

44. 0.002 0.002 ↓ 0.0 0 1

Hash (cost=32.29..32.29 rows=290 width=38) (actual time=0.002..0.002 rows=0 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 0kB
45. 0.000 0.000 ↓ 0.0 0 1

Hash Join (cost=15.40..32.29 rows=290 width=38) (actual time=0.000..0.000 rows=0 loops=1)

  • Hash Cond: (custodial_cost_basis_details.custodial_cost_basis_summary_id = custodial_cost_basis_summaries.id)
46. 0.000 0.000 ↓ 0.0 0 1

Seq Scan on custodial_cost_basis_details (cost=0.00..12.90 rows=290 width=30) (actual time=0.000..0.000 rows=0 loops=1)

47. 0.000 0.000 ↓ 0.0 0

Hash (cost=12.40..12.40 rows=240 width=24) (never executed)

48. 0.000 0.000 ↓ 0.0 0

Seq Scan on custodial_cost_basis_summaries (cost=0.00..12.40 rows=240 width=24) (never executed)

49. 0.002 0.008 ↑ 1.0 10 1

Hash (cost=1.10..1.10 rows=10 width=19) (actual time=0.008..0.008 rows=10 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 1kB
50. 0.006 0.006 ↑ 1.0 10 1

Seq Scan on custodial_asset_classes (cost=0.00..1.10 rows=10 width=19) (actual time=0.004..0.006 rows=10 loops=1)

51. 0.016 0.028 ↑ 1.0 93 1

Hash (cost=1.93..1.93 rows=93 width=25) (actual time=0.028..0.028 rows=93 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 6kB
52. 0.012 0.012 ↑ 1.0 93 1

Seq Scan on custodial_asset_product_subgroups (cost=0.00..1.93 rows=93 width=25) (actual time=0.002..0.012 rows=93 loops=1)

53. 0.001 0.052 ↑ 1.0 2 1

Hash (cost=38.96..38.96 rows=2 width=25) (actual time=0.052..0.052 rows=2 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 1kB
54. 0.000 0.051 ↑ 1.0 2 1

Nested Loop (cost=0.70..38.96 rows=2 width=25) (actual time=0.048..0.051 rows=2 loops=1)

55. 0.041 0.041 ↑ 1.0 2 1

Index Scan using index_rep_codes_on_classic_urn on rep_codes (cost=0.41..16.09 rows=2 width=25) (actual time=0.022..0.041 rows=2 loops=1)

  • Index Cond: ((classic_urn)::text = ANY ('{RepCode:cfs-back-office:C35,RepCode:cfs-registration:C35}'::text[]))
56. 0.010 0.010 ↑ 2.0 1 2

Index Scan using index_rep_code_mappings_on_rep_code_id on rep_code_mappings rep_code_mappings_contacts_join (cost=0.29..11.42 rows=2 width=16) (actual time=0.003..0.005 rows=1 loops=2)

  • Index Cond: (rep_code_id = rep_codes.id)
57. 0.002 0.027 ↑ 1.0 1 1

Hash (cost=16.60..16.60 rows=1 width=42) (actual time=0.027..0.027 rows=1 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 1kB
58. 0.004 0.025 ↑ 1.0 1 1

Nested Loop Left Join (cost=0.55..16.60 rows=1 width=42) (actual time=0.025..0.025 rows=1 loops=1)

59. 0.016 0.016 ↑ 1.0 1 1

Index Scan using index_workgroups_on_classic_urn on workgroups (cost=0.28..8.29 rows=1 width=37) (actual time=0.016..0.016 rows=1 loops=1)

  • Index Cond: ((classic_urn)::text = 'Workgroup:cfs:RCF'::text)
60. 0.005 0.005 ↑ 1.0 1 1

Index Scan using index_programs_on_workgroup_id on programs (cost=0.28..8.29 rows=1 width=13) (actual time=0.005..0.005 rows=1 loops=1)

  • Index Cond: (workgroup_id = workgroups.id)
61. 6.562 6.562 ↑ 1.0 1 3,281

Index Scan using reps_pkey on reps (cost=0.29..8.30 rows=1 width=24) (actual time=0.002..0.002 rows=1 loops=3,281)

  • Index Cond: (id = rep_codes.rep_id)
62. 9.843 9.843 ↑ 1.0 1 3,281

Index Scan using custodial_account_id_contacts_mvbalances_mvw on contacts_mvbalances_mvw (cost=0.43..7.40 rows=1 width=35) (actual time=0.003..0.003 rows=1 loops=3,281)

  • Index Cond: (custodial_account_id = accounts_custodial_accounts_mvw.custodial_account_id)
63. 9.882 9.882 ↑ 1.0 1 3,294

Index Scan using contacts_pkey on contacts contacts_1 (cost=0.43..7.44 rows=1 width=8) (actual time=0.003..0.003 rows=1 loops=3,294)

  • Index Cond: (id = contacts.id)
  • Filter: (realm_id = ANY ('{1,2,5,7,3,4}'::integer[]))
Planning time : 10.705 ms
Execution time : 29,295.127 ms