explain.depesz.com

PostgreSQL's explain analyze made readable

Result: NYOW

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

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

2. 13.862 29,195.952 ↓ 3,286.0 3,286 1

HashAggregate (cost=2,986,331.45..2,986,331.49 rows=1 width=340) (actual time=29,192.875..29,195.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.552 29,182.090 ↓ 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,594.411..29,182.090 rows=3,294 loops=1)

  • Join Filter: (account_forms_collections.contact_id = contacts_1.id)
4. 2.695 29,168.656 ↓ 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,594.388..29,168.656 rows=3,294 loops=1)

5. 3.873 29,156.118 ↓ 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,594.375..29,156.118 rows=3,281 loops=1)

6. 1.722 29,145.683 ↓ 3,281.0 3,281 1

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

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

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

  • Hash Cond: (contacts.rep_code_mapping_id = rep_code_mappings_contacts_join.id)
8. 427.661 29,015.464 ↓ 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=20,379.705..29,015.464 rows=1,796,224 loops=1)

  • Hash Cond: (custodial_assets.custodial_asset_product_subgroup_id = custodial_asset_product_subgroups.id)
9. 434.235 28,587.771 ↓ 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=20,379.654..28,587.771 rows=1,796,224 loops=1)

  • Hash Cond: (custodial_assets.custodial_asset_class_id = custodial_asset_classes.id)
10. 324.758 28,153.526 ↓ 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=20,379.626..28,153.526 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,142.230 27,828.767 ↓ 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=20,379.609..27,828.767 rows=1,796,224 loops=1)

  • Hash Cond: (accounts.account_forms_collection_id = account_forms_collections.id)
12. 1,174.032 15,722.240 ↑ 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,410.413..15,722.240 rows=1,801,720 loops=1)

  • Hash Cond: (custodial_latest_positions_mvw.custodial_security_id = custodial_securities.id)
13. 2,096.770 14,263.058 ↑ 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,125.113..14,263.058 rows=1,807,373 loops=1)

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

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

  • Hash Cond: (custodial_latest_positions_mvw.custodial_security_id = securities_custodial_latest_positions_mvw.id)
15. 748.437 748.437 ↑ 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.011..748.437 rows=2,793,495 loops=1)

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

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

  • Buckets: 131072 Batches: 1 Memory Usage: 35957kB
17. 164.801 231.053 ↓ 1.0 657,733 1

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

  • Hash Cond: (securities_custodial_latest_positions_mvw.custodial_asset_id = custodial_assets.id)
18. 66.108 66.108 ↓ 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.004..66.108 rows=657,733 loops=1)

19. 0.057 0.144 ↓ 1.0 521 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 29kB
20. 0.087 0.087 ↓ 1.0 521 1

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

21. 441.613 9,790.087 ↑ 1.0 1,418,567 1

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

  • Buckets: 65536 Batches: 4 Memory Usage: 39841kB
22. 334.728 9,348.474 ↑ 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,539.857..9,348.474 rows=1,418,567 loops=1)

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

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

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

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

  • Hash Cond: (accounts_custodial_accounts_mvw.custodial_account_id = custodial_accounts.id)
25. 293.481 293.481 ↑ 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..293.481 rows=1,418,625 loops=1)

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

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

  • Buckets: 131072 Batches: 8 Memory Usage: 33872kB
27. 907.397 907.397 ↓ 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.003..907.397 rows=4,868,268 loops=1)

28. 585.459 2,790.239 ↑ 1.0 2,831,212 1

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

  • Buckets: 131072 Batches: 4 Memory Usage: 44266kB
29. 2,204.780 2,204.780 ↑ 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.008..2,204.780 rows=2,831,212 loops=1)

30. 0.255 0.552 ↓ 1.0 2,053 1

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

  • Buckets: 1024 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.004..0.297 rows=2,053 loops=1)

32. 132.976 285.150 ↓ 1.0 657,733 1

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

  • Buckets: 131072 Batches: 1 Memory Usage: 46755kB
33. 152.174 152.174 ↓ 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..152.174 rows=657,733 loops=1)

34. 766.090 9,964.297 ↓ 1.7 1,074,233 1

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

  • Buckets: 65536 Batches: 4 (originally 2) Memory Usage: 65537kB
35. 2,293.987 9,198.207 ↓ 1.7 1,074,233 1

Hash Join (cost=251,427.21..1,504,923.52 rows=620,822 width=98) (actual time=431.668..9,198.207 rows=1,074,233 loops=1)

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

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

  • Hash Cond: (contacts.owner_id = owners_contacts_join.id)
37. 4,182.341 4,182.341 ↓ 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.050..4,182.341 rows=1,725,538 loops=1)

38. 3.934 64.968 ↓ 1.0 14,563 1

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

  • Buckets: 2048 Batches: 1 Memory Usage: 1046kB
39. 7.397 61.034 ↓ 1.0 14,563 1

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

40. 3.429 3.429 ↓ 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.004..3.429 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. 190.102 366.319 ↑ 1.2 1,076,079 1

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

  • Buckets: 131072 Batches: 1 Memory Usage: 50442kB
43. 176.217 176.217 ↓ 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..176.217 rows=1,307,579 loops=1)

44. 0.001 0.001 ↓ 0.0 0 1

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

  • Buckets: 1024 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.006 0.010 ↑ 1.0 10 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
50. 0.004 0.004 ↑ 1.0 10 1

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

51. 0.021 0.032 ↑ 1.0 93 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 6kB
52. 0.011 0.011 ↑ 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.011 rows=93 loops=1)

53. 0.002 0.055 ↑ 1.0 2 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
54. 0.002 0.053 ↑ 1.0 2 1

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

55. 0.043 0.043 ↑ 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.043 rows=2 loops=1)

  • Index Cond: ((classic_urn)::text = ANY ('{RepCode:cfs-back-office:C35,RepCode:cfs-registration:C35}'::text[]))
56. 0.008 0.008 ↑ 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.004 rows=1 loops=2)

  • Index Cond: (rep_code_id = rep_codes.id)
57. 0.003 0.030 ↑ 1.0 1 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
58. 0.005 0.027 ↑ 1.0 1 1

Nested Loop Left Join (cost=0.55..16.60 rows=1 width=42) (actual time=0.026..0.027 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.006 0.006 ↑ 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.006 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 : 11.384 ms
Execution time : 29,202.479 ms