explain.depesz.com

PostgreSQL's explain analyze made readable

Result: eqh9

Settings
# exclusive inclusive rows x rows loops node
1. 5.453 28,641.208 ↓ 3,286.0 3,286 1

WindowAgg (cost=3,001,010.45..3,001,010.52 rows=1 width=340) (actual time=28,633.044..28,641.208 rows=3,286 loops=1)

2. 13.445 28,635.755 ↓ 3,286.0 3,286 1

HashAggregate (cost=3,001,010.45..3,001,010.49 rows=1 width=340) (actual time=28,633.020..28,635.755 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. 0.988 28,622.310 ↓ 3,294.0 3,294 1

Nested Loop Semi Join (cost=2,346,150.31..3,001,010.36 rows=1 width=340) (actual time=20,005.001..28,622.310 rows=3,294 loops=1)

  • Join Filter: (account_forms_collections.contact_id = contacts_1.id)
4. 3.339 28,608.146 ↓ 3,294.0 3,294 1

Nested Loop Left Join (cost=2,346,149.88..3,001,002.91 rows=1 width=356) (actual time=20,004.984..28,608.146 rows=3,294 loops=1)

5. 3.936 28,594.964 ↓ 3,281.0 3,281 1

Nested Loop Left Join (cost=2,346,149.45..3,000,995.50 rows=1 width=337) (actual time=20,004.973..28,594.964 rows=3,281 loops=1)

6. 1.693 28,584.466 ↓ 3,281.0 3,281 1

Hash Join (cost=2,346,149.17..3,000,987.19 rows=1 width=329) (actual time=20,004.952..28,584.466 rows=3,281 loops=1)

  • Hash Cond: (owners_contacts_join.workgroup_id = workgroups.id)
7. 118.145 28,582.748 ↓ 27.3 3,281 1

Hash Join (cost=2,346,132.56..3,000,970.12 rows=120 width=303) (actual time=20,004.919..28,582.748 rows=3,281 loops=1)

  • Hash Cond: (contacts.rep_code_mapping_id = rep_code_mappings_contacts_join.id)
8. 423.421 28,464.552 ↓ 1.4 1,796,213 1

Hash Left Join (cost=2,346,093.57..2,995,963.76 rows=1,324,371 width=294) (actual time=19,835.127..28,464.552 rows=1,796,213 loops=1)

  • Hash Cond: (custodial_assets.custodial_asset_product_subgroup_id = custodial_asset_product_subgroups.id)
9. 426.386 28,041.106 ↓ 1.4 1,796,213 1

Hash Left Join (cost=2,346,090.48..2,977,750.56 rows=1,324,371 width=277) (actual time=19,835.095..28,041.106 rows=1,796,213 loops=1)

  • Hash Cond: (custodial_assets.custodial_asset_class_id = custodial_asset_classes.id)
10. 323.871 27,614.711 ↓ 1.4 1,796,213 1

Hash Left Join (cost=2,346,089.26..2,959,539.24 rows=1,324,371 width=266) (actual time=19,835.079..27,614.711 rows=1,796,213 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,251.442 27,290.839 ↓ 1.4 1,796,213 1

Hash Join (cost=2,346,052.62..2,856,863.84 rows=1,324,371 width=260) (actual time=19,835.066..27,290.839 rows=1,796,213 loops=1)

  • Hash Cond: (accounts.account_forms_collection_id = account_forms_collections.id)
12. 2,775.590 15,365.592 ↑ 1.6 1,801,720 1

Hash Join (cost=823,711.82..1,143,232.74 rows=2,827,838 width=178) (actual time=10,155.253..15,365.592 rows=1,801,720 loops=1)

  • Hash Cond: (custodial_latest_positions_mvw.custodial_account_id = custodial_accounts.id)
13. 1,595.275 2,867.887 ↑ 1.0 2,786,455 1

Hash Join (cost=48,050.67..238,176.88 rows=2,792,999 width=106) (actual time=429.473..2,867.887 rows=2,786,455 loops=1)

  • Hash Cond: (custodial_latest_positions_mvw.custodial_security_id = custodial_securities.id)
14. 843.233 843.233 ↑ 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.004..843.233 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
15. 168.857 429.379 ↓ 1.0 657,733 1

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

  • Buckets: 65536 Batches: 2 Memory Usage: 28554kB
16. 190.467 260.522 ↓ 1.0 657,733 1

Hash Left Join (cost=18.68..31,479.46 rows=657,697 width=73) (actual time=0.155..260.522 rows=657,733 loops=1)

  • Hash Cond: (custodial_securities.custodial_asset_id = custodial_assets.id)
17. 69.909 69.909 ↓ 1.0 657,733 1

Seq Scan on custodial_securities (cost=0.00..22,427.97 rows=657,697 width=65) (actual time=0.004..69.909 rows=657,733 loops=1)

18. 0.067 0.146 ↓ 1.0 521 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 29kB
19. 0.079 0.079 ↓ 1.0 521 1

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

20. 415.502 9,722.115 ↑ 1.0 1,418,567 1

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

  • Buckets: 65536 Batches: 4 Memory Usage: 39841kB
21. 339.351 9,306.613 ↑ 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,609.763..9,306.613 rows=1,418,567 loops=1)

  • Hash Cond: (accounts.held_where_id = held_wheres.id)
22. 2,109.184 8,966.710 ↑ 1.0 1,418,567 1

Hash Join (cost=549,521.38..722,167.64 rows=1,418,625 width=59) (actual time=4,609.200..8,966.710 rows=1,418,567 loops=1)

  • Hash Cond: (accounts_custodial_accounts_mvw.account_id = accounts.id)
23. 1,981.790 4,021.178 ↑ 1.0 1,418,625 1

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

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

  • Filter: ((number)::text <> ''::text)
  • Rows Removed by Filter: 1
25. 840.929 1,761.156 ↓ 1.0 4,868,268 1

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

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

27. 587.580 2,836.348 ↑ 1.0 2,831,213 1

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

  • Buckets: 131072 Batches: 4 Memory Usage: 44266kB
28. 2,248.768 2,248.768 ↑ 1.0 2,831,213 1

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

29. 0.274 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
30. 0.278 0.278 ↓ 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.278 rows=2,053 loops=1)

31. 565.125 9,673.805 ↓ 1.7 1,074,228 1

Hash (cost=1,504,879.53..1,504,879.53 rows=620,822 width=98) (actual time=9,673.805..9,673.805 rows=1,074,228 loops=1)

  • Buckets: 65536 Batches: 4 (originally 2) Memory Usage: 65537kB
32. 2,319.864 9,108.680 ↓ 1.7 1,074,228 1

Hash Join (cost=251,383.22..1,504,879.53 rows=620,822 width=98) (actual time=428.319..9,108.680 rows=1,074,228 loops=1)

  • Hash Cond: (contacts.id = account_forms_collections.contact_id)
33. 2,301.700 6,425.026 ↓ 1.7 1,720,230 1

Hash Join (cost=200,246.85..1,432,631.15 rows=993,586 width=82) (actual time=64.352..6,425.026 rows=1,720,230 loops=1)

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

35. 3.065 64.282 ↓ 1.0 14,563 1

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

  • Buckets: 2048 Batches: 1 Memory Usage: 1046kB
36. 7.632 61.217 ↓ 1.0 14,563 1

Nested Loop (cost=0.43..200,065.92 rows=14,475 width=39) (actual time=0.020..61.217 rows=14,563 loops=1)

37. 3.377 3.377 ↓ 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.377 rows=25,104 loops=1)

38. 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)
39. 172.362 363.790 ↑ 1.2 1,076,079 1

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

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

41. 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
42. 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)
43. 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)

44. 0.000 0.000 ↓ 0.0 0

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

45. 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)

46. 0.002 0.009 ↑ 1.0 10 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
47. 0.007 0.007 ↑ 1.0 10 1

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

48. 0.014 0.025 ↑ 1.0 93 1

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

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

50. 0.001 0.051 ↑ 1.0 2 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
51. 0.002 0.050 ↑ 1.0 2 1

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

52. 0.040 0.040 ↑ 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.021..0.040 rows=2 loops=1)

  • Index Cond: ((classic_urn)::text = ANY ('{RepCode:cfs-back-office:C35,RepCode:cfs-registration:C35}'::text[]))
53. 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)
54. 0.003 0.025 ↑ 1.0 1 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
55. 0.002 0.022 ↑ 1.0 1 1

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

56. 0.015 0.015 ↑ 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.015..0.015 rows=1 loops=1)

  • Index Cond: ((classic_urn)::text = 'Workgroup:cfs:RCF'::text)
57. 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)
58. 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)
59. 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)
60. 13.176 13.176 ↑ 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.004..0.004 rows=1 loops=3,294)

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