explain.depesz.com

PostgreSQL's explain analyze made readable

Result: sK9i : No org id

Settings

Optimization path:

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 315.648 14,761.549 ↓ 28.9 28,888 1

Hash Left Join (cost=417.20..28,410.53 rows=1,000 width=88) (actual time=429.167..14,761.549 rows=28,888 loops=1)

  • Hash Cond: ((us.cid = st.cid) AND (us.property_id = st.property_id) AND (us.id = st.unit_space_id))
  • Join Filter: (((generate_series.generate_series)::date >= st.scheduled_start_date) AND ((generate_series.generate_series)::date <= st.scheduled_end_date))
2. 506.690 14,445.534 ↓ 28.9 28,888 1

Nested Loop Left Join (cost=408.64..28,320.71 rows=1,000 width=245) (actual time=428.754..14,445.534 rows=28,888 loops=1)

  • Join Filter: ((cl.cid = us.cid) AND (cl.property_id = us.property_id) AND (cl.unit_space_id = us.id) AND ((generate_series.generate_series)::date >= COALESCE(li.lease_start_date, (generate_series.generate_series)::date)) AND ((generate_series.generate_series)::date <= COALESCE(li.lease_end_date, (generate_series.generate_series)::date)))
  • Rows Removed by Join Filter: 4,243,455
3. 35.302 13,678.852 ↓ 28.9 28,888 1

Nested Loop Left Join (cost=405.69..27,946.37 rows=1,000 width=193) (actual time=417.741..13,678.852 rows=28,888 loops=1)

  • Join Filter: ((mr.cid = us.cid) AND (mr.property_id = us.property_id) AND (mr.unit_space_id = us.id) AND ((generate_series.generate_series)::date >= COALESCE((mrd.scheduled_start_datetime)::date, (generate_series.generate_series)::date)) AND ((generate_series.generate_series)::date <= COALESCE((mrd.scheduled_end_datetime)::date, (generate_series.generate_series)::date)))
  • Rows Removed by Join Filter: 259,992
4. 7,085.859 13,614.662 ↓ 28.9 28,888 1

Nested Loop Left Join (cost=404.55..26,365.65 rows=1,000 width=161) (actual time=416.806..13,614.662 rows=28,888 loops=1)

  • Join Filter: ((oc.cid = us.cid) AND (ocus_1.unit_space_id = us.id) AND ((generate_series.generate_series)::date >= lsw_1.start_date) AND ((generate_series.generate_series)::date <= lsw_1.end_date))
  • Rows Removed by Join Filter: 82,647,546
5. 16.571 1,704.507 ↓ 28.9 28,888 1

Nested Loop Left Join (cost=392.19..26,128.17 rows=1,000 width=129) (actual time=143.987..1,704.507 rows=28,888 loops=1)

6. 43.583 214.648 ↓ 28.9 28,888 1

Hash Left Join (cost=367.12..1,018.17 rows=1,000 width=65) (actual time=143.685..214.648 rows=28,888 loops=1)

  • Hash Cond: ((us.cid = laus.cid) AND (us.id = laus.unit_space_id) AND ((generate_series.generate_series)::date = laus.move_in_date))
7. 10.520 31.010 ↓ 28.9 28,888 1

Nested Loop (cost=366.22..1,004.77 rows=1,000 width=53) (actual time=3.588..31.010 rows=28,888 loops=1)

8. 1.274 12.012 ↓ 314.0 314 1

Nested Loop (cost=366.22..984.76 rows=1 width=45) (actual time=3.550..12.012 rows=314 loops=1)

9. 0.800 6.342 ↓ 13.7 314 1

Hash Join (cost=365.92..806.71 rows=23 width=41) (actual time=3.505..6.342 rows=314 loops=1)

  • Hash Cond: (us.property_floorplan_id = pf.id)
10. 2.096 2.150 ↓ 3.8 314 1

Bitmap Heap Scan on unit_spaces us (cost=5.71..446.28 rows=83 width=41) (actual time=0.085..2.150 rows=314 loops=1)

  • Recheck Cond: ((cid = 235) AND (property_id = 719,642))
  • Filter: ((deleted_on IS NULL) AND (occupancy_type_id <> 2))
  • Rows Removed by Filter: 48
  • Heap Blocks: exact=174
11. 0.054 0.054 ↓ 2.9 362 1

Bitmap Index Scan on idx_unit_spaces_company_property_id (cost=0.00..5.69 rows=127 width=0) (actual time=0.053..0.054 rows=362 loops=1)

  • Index Cond: ((cid = 235) AND (property_id = 719,642))
12. 0.476 3.392 ↑ 1.0 2,322 1

Hash (cost=330.85..330.85 rows=2,349 width=8) (actual time=3.391..3.392 rows=2,322 loops=1)

  • Buckets: 4,096 Batches: 1 Memory Usage: 123kB
13. 2.688 2.916 ↑ 1.0 2,322 1

Bitmap Heap Scan on property_floorplans pf (cost=50.49..330.85 rows=2,349 width=8) (actual time=0.265..2.916 rows=2,322 loops=1)

  • Recheck Cond: (cid = 235)
  • Heap Blocks: exact=164
14. 0.228 0.228 ↑ 1.0 2,324 1

Bitmap Index Scan on pk_property_floorplans (cost=0.00..49.90 rows=2,349 width=0) (actual time=0.228..0.228 rows=2,324 loops=1)

  • Index Cond: (cid = 235)
15. 4.396 4.396 ↑ 1.0 1 314

Index Scan using pk_property_units on property_units pu (cost=0.29..7.74 rows=1 width=16) (actual time=0.014..0.014 rows=1 loops=314)

  • Index Cond: ((cid = 235) AND (id = us.property_unit_id))
  • Filter: (property_id = 719,642)
16. 8.478 8.478 ↑ 10.9 92 314

Function Scan on generate_series (cost=0.01..10.01 rows=1,000 width=8) (actual time=0.000..0.027 rows=92 loops=314)

17. 5.806 140.055 ↓ 27,048.0 27,048 1

Hash (cost=0.88..0.88 rows=1 width=24) (actual time=140.055..140.055 rows=27,048 loops=1)

  • Buckets: 32,768 (originally 1024) Batches: 1 (originally 1) Memory Usage: 1,736kB
18. 134.249 134.249 ↓ 27,048.0 27,048 1

Function Scan on load_available_unit_spaces laus (cost=0.25..0.88 rows=1 width=24) (actual time=129.981..134.249 rows=27,048 loops=1)

  • Filter: (cid = 235)
19. 375.544 1,473.288 ↑ 1.0 1 28,888

Aggregate (cost=25.07..25.09 rows=1 width=64) (actual time=0.051..0.051 rows=1 loops=28,888)

20. 202.216 1,097.744 ↓ 2.8 14 28,888

Nested Loop Left Join (cost=0.86..25.05 rows=5 width=8) (actual time=0.018..0.038 rows=14 loops=28,888)

  • Join Filter: ((lt_1.lease_term_type_id = 2) AND (lt_1.cid = lsw_2.cid) AND (lsw_2.property_id = pcs.property_id) AND (lt_1.id = lsw_2.lease_term_id))
  • Rows Removed by Join Filter: 41
21. 86.664 519.984 ↓ 2.6 13 28,888

Nested Loop (cost=0.57..16.62 rows=5 width=16) (actual time=0.007..0.018 rows=13 loops=28,888)

22. 115.552 115.552 ↑ 1.0 1 28,888

Index Scan using idx_property_charge_settings_property_id on property_charge_settings pcs (cost=0.28..8.30 rows=1 width=12) (actual time=0.003..0.004 rows=1 loops=28,888)

  • Index Cond: (property_id = us.property_id)
  • Filter: (cid = us.cid)
23. 317.768 317.768 ↓ 13.0 13 28,888

Index Scan using idx_lease_terms_master on lease_terms lt_1 (cost=0.29..8.30 rows=1 width=16) (actual time=0.003..0.011 rows=13 loops=28,888)

  • Index Cond: ((cid = us.cid) AND (lease_term_structure_id = pcs.lease_term_structure_id))
  • Filter: (deleted_on IS NULL)
  • Rows Removed by Filter: 2
24. 144.440 375.544 ↓ 3.0 3 375,544

Materialize (cost=0.29..8.32 rows=1 width=16) (actual time=0.001..0.001 rows=3 loops=375,544)

25. 231.104 231.104 ↓ 3.0 3 28,888

Index Scan using ca_lease_start_windows_idx on lease_start_windows lsw_2 (cost=0.29..8.31 rows=1 width=16) (actual time=0.006..0.008 rows=3 loops=28,888)

  • Index Cond: ((cid = us.cid) AND (property_id = us.property_id) AND (end_date >= (generate_series.generate_series)::date))
  • Filter: ((deleted_on IS NULL) AND (is_active IS TRUE))
26. 4,503.739 4,824.296 ↓ 2,861.0 2,861 28,888

Materialize (cost=12.36..209.99 rows=1 width=48) (actual time=0.000..0.167 rows=2,861 loops=28,888)

27. 7.442 320.557 ↓ 2,861.0 2,861 1

Nested Loop (cost=12.36..209.98 rows=1 width=48) (actual time=1.934..320.557 rows=2,861 loops=1)

28. 1.535 304.532 ↓ 2,861.0 2,861 1

Nested Loop (cost=11.94..201.54 rows=1 width=36) (actual time=1.866..304.532 rows=2,861 loops=1)

29. 32.603 297.275 ↓ 2,861.0 2,861 1

Nested Loop (cost=11.66..193.22 rows=1 width=32) (actual time=1.832..297.275 rows=2,861 loops=1)

  • Join Filter: (oc.organization_id = o.id)
  • Rows Removed by Join Filter: 557,895
30. 0.464 0.464 ↓ 196.0 196 1

Seq Scan on organizations o (cost=0.00..6.30 rows=1 width=12) (actual time=0.319..0.464 rows=196 loops=1)

  • Filter: (cid = 235)
  • Rows Removed by Filter: 68
31. 112.333 264.208 ↓ 408.7 2,861 196

Hash Join (cost=11.66..186.83 rows=7 width=24) (actual time=0.018..1.348 rows=2,861 loops=196)

  • Hash Cond: (ocus_1.organization_contract_id = oc.id)
32. 150.920 150.920 ↑ 1.1 2,901 196

Seq Scan on organization_contract_unit_spaces ocus_1 (cost=0.00..167.01 rows=3,081 width=12) (actual time=0.013..0.770 rows=2,901 loops=196)

  • Filter: ((deleted_on IS NULL) AND (cid = 235))
  • Rows Removed by Filter: 4,060
33. 0.094 0.955 ↓ 352.0 352 1

Hash (cost=11.64..11.64 rows=1 width=20) (actual time=0.955..0.955 rows=352 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 26kB
34. 0.279 0.861 ↓ 352.0 352 1

Bitmap Heap Scan on organization_contracts oc (cost=4.30..11.64 rows=1 width=20) (actual time=0.612..0.861 rows=352 loops=1)

  • Recheck Cond: (cid = 235)
  • Filter: (organization_contract_status_type_id = ANY ('{1,2}'::integer[]))
  • Rows Removed by Filter: 48
  • Heap Blocks: exact=11
35. 0.582 0.582 ↓ 133.3 400 1

Bitmap Index Scan on ukey_organization_contracts_reservation_code (cost=0.00..4.30 rows=3 width=0) (actual time=0.582..0.582 rows=400 loops=1)

  • Index Cond: (cid = 235)
36. 5.722 5.722 ↑ 1.0 1 2,861

Index Scan using pk_lease_start_windows on lease_start_windows lsw_1 (cost=0.29..8.31 rows=1 width=16) (actual time=0.002..0.002 rows=1 loops=2,861)

  • Index Cond: ((cid = 235) AND (id = oc.lease_start_window_id))
  • Filter: ((deleted_on IS NULL) AND (is_active IS TRUE))
37. 8.583 8.583 ↑ 1.0 1 2,861

Index Scan using pk_customers on customers c_1 (cost=0.42..8.44 rows=1 width=21) (actual time=0.003..0.003 rows=1 loops=2,861)

  • Index Cond: ((cid = 235) AND (id = o.customer_id))
38. 27.976 28.888 ↓ 4.5 9 28,888

Materialize (cost=1.14..1,500.72 rows=2 width=60) (actual time=0.000..0.001 rows=9 loops=28,888)

39. 0.046 0.912 ↓ 4.5 9 1

Nested Loop (cost=1.14..1,500.71 rows=2 width=60) (actual time=0.605..0.912 rows=9 loops=1)

40. 0.016 0.605 ↓ 4.5 9 1

Nested Loop Left Join (cost=0.71..1,483.80 rows=2 width=16) (actual time=0.537..0.605 rows=9 loops=1)

  • Filter: ((COALESCE(ms.maintenance_status_type_id, 0) <> 2) AND (COALESCE(ms.maintenance_status_type_id, 0) <> 4))
41. 0.544 0.544 ↓ 4.5 9 1

Index Scan using idx_maintenance_requests_property_id on maintenance_requests mr (cost=0.43..1,467.17 rows=2 width=20) (actual time=0.495..0.544 rows=9 loops=1)

  • Index Cond: (property_id = 719,642)
  • Filter: ((cid IS NOT NULL) AND (parent_maintenance_request_id IS NULL) AND (deleted_on IS NULL) AND (cid = 235) AND (maintenance_request_type_id = 1))
  • Rows Removed by Filter: 5
42. 0.045 0.045 ↑ 1.0 1 9

Index Scan using pk_maintenance_statuses on maintenance_statuses ms (cost=0.28..8.30 rows=1 width=12) (actual time=0.005..0.005 rows=1 loops=9)

  • Index Cond: ((cid = mr.cid) AND (cid = 235) AND (id = mr.maintenance_status_id))
43. 0.261 0.261 ↑ 1.0 1 9

Index Scan using idx_maintenance_request_details_maintenance_request_id on maintenance_request_details mrd (cost=0.43..8.45 rows=1 width=20) (actual time=0.029..0.029 rows=1 loops=9)

  • Index Cond: (maintenance_request_id = mr.id)
44. 249.211 259.992 ↓ 24.5 147 28,888

Materialize (cost=2.95..164.35 rows=6 width=72) (actual time=0.000..0.009 rows=147 loops=28,888)

45. 1.150 10.781 ↓ 24.5 147 1

Nested Loop Left Join (cost=2.95..164.32 rows=6 width=72) (actual time=0.314..10.781 rows=147 loops=1)

  • Join Filter: (ocus.organization_contract_id = lsw.organization_contract_id)
  • Rows Removed by Join Filter: 47
46. 0.054 9.190 ↓ 24.5 147 1

Nested Loop Left Join (cost=2.67..114.40 rows=6 width=100) (actual time=0.247..9.190 rows=147 loops=1)

  • Join Filter: ((lt.cid = lsw.cid) AND (lsw.property_id = cl.property_id) AND (lt.id = lsw.lease_term_id))
  • Rows Removed by Join Filter: 1
47. 0.211 8.842 ↓ 24.5 147 1

Nested Loop (cost=2.38..112.34 rows=6 width=96) (actual time=0.234..8.842 rows=147 loops=1)

48. 0.164 8.337 ↓ 147.0 147 1

Nested Loop Left Join (cost=2.10..112.01 rows=1 width=88) (actual time=0.200..8.337 rows=147 loops=1)

49. 0.094 7.438 ↓ 147.0 147 1

Nested Loop Left Join (cost=1.68..103.56 rows=1 width=86) (actual time=0.184..7.438 rows=147 loops=1)

50. 0.068 6.315 ↓ 147.0 147 1

Nested Loop (cost=1.26..95.11 rows=1 width=82) (actual time=0.157..6.315 rows=147 loops=1)

  • Join Filter: ((cl.id = li.lease_id) AND (cl.active_lease_interval_id = li.id))
51. 0.095 4.483 ↓ 147.0 147 1

Nested Loop (cost=0.84..94.39 rows=1 width=70) (actual time=0.112..4.483 rows=147 loops=1)

52. 2.516 2.516 ↓ 31.2 156 1

Index Scan using idx_cached_leases_cid_property_id on cached_leases cl (cost=0.42..52.11 rows=5 width=54) (actual time=0.075..2.516 rows=156 loops=1)

  • Index Cond: ((cid = 235) AND (property_id = 719,642))
  • Filter: (lease_status_type_id = ANY ('{3,4,5}'::integer[]))
  • Rows Removed by Filter: 44
53. 1.872 1.872 ↑ 1.0 1 156

Index Scan using idx_cached_applications_lease_interval_id on cached_applications ca (cost=0.42..8.45 rows=1 width=24) (actual time=0.012..0.012 rows=1 loops=156)

  • Index Cond: (lease_interval_id = cl.active_lease_interval_id)
  • Filter: ((cid = 235) AND (cl.id = lease_id) AND (cl.unit_space_id = unit_space_id))
  • Rows Removed by Filter: 0
54. 1.764 1.764 ↑ 1.0 1 147

Index Scan using idx_lease_intervals on lease_intervals li (cost=0.42..0.71 rows=1 width=28) (actual time=0.012..0.012 rows=1 loops=147)

  • Index Cond: (id = ca.lease_interval_id)
  • Filter: ((cid = 235) AND (ca.lease_id = lease_id))
55. 1.029 1.029 ↑ 1.0 1 147

Index Scan using idx_lease_unit_spaces_lease_id on lease_unit_spaces lus (cost=0.42..8.44 rows=1 width=16) (actual time=0.007..0.007 rows=1 loops=147)

  • Index Cond: (lease_id = cl.id)
  • Filter: ((cid = 235) AND (cl.cid = cid) AND (unit_space_id = cl.unit_space_id))
56. 0.735 0.735 ↑ 1.0 1 147

Index Scan using pk_customers on customers c (cost=0.42..8.44 rows=1 width=10) (actual time=0.005..0.005 rows=1 loops=147)

  • Index Cond: ((cid = cl.cid) AND (cid = 235) AND (id = cl.primary_customer_id))
57. 0.294 0.294 ↑ 1.0 1 147

Index Scan using pk_lease_terms on lease_terms lt (cost=0.29..0.34 rows=1 width=12) (actual time=0.002..0.002 rows=1 loops=147)

  • Index Cond: ((cid = 235) AND (id = li.lease_term_id))
58. 0.294 0.294 ↑ 1.0 1 147

Index Scan using pk_lease_start_windows on lease_start_windows lsw (cost=0.29..0.33 rows=1 width=28) (actual time=0.002..0.002 rows=1 loops=147)

  • Index Cond: ((cid = 235) AND (id = li.lease_start_window_id))
  • Filter: ((deleted_on IS NULL) AND (is_active IS TRUE) AND (property_id = 719,642))
59. 0.441 0.441 ↑ 1.0 1 147

Index Scan using ca_organization_contract_unit_spaces_idx on organization_contract_unit_spaces ocus (cost=0.28..8.30 rows=1 width=16) (actual time=0.003..0.003 rows=1 loops=147)

  • Index Cond: ((cid = cl.cid) AND (cid = 235) AND (unit_space_id = cl.unit_space_id))
60. 0.017 0.367 ↓ 2.0 2 1

Hash (cost=8.54..8.54 rows=1 width=52) (actual time=0.367..0.367 rows=2 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
61. 0.014 0.350 ↓ 2.0 2 1

Subquery Scan on st (cost=8.46..8.54 rows=1 width=52) (actual time=0.325..0.350 rows=2 loops=1)

  • Filter: ((st.scheduled_start_date <= '2020-10-29'::date) AND (st.scheduled_end_date >= '2020-07-30'::date))
  • Rows Removed by Filter: 10
62. 0.058 0.336 ↓ 12.0 12 1

WindowAgg (cost=8.46..8.52 rows=1 width=64) (actual time=0.309..0.336 rows=12 loops=1)

63. 0.061 0.278 ↓ 12.0 12 1

Sort (cost=8.46..8.47 rows=1 width=622) (actual time=0.277..0.278 rows=12 loops=1)

  • Sort Key: ((st_1.details ->> 'unit_space_id'::text)), st_1.start_on
  • Sort Method: quicksort Memory: 26kB
64. 0.217 0.217 ↓ 12.0 12 1

Index Scan using ca_scheduled_tasks_idx on scheduled_tasks st_1 (cost=0.43..8.45 rows=1 width=622) (actual time=0.090..0.217 rows=12 loops=1)

  • Index Cond: ((cid = 235) AND (scheduled_task_type_id = 11) AND (property_id = 719,642))
  • Filter: ((deleted_by IS NULL) AND (deleted_on IS NULL))