explain.depesz.com

PostgreSQL's explain analyze made readable

Result: aV6n

Settings
# exclusive inclusive rows x rows loops node
1. 3.831 29,227.005 ↓ 3,196.0 3,196 1

WindowAgg (cost=2,434,801.22..2,434,801.26 rows=1 width=321) (actual time=29,220.633..29,227.005 rows=3,196 loops=1)

2. 29.454 29,223.174 ↓ 3,196.0 3,196 1

HashAggregate (cost=2,434,801.22..2,434,801.24 rows=1 width=321) (actual time=29,220.609..29,223.174 rows=3,196 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. 4.366 29,193.720 ↓ 3,204.0 3,204 1

Nested Loop Semi Join (cost=2,185,432.64..2,434,801.14 rows=1 width=321) (actual time=23,715.181..29,193.720 rows=3,204 loops=1)

  • Join Filter: (account_forms_collections.contact_id = contacts_1.id)
4. 2.138 29,141.294 ↓ 3,204.0 3,204 1

Nested Loop Left Join (cost=2,185,432.21..2,434,793.69 rows=1 width=337) (actual time=23,715.155..29,141.294 rows=3,204 loops=1)

5. 3.135 28,963.651 ↓ 3,191.0 3,191 1

Nested Loop Left Join (cost=2,185,431.79..2,434,786.28 rows=1 width=318) (actual time=23,715.127..28,963.651 rows=3,191 loops=1)

6. 6.494 28,957.325 ↓ 3,191.0 3,191 1

Nested Loop Left Join (cost=2,185,431.64..2,434,784.10 rows=1 width=301) (actual time=23,715.119..28,957.325 rows=3,191 loops=1)

  • Join Filter: (custodial_asset_classes.id = custodial_assets.custodial_asset_class_id)
  • Rows Removed by Join Filter: 28,719
7. 2.166 28,947.640 ↓ 3,191.0 3,191 1

Nested Loop Left Join (cost=2,185,431.64..2,434,782.88 rows=1 width=290) (actual time=23,715.110..28,947.640 rows=3,191 loops=1)

8. 1.885 28,939.092 ↓ 3,191.0 3,191 1

Nested Loop Left Join (cost=2,185,431.36..2,434,776.14 rows=1 width=269) (actual time=23,715.101..28,939.092 rows=3,191 loops=1)

  • Join Filter: (custodial_securities.id = custodial_cost_basis_summaries.custodial_security_id)
9. 1.950 28,934.016 ↓ 3,191.0 3,191 1

Hash Join (cost=2,185,431.07..2,434,769.35 rows=1 width=263) (actual time=23,715.093..28,934.016 rows=3,191 loops=1)

  • Hash Cond: (owners_contacts_join.workgroup_id = workgroups.id)
10. 2.003 28,932.018 ↓ 28.7 3,191 1

Hash Left Join (cost=2,185,414.46..2,434,752.32 rows=111 width=237) (actual time=23,715.037..28,932.018 rows=3,191 loops=1)

  • Hash Cond: (securities_custodial_latest_positions_mvw.custodial_asset_id = custodial_assets.id)
11. 1.266 28,929.839 ↓ 28.7 3,191 1

Nested Loop Left Join (cost=2,185,395.79..2,434,732.12 rows=111 width=229) (actual time=23,714.839..28,929.839 rows=3,191 loops=1)

12. 3.561 28,851.989 ↓ 28.7 3,191 1

Nested Loop (cost=2,185,395.36..2,433,909.93 rows=111 width=229) (actual time=23,714.825..28,851.989 rows=3,191 loops=1)

13. 112.014 28,838.855 ↓ 16.6 3,191 1

Hash Join (cost=2,185,394.93..2,432,388.34 rows=192 width=214) (actual time=23,714.788..28,838.855 rows=3,191 loops=1)

  • Hash Cond: (contacts.rep_code_mapping_id = rep_code_mappings_contacts_join.id)
14. 581.053 28,726.717 ↑ 1.3 1,688,546 1

Hash Join (cost=2,185,339.32..2,424,374.83 rows=2,121,685 width=197) (actual time=23,560.237..28,726.717 rows=1,688,546 loops=1)

  • Hash Cond: (contacts.owner_id = owners_contacts_join.id)
15. 1,245.012 28,050.843 ↑ 1.3 1,688,546 1

Hash Join (cost=2,183,182.42..2,379,748.81 rows=2,125,227 width=189) (actual time=23,465.400..28,050.843 rows=1,688,546 loops=1)

  • Hash Cond: (custodial_latest_positions_mvw.custodial_security_id = custodial_securities.id)
16. 2,607.311 26,385.750 ↑ 1.3 1,694,145 1

Hash Join (cost=2,152,536.48..2,309,209.50 rows=2,130,411 width=131) (actual time=23,045.054..26,385.750 rows=1,694,145 loops=1)

  • Hash Cond: (custodial_latest_positions_mvw.custodial_account_id = custodial_accounts.id)
17. 736.979 736.979 ↑ 1.0 2,599,537 1

Seq Scan on custodial_latest_positions_mvw (cost=0.00..80,119.86 rows=2,599,920 width=20) (actual time=0.022..736.979 rows=2,599,537 loops=1)

  • Filter: ((valued_on >= '2019-12-31'::date) AND (valued_on <= '2020-01-31'::date))
  • Rows Removed by Filter: 304,054
18. 609.968 23,041.460 ↓ 1.2 1,418,452 1

Hash (cost=2,118,002.98..2,118,002.98 rows=1,148,120 width=119) (actual time=23,041.460..23,041.460 rows=1,418,452 loops=1)

  • Buckets: 65,536 Batches: 4 Memory Usage: 56,038kB
19. 3,192.800 22,431.492 ↓ 1.2 1,418,452 1

Hash Join (cost=1,869,401.07..2,118,002.98 rows=1,148,120 width=119) (actual time=14,037.890..22,431.492 rows=1,418,452 loops=1)

  • Hash Cond: (accounts_custodial_accounts_mvw.custodial_account_id = custodial_accounts.id)
20. 2,607.835 16,973.518 ↓ 1.2 1,418,452 1

Hash Join (cost=1,655,768.60..1,816,151.66 rows=1,148,120 width=96) (actual time=11,770.076..16,973.518 rows=1,418,452 loops=1)

  • Hash Cond: (accounts.account_forms_collection_id = account_forms_collections.id)
21. 2,300.535 5,535.269 ↑ 1.0 1,418,625 1

Hash Join (cost=330,139.71..425,494.75 rows=1,418,625 width=37) (actual time=2,936.704..5,535.269 rows=1,418,625 loops=1)

  • Hash Cond: (accounts_custodial_accounts_mvw.account_id = accounts.id)
22. 299.311 299.311 ↑ 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.013..299.311 rows=1,418,625 loops=1)

  • Filter: ((number)::text <> ''::text)
  • Rows Removed by Filter: 1
23. 775.213 2,935.423 ↓ 1.0 2,831,153 1

Hash (cost=272,727.87..272,727.87 rows=2,826,387 width=37) (actual time=2,935.423..2,935.423 rows=2,831,153 loops=1)

  • Buckets: 131,072 Batches: 4 Memory Usage: 44,266kB
24. 2,160.210 2,160.210 ↓ 1.0 2,831,153 1

Seq Scan on accounts (cost=0.00..272,727.87 rows=2,826,387 width=37) (actual time=0.012..2,160.210 rows=2,831,153 loops=1)

25. 563.752 8,830.414 ↓ 1.0 1,076,079 1

Hash (cost=1,298,547.07..1,298,547.07 rows=1,074,866 width=75) (actual time=8,830.414..8,830.414 rows=1,076,079 loops=1)

  • Buckets: 65,536 Batches: 2 Memory Usage: 59,128kB
26. 3,879.853 8,266.662 ↓ 1.0 1,076,079 1

Hash Join (cost=51,136.36..1,298,547.07 rows=1,074,866 width=75) (actual time=368.230..8,266.662 rows=1,076,079 loops=1)

  • Hash Cond: (contacts.id = account_forms_collections.contact_id)
27. 4,019.042 4,019.042 ↑ 1.2 1,725,536 1

Seq Scan on contacts (cost=0.00..1,206,200.62 rows=2,030,762 width=59) (actual time=0.025..4,019.042 rows=1,725,536 loops=1)

28. 190.248 367.767 ↑ 1.2 1,076,079 1

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

  • Buckets: 131,072 Batches: 1 Memory Usage: 50,442kB
29. 177.519 177.519 ↓ 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..177.519 rows=1,307,579 loops=1)

30. 1,049.435 2,265.174 ↓ 1.0 4,865,594 1

Hash (cost=128,052.54..128,052.54 rows=4,661,354 width=23) (actual time=2,265.174..2,265.174 rows=4,865,594 loops=1)

  • Buckets: 131,072 Batches: 8 (originally 4) Memory Usage: 65,537kB
31. 1,215.739 1,215.739 ↓ 1.0 4,865,594 1

Seq Scan on custodial_accounts (cost=0.00..128,052.54 rows=4,661,354 width=23) (actual time=0.004..1,215.739 rows=4,865,594 loops=1)

32. 139.453 420.081 ↓ 1.0 657,584 1

Hash (cost=22,426.53..22,426.53 rows=657,553 width=58) (actual time=420.081..420.081 rows=657,584 loops=1)

  • Buckets: 131,072 Batches: 1 Memory Usage: 46,743kB
33. 280.628 280.628 ↓ 1.0 657,584 1

Seq Scan on custodial_securities (cost=0.00..22,426.53 rows=657,553 width=58) (actual time=0.013..280.628 rows=657,584 loops=1)

34. 3.605 94.821 ↓ 1.0 25,102 1

Hash (cost=1,844.18..1,844.18 rows=25,018 width=24) (actual time=94.821..94.821 rows=25,102 loops=1)

  • Buckets: 4,096 Batches: 1 Memory Usage: 1,209kB
35. 91.216 91.216 ↓ 1.0 25,102 1

Seq Scan on classic_users owners_contacts_join (cost=0.00..1,844.18 rows=25,018 width=24) (actual time=1.862..91.216 rows=25,102 loops=1)

36. 0.001 0.124 ↑ 1.0 2 1

Hash (cost=55.58..55.58 rows=2 width=33) (actual time=0.124..0.124 rows=2 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 1kB
37. 0.003 0.123 ↑ 1.0 2 1

Nested Loop Left Join (cost=0.98..55.58 rows=2 width=33) (actual time=0.107..0.123 rows=2 loops=1)

38. 0.000 0.104 ↑ 1.0 2 1

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

39. 0.068 0.068 ↑ 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.039..0.068 rows=2 loops=1)

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

  • Index Cond: (rep_code_id = rep_codes.id)
41. 0.016 0.016 ↑ 1.0 1 2

Index Scan using reps_pkey on reps (cost=0.29..8.30 rows=1 width=24) (actual time=0.008..0.008 rows=1 loops=2)

  • Index Cond: (id = rep_codes.rep_id)
42. 9.573 9.573 ↑ 1.0 1 3,191

Index Scan using contacts_pkey on contacts contacts_classic_users (cost=0.43..7.91 rows=1 width=23) (actual time=0.003..0.003 rows=1 loops=3,191)

  • Index Cond: (id = owners_contacts_join.contact_id)
43. 76.584 76.584 ↑ 1.0 1 3,191

Index Scan using custodial_securities_pkey on custodial_securities securities_custodial_latest_positions_mvw (cost=0.42..7.40 rows=1 width=16) (actual time=0.022..0.024 rows=1 loops=3,191)

  • Index Cond: (id = custodial_latest_positions_mvw.custodial_security_id)
44. 0.065 0.176 ↓ 1.0 521 1

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

  • Buckets: 1,024 Batches: 1 Memory Usage: 29kB
45. 0.111 0.111 ↓ 1.0 521 1

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

46. 0.002 0.048 ↑ 1.0 1 1

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

  • Buckets: 1,024 Batches: 1 Memory Usage: 1kB
47. 0.004 0.046 ↑ 1.0 1 1

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

48. 0.028 0.028 ↑ 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.027..0.028 rows=1 loops=1)

  • Index Cond: ((classic_urn)::text = 'Workgroup:cfs:RCF'::text)
49. 0.014 0.014 ↑ 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.014..0.014 rows=1 loops=1)

  • Index Cond: (workgroup_id = workgroups.id)
50. 0.000 3.191 ↓ 0.0 0 3,191

Nested Loop (cost=0.29..6.77 rows=1 width=38) (actual time=0.001..0.001 rows=0 loops=3,191)

51. 3.191 3.191 ↓ 0.0 0 3,191

Index Scan using index_on_cus_cost_basis_acc_sec_and_portf_acc_type on custodial_cost_basis_summaries (cost=0.14..3.36 rows=1 width=24) (actual time=0.001..0.001 rows=0 loops=3,191)

  • Index Cond: (custodial_accounts.id = custodial_account_id)
52. 0.000 0.000 ↓ 0.0 0

Index Scan using index_on_cost_basis_record_identifier on custodial_cost_basis_details (cost=0.15..3.40 rows=1 width=30) (never executed)

  • Index Cond: (custodial_cost_basis_summary_id = custodial_cost_basis_summaries.id)
53. 6.382 6.382 ↑ 1.0 1 3,191

Index Scan using held_wheres_pkey on held_wheres (cost=0.28..6.73 rows=1 width=29) (actual time=0.002..0.002 rows=1 loops=3,191)

  • Index Cond: (id = accounts.held_where_id)
54. 3.191 3.191 ↑ 1.0 10 3,191

Seq Scan on custodial_asset_classes (cost=0.00..1.10 rows=10 width=19) (actual time=0.000..0.001 rows=10 loops=3,191)

55. 3.191 3.191 ↑ 1.0 1 3,191

Index Scan using custodial_asset_product_subgroups_pkey on custodial_asset_product_subgroups (cost=0.14..2.17 rows=1 width=25) (actual time=0.001..0.001 rows=1 loops=3,191)

  • Index Cond: (id = custodial_assets.custodial_asset_product_subgroup_id)
56. 175.505 175.505 ↑ 1.0 1 3,191

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.054..0.055 rows=1 loops=3,191)

  • Index Cond: (custodial_account_id = accounts_custodial_accounts_mvw.custodial_account_id)
57. 48.060 48.060 ↑ 1.0 1 3,204

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

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