explain.depesz.com

PostgreSQL's explain analyze made readable

Result: aS6B

Settings
# exclusive inclusive rows x rows loops node
1. 9.219 17,422.771 ↓ 1,223.0 1,223 1

Sort (cost=1,302.10..1,302.11 rows=1 width=1,140) (actual time=17,422.600..17,422.771 rows=1,223 loops=1)

  • Sort Key: l.property_name, xmax.considered_rented_on DESC, (CASE WHEN (l.lease_interval_type_id = 1) THEN 1 WHEN (l.lease_interval_type_id = 5) THEN 2 WHEN (l.lease_interval_type_id = 3) THEN 3 ELSE NULL::integer END)
  • Sort Method: quicksort Memory: 679kB
2. 33.549 17,413.552 ↓ 1,223.0 1,223 1

Nested Loop Left Join (cost=382.55..1,302.09 rows=1 width=1,140) (actual time=210.699..17,413.552 rows=1,223 loops=1)

  • Filter: CASE WHEN (3 = l.lease_interval_type_id) THEN (((cal_max.lease_approved)::date >= '2018-01-01'::date) AND ((cal_max.lease_approved)::date < '2019-01-01 00:00:00'::timestamp without time zone)) WHEN (1 = l.lease_interval_type_id) THEN CASE WHEN ('12'::text = pp_applications.value) THEN (((l.application_approved_on)::date >= '2018-01-01'::date) AND ((l.application_approved_on)::date < '2019-01-01 00:00:00'::timestamp without time zone)) WHEN ('18'::text = pp_applications.value) THEN (((cal_max.lease_approved)::date >= '2018-01-01'::date) AND ((cal_max.lease_approved)::date < '2019-01-01 00:00:00'::timestamp without time zone)) ELSE (((LEAST(l.application_completed, e.event_datetime))::date >= '2018-01-01'::date) AND ((LEAST(l.application_completed, e.event_datetime))::date < '2019-01-01 00:00:00'::timestamp without time zone)) END WHEN (5 = l.lease_interval_type_id) THEN CASE WHEN ('51'::text = pp_transfers.value) THEN (((LEAST(l.application_completed, e.event_datetime))::date >= '2018-01-01'::date) AND ((LEAST(l.application_completed, e.event_datetime))::date < '2019-01-01 00:00:00'::timestamp without time zone)) WHEN ('52'::text = pp_transfers.value) THEN (((l.application_approved_on)::date >= '2018-01-01'::date) AND ((l.application_approved_on)::date < '2019-01-01 00:00:00'::timestamp without time zone)) ELSE (((cal_max.lease_approved)::date >= '2018-01-01'::date) AND ((cal_max.lease_approved)::date < '2019-01-01 00:00:00'::timestamp without time zone)) END ELSE NULL::boolean END
  • Rows Removed by Filter: 770
3. 5.017 17,366.052 ↓ 1,993.0 1,993 1

Nested Loop Left Join (cost=382.13..1,292.74 rows=1 width=1,101) (actual time=23.726..17,366.052 rows=1,993 loops=1)

4. 4.856 17,343.098 ↓ 1,993.0 1,993 1

Nested Loop Left Join (cost=381.71..1,284.07 rows=1 width=1,082) (actual time=23.704..17,343.098 rows=1,993 loops=1)

5. 4.235 17,328.277 ↓ 1,993.0 1,993 1

Nested Loop Left Join (cost=381.42..1,276.02 rows=1 width=1,082) (actual time=23.691..17,328.277 rows=1,993 loops=1)

6. 5.034 17,316.070 ↓ 1,993.0 1,993 1

Nested Loop Left Join (cost=381.14..1,270.80 rows=1 width=848) (actual time=23.675..17,316.070 rows=1,993 loops=1)

7. 4.592 17,303.064 ↓ 1,993.0 1,993 1

Nested Loop Left Join (cost=380.86..1,266.03 rows=1 width=843) (actual time=23.663..17,303.064 rows=1,993 loops=1)

8. 5.017 17,292.493 ↓ 1,993.0 1,993 1

Nested Loop Left Join (cost=380.73..1,265.51 rows=1 width=831) (actual time=23.654..17,292.493 rows=1,993 loops=1)

9. 3.026 16,900.834 ↓ 1,993.0 1,993 1

Nested Loop Left Join (cost=365.45..1,249.17 rows=1 width=697) (actual time=23.436..16,900.834 rows=1,993 loops=1)

10. 2.563 16,887.843 ↓ 1,993.0 1,993 1

Nested Loop Left Join (cost=365.17..1,240.85 rows=1 width=561) (actual time=23.421..16,887.843 rows=1,993 loops=1)

11. 610.678 16,869.336 ↓ 1,993.0 1,993 1

Nested Loop (cost=356.83..1,232.49 rows=1 width=557) (actual time=23.406..16,869.336 rows=1,993 loops=1)

  • Join Filter: (cll.unit_space_id = past_recent_lease.unit_space_id)
  • Rows Removed by Join Filter: 2881658
12. 4.496 164.294 ↓ 719.3 2,158 1

Nested Loop Left Join (cost=165.40..490.17 rows=3 width=497) (actual time=6.123..164.294 rows=2,158 loops=1)

13. 3.845 151.166 ↓ 2,158.0 2,158 1

Nested Loop Left Join (cost=165.12..489.85 rows=1 width=501) (actual time=6.110..151.166 rows=2,158 loops=1)

14. 4.184 130.057 ↓ 2,158.0 2,158 1

Nested Loop (cost=164.69..481.39 rows=1 width=481) (actual time=6.095..130.057 rows=2,158 loops=1)

15. 4.422 115.083 ↓ 2,158.0 2,158 1

Nested Loop (cost=164.40..474.07 rows=1 width=477) (actual time=6.061..115.083 rows=2,158 loops=1)

16. 4.137 95.450 ↓ 2,173.0 2,173 1

Nested Loop (cost=163.98..471.81 rows=1 width=477) (actual time=6.045..95.450 rows=2,173 loops=1)

17. 3.370 82.621 ↓ 2,173.0 2,173 1

Nested Loop (cost=163.70..471.50 rows=1 width=483) (actual time=6.034..82.621 rows=2,173 loops=1)

18. 4.104 14.061 ↓ 2,173.0 2,173 1

Hash Join (cost=163.27..463.02 rows=1 width=430) (actual time=5.977..14.061 rows=2,173 loops=1)

  • Hash Cond: ((l.lease_id = xmax.lease_id) AND (l.property_id = xmax.property_id) AND (l.application_id = xmax.application_id))
19. 4.366 4.366 ↓ 49.6 2,181 1

Seq Scan on leads l (cost=0.00..298.75 rows=44 width=414) (actual time=0.373..4.366 rows=2,181 loops=1)

  • Filter: ((unit_number_cache IS NOT NULL) AND (post_date >= '2018-01-01'::date) AND (cid = 8132) AND (lease_interval_type_id = ANY ('{1,5,3}'::integer[])))
  • Rows Removed by Filter: 6659
20. 2.549 5.591 ↓ 112.2 4,935 1

Hash (cost=162.50..162.50 rows=44 width=20) (actual time=5.591..5.591 rows=4,935 loops=1)

  • Buckets: 8192 (originally 1024) Batches: 1 (originally 1) Memory Usage: 311kB
21. 3.042 3.042 ↓ 200.9 8,840 1

Seq Scan on xyz xmax (cost=0.00..162.50 rows=44 width=20) (actual time=0.018..3.042 rows=8,840 loops=1)

  • Filter: (cid = 8132)
22. 65.190 65.190 ↑ 1.0 1 2,173

Index Scan using idx_cached_lease_logs_cid_lease_id_log_datetime_date on cached_lease_logs cll (cost=0.43..8.47 rows=1 width=53) (actual time=0.029..0.030 rows=1 loops=2,173)

  • Index Cond: ((cid = 8132) AND (lease_id = l.lease_id) AND (reporting_post_date < '2019-01-01 00:00:00'::timestamp without time zone))
  • Filter: ((apply_through_post_date >= '2018-12-31'::date) AND (is_post_date_ignored = 0))
  • Rows Removed by Filter: 13
23. 8.692 8.692 ↑ 1.0 1 2,173

Index Scan using idx_property_charge_settings_property_id on property_charge_settings pcs (cost=0.28..0.30 rows=1 width=10) (actual time=0.004..0.004 rows=1 loops=2,173)

  • Index Cond: (property_id = cll.property_id)
  • Filter: (cid = 8132)
24. 15.211 15.211 ↑ 1.0 1 2,173

Index Scan using pk_cached_leases on cached_leases cl (cost=0.42..2.25 rows=1 width=16) (actual time=0.007..0.007 rows=1 loops=2,173)

  • Index Cond: ((cid = 8132) AND (id = cll.lease_id))
  • Filter: (lease_status_type_id <> 2)
  • Rows Removed by Filter: 0
25. 10.790 10.790 ↑ 1.0 1 2,158

Index Scan using idx_temp_min_max_leads_application_id on min_max_leads cal_max (cost=0.29..7.31 rows=1 width=28) (actual time=0.005..0.005 rows=1 loops=2,158)

  • Index Cond: (application_id = xmax.application_id)
  • Filter: ((cid = 8132) AND (xmax.property_id = property_id))
26. 17.264 17.264 ↑ 1.0 1 2,158

Index Scan using idx_lease_intervals on lease_intervals li (cost=0.43..8.45 rows=1 width=24) (actual time=0.008..0.008 rows=1 loops=2,158)

  • Index Cond: (id = l.lease_interval_id)
  • Filter: ((cid = 8132) AND (cid = l.cid) AND (lease_id = l.lease_id))
  • Rows Removed by Filter: 0
27. 8.632 8.632 ↑ 1.0 1 2,158

Index Scan using pk_lease_terms on lease_terms lt (cost=0.29..0.32 rows=1 width=12) (actual time=0.004..0.004 rows=1 loops=2,158)

  • Index Cond: ((cid = li.cid) AND (cid = 8132) AND (id = li.lease_term_id))
28. 1,691.872 16,094.364 ↓ 190.9 1,336 2,158

Subquery Scan on past_recent_lease (cost=191.43..247.35 rows=7 width=68) (actual time=3.333..7.458 rows=1,336 loops=2,158)

  • Filter: ((past_recent_lease.lease_id IS NOT NULL) AND (past_recent_lease.cid = 8132) AND (past_recent_lease.prior_lease_row_num = 1))
  • Rows Removed by Filter: 1434
29. 6,361.784 14,402.492 ↓ 2.0 2,771 2,158

WindowAgg (cost=191.43..226.38 rows=1,398 width=80) (actual time=3.332..6.674 rows=2,771 loops=2,158)

30. 4,523.168 8,040.708 ↓ 2.0 2,771 2,158

Sort (cost=191.43..194.93 rows=1,398 width=72) (actual time=3.329..3.726 rows=2,771 loops=2,158)

  • Sort Key: cl_1.unit_space_id, (CASE WHEN (cl_1.move_out_date IS NOT NULL) THEN cl_1.move_out_date ELSE NULL::date END) DESC, cl_1.lease_end_date DESC
  • Sort Method: quicksort Memory: 499kB
31. 3,517.540 3,517.540 ↓ 2.0 2,771 2,158

Seq Scan on available_cached_leases cl_1 (cost=0.00..118.40 rows=1,398 width=72) (actual time=0.005..1.630 rows=2,771 loops=2,158)

  • Filter: ((lease_interval_id <> l.lease_interval_id) AND (lease_start_date < li.lease_start_date) AND (cid = 8132))
  • Rows Removed by Filter: 1423
32. 1.993 15.944 ↓ 0.0 0 1,993

Limit (cost=8.33..8.34 rows=1 width=8) (actual time=0.008..0.008 rows=0 loops=1,993)

33. 5.979 13.951 ↓ 0.0 0 1,993

Sort (cost=8.33..8.34 rows=1 width=8) (actual time=0.007..0.007 rows=0 loops=1,993)

  • Sort Key: e.event_datetime
  • Sort Method: quicksort Memory: 25kB
34. 7.972 7.972 ↓ 0.0 0 1,993

Index Scan using idx_events_lease_interval_id_status_change on events e (cost=0.29..8.32 rows=1 width=8) (actual time=0.004..0.004 rows=0 loops=1,993)

  • Index Cond: (lease_interval_id = l.lease_interval_id)
  • Filter: ((cid = 8132) AND (new_stage_id = 3) AND (new_status_id = 2) AND (((new_stage_id = 3) AND (old_stage_id < 3)) OR ((new_status_id = 2) AND (old_status_id < 2))))
  • Rows Removed by Filter: 0
35. 9.965 9.965 ↑ 1.0 1 1,993

Index Scan using idx_temp_cached_leases_scheduled_charges_lease_interval_id on cached_leases_scheduled_charges lsc (cost=0.29..8.31 rows=1 width=156) (actual time=0.004..0.005 rows=1 loops=1,993)

  • Index Cond: (lease_interval_id = past_recent_lease.lease_interval_id)
  • Filter: ((cid = 8132) AND (cid = past_recent_lease.cid) AND (lease_id = past_recent_lease.lease_id))
36. 89.685 386.642 ↑ 1.0 1 1,993

GroupAggregate (cost=15.27..16.32 rows=1 width=176) (actual time=0.194..0.194 rows=1 loops=1,993)

  • Group Key: sc.one_time_concession
37. 11.958 296.957 ↓ 4.0 4 1,993

Sort (cost=15.27..15.28 rows=1 width=73) (actual time=0.148..0.149 rows=4 loops=1,993)

  • Sort Key: sc.one_time_concession
  • Sort Method: quicksort Memory: 25kB
38. 3.986 284.999 ↓ 4.0 4 1,993

Subquery Scan on sc (cost=15.22..15.26 rows=1 width=73) (actual time=0.135..0.143 rows=4 loops=1,993)

39. 17.937 281.013 ↓ 4.0 4 1,993

WindowAgg (cost=15.22..15.25 rows=1 width=121) (actual time=0.134..0.141 rows=4 loops=1,993)

40. 17.937 263.076 ↓ 4.0 4 1,993

Sort (cost=15.22..15.22 rows=1 width=81) (actual time=0.132..0.132 rows=4 loops=1,993)

  • Sort Key: sc_charges.property_id, sc_charges.ar_origin_id, sc_charges.ar_code_type_id, sc_charges.charge_end_date DESC
  • Sort Method: quicksort Memory: 25kB
41. 9.965 245.139 ↓ 4.0 4 1,993

Group (cost=15.17..15.21 rows=1 width=81) (actual time=0.119..0.123 rows=4 loops=1,993)

  • Group Key: sc_charges.cid, sc_charges.lease_id, sc_charges.lease_interval_id, sc_charges.property_id, sc_charges.charge_amount, sc_charges.ar_origin_id, sc_charges.ar_code_type_id, sc_charges.scheduled_charge_type_id, sc_charges.charge_start_date, sc_charges.charge_end_date, sc_charges.ar_trigger_id, sc_charges.ar_code_id, current_manual_concession.one_time_concession
42. 25.909 235.174 ↓ 5.0 5 1,993

Sort (cost=15.17..15.17 rows=1 width=81) (actual time=0.118..0.118 rows=5 loops=1,993)

  • Sort Key: sc_charges.property_id, sc_charges.charge_amount, sc_charges.ar_origin_id, sc_charges.ar_code_type_id, sc_charges.scheduled_charge_type_id, sc_charges.charge_start_date, sc_charges.charge_end_date, sc_charges.ar_trigger_id, sc_charges.ar_code_id, current_manual_concession.one_time_concession
  • Sort Method: quicksort Memory: 25kB
43. 29.171 209.265 ↓ 5.0 5 1,993

Nested Loop Left Join (cost=9.43..15.16 rows=1 width=81) (actual time=0.058..0.105 rows=5 loops=1,993)

44. 59.790 113.601 ↓ 5.0 5 1,993

Bitmap Heap Scan on scheduled_charges sc_charges (cost=9.43..13.45 rows=1 width=49) (actual time=0.046..0.057 rows=5 loops=1,993)

  • Recheck Cond: ((cid = 8132) AND (lease_id = l.lease_id) AND (lease_interval_id = li.id))
  • Filter: ((NOT is_unselected_quote) AND (deleted_on IS NULL) AND (deleted_by IS NULL))
  • Rows Removed by Filter: 10
  • Heap Blocks: exact=13297
45. 5.979 53.811 ↓ 0.0 0 1,993

BitmapAnd (cost=9.43..9.43 rows=1 width=0) (actual time=0.027..0.027 rows=0 loops=1,993)

46. 29.895 29.895 ↓ 10.2 51 1,993

Bitmap Index Scan on idx_scheduled_charges_remote_primary_key (cost=0.00..4.48 rows=5 width=0) (actual time=0.015..0.015 rows=51 loops=1,993)

  • Index Cond: ((cid = 8132) AND (lease_id = l.lease_id))
47. 17.937 17.937 ↑ 2.4 15 1,993

Bitmap Index Scan on idx_scheduled_charges_lease_interval_id (cost=0.00..4.70 rows=36 width=0) (actual time=0.009..0.009 rows=15 loops=1,993)

  • Index Cond: (lease_interval_id = li.id)
48. 66.493 66.493 ↓ 0.0 0 9,499

Seq Scan on ar_transaction_concessions current_manual_concession (cost=0.00..1.70 rows=1 width=32) (actual time=0.007..0.007 rows=0 loops=9,499)

  • Filter: ((cid = l.cid) AND (lease_id = l.lease_id) AND (lease_interval_id = li.id))
  • Rows Removed by Filter: 40
49. 5.979 5.979 ↑ 1.0 1 1,993

Index Scan using pk_lease_interval_types on lease_interval_types lit (cost=0.13..0.42 rows=1 width=16) (actual time=0.003..0.003 rows=1 loops=1,993)

  • Index Cond: (id = l.lease_interval_type_id)
50. 7.972 7.972 ↑ 1.0 1 1,993

Index Scan using idx_property_floorplans on property_floorplans pf (cost=0.28..4.76 rows=1 width=17) (actual time=0.004..0.004 rows=1 loops=1,993)

  • Index Cond: (id = l.property_floorplan_id)
  • Filter: ((cid = 8132) AND (cid = l.cid))
51. 7.972 7.972 ↑ 1.0 1 1,993

Index Scan using idx_unit_types_id on unit_types ut (cost=0.28..5.21 rows=1 width=246) (actual time=0.004..0.004 rows=1 loops=1,993)

  • Index Cond: (id = l.unit_type_id)
  • Filter: ((cid = 8132) AND (cid = l.cid))
52. 9.965 9.965 ↑ 1.0 1 1,993

Index Scan using pk_property_units on property_units pu (cost=0.29..8.04 rows=1 width=12) (actual time=0.005..0.005 rows=1 loops=1,993)

  • Index Cond: ((cid = l.cid) AND (cid = 8132) AND (id = l.property_unit_id))
53. 17.937 17.937 ↑ 1.0 1 1,993

Index Scan using uk_property_preferences_cid_property_id_key on property_preferences pp_applications (cost=0.42..8.45 rows=1 width=27) (actual time=0.009..0.009 rows=1 loops=1,993)

  • Index Cond: ((cid = l.cid) AND (cid = 8132) AND (property_id = l.property_id) AND ((key)::text = 'CHANGE_UNIT_STATUS_TO_RENTED'::text))
54. 13.951 13.951 ↑ 1.0 1 1,993

Index Scan using uk_property_preferences_cid_property_id_key on property_preferences pp_transfers (cost=0.42..8.45 rows=1 width=27) (actual time=0.007..0.007 rows=1 loops=1,993)

  • Index Cond: ((cid = l.cid) AND (cid = 8132) AND (property_id = l.property_id) AND ((key)::text = 'TRANSFER_CHANGE_UNIT_STATUS_TO_RENTED'::text))
Planning time : 29.318 ms