explain.depesz.com

PostgreSQL's explain analyze made readable

Result: bKkT

Settings
# exclusive inclusive rows x rows loops node
1. 15.157 93,824.526 ↓ 1,807.0 1,807 1

Sort (cost=3,140.11..3,140.12 rows=1 width=1,140) (actual time=93,824.271..93,824.526 rows=1,807 loops=1)

  • Sort Key: l.property_name, (CASE WHEN (3 = l.lease_interval_type_id) THEN ((min(cal_inner.lease_approved_on)))::date WHEN (1 = l.lease_interval_type_id) THEN CASE WHEN ('12'::text = pp_applications.value) THEN (l.application_approved_on)::date WHEN ('18'::text = pp_applications.value) THEN ((min(cal_inner.lease_approved_on)))::date ELSE (LEAST(l.application_completed, e.event_datetime))::date 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 WHEN ('52'::text = pp_transfers.value) THEN (l.application_approved_on)::date ELSE ((min(cal_inner.lease_approved_on)))::date END ELSE NULL::date END) 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: 980kB
2. 69.573 93,809.369 ↓ 1,807.0 1,807 1

Nested Loop Left Join (cost=952.01..3,140.10 rows=1 width=1,140) (actual time=6,907.004..93,809.369 rows=1,807 loops=1)

  • Filter: CASE WHEN (3 = l.lease_interval_type_id) THEN ((((min(cal_inner.lease_approved_on)))::date >= '2018-01-01'::date) AND (((min(cal_inner.lease_approved_on)))::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 ((((min(cal_inner.lease_approved_on)))::date >= '2018-01-01'::date) AND (((min(cal_inner.lease_approved_on)))::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 ((((min(cal_inner.lease_approved_on)))::date >= '2018-01-01'::date) AND (((min(cal_inner.lease_approved_on)))::date < '2019-01-01 00:00:00'::timestamp without time zone)) END ELSE NULL::boolean END
  • Rows Removed by Filter: 2312
3. 12.331 93,706.844 ↓ 4,119.0 4,119 1

Nested Loop Left Join (cost=951.59..3,130.89 rows=1 width=1,097) (actual time=270.357..93,706.844 rows=4,119 loops=1)

4. 10.644 93,649.204 ↓ 4,119.0 4,119 1

Nested Loop Left Join (cost=951.17..3,122.46 rows=1 width=1,078) (actual time=270.286..93,649.204 rows=4,119 loops=1)

5. 12.233 93,609.727 ↓ 4,119.0 4,119 1

Nested Loop Left Join (cost=950.87..3,114.76 rows=1 width=1,078) (actual time=270.238..93,609.727 rows=4,119 loops=1)

6. 13.161 93,576.899 ↓ 4,119.0 4,119 1

Nested Loop Left Join (cost=950.59..3,110.80 rows=1 width=844) (actual time=270.182..93,576.899 rows=4,119 loops=1)

7. 9.740 93,543.143 ↓ 4,119.0 4,119 1

Nested Loop Left Join (cost=950.31..3,107.16 rows=1 width=839) (actual time=270.137..93,543.143 rows=4,119 loops=1)

8. 11.103 93,516.927 ↓ 4,119.0 4,119 1

Nested Loop Left Join (cost=950.18..3,106.82 rows=1 width=827) (actual time=270.102..93,516.927 rows=4,119 loops=1)

9. 10.926 85,667.367 ↓ 4,119.0 4,119 1

Nested Loop Left Join (cost=569.56..2,724.36 rows=1 width=693) (actual time=269.816..85,667.367 rows=4,119 loops=1)

10. 1,778.639 85,631.727 ↓ 4,119.0 4,119 1

Nested Loop (cost=569.27..2,716.53 rows=1 width=557) (actual time=269.754..85,631.727 rows=4,119 loops=1)

  • Join Filter: (cll.unit_space_id = past_recent_lease.unit_space_id)
  • Rows Removed by Join Filter: 8324899
11. 9.291 2,612.646 ↓ 2,459.0 4,918 1

Nested Loop Left Join (cost=104.09..1,525.13 rows=2 width=501) (actual time=1.086..2,612.646 rows=4,918 loops=1)

12. 11.442 2,559.093 ↓ 2,459.0 4,918 1

Nested Loop Left Join (cost=95.75..1,508.41 rows=2 width=493) (actual time=1.070..2,559.093 rows=4,918 loops=1)

13. 13.967 2,523.061 ↓ 4,918.0 4,918 1

Nested Loop Left Join (cost=95.47..1,508.10 rows=1 width=497) (actual time=1.058..2,523.061 rows=4,918 loops=1)

14. 10.790 2,464.832 ↓ 4,918.0 4,918 1

Nested Loop (cost=95.04..1,499.68 rows=1 width=477) (actual time=1.043..2,464.832 rows=4,918 loops=1)

15. 6.626 324.548 ↓ 4,918.0 4,918 1

Nested Loop (cost=1.13..1,405.74 rows=1 width=465) (actual time=0.364..324.548 rows=4,918 loops=1)

16. 11.197 288.414 ↓ 2,459.0 4,918 1

Nested Loop (cost=0.85..1,405.12 rows=2 width=471) (actual time=0.356..288.414 rows=4,918 loops=1)

  • Join Filter: (l.lease_id = cll.lease_id)
17. 12.897 75.579 ↓ 1,229.5 4,918 1

Nested Loop (cost=0.42..1,373.46 rows=4 width=426) (actual time=0.300..75.579 rows=4,918 loops=1)

18. 12.052 12.052 ↓ 56.3 5,063 1

Seq Scan on leads l (cost=0.00..621.41 rows=90 width=414) (actual time=0.277..12.052 rows=5,063 loops=1)

  • Filter: ((unit_number_cache IS NOT NULL) AND (post_date >= '2018-01-01'::date) AND (cid = 2101) AND (lease_interval_type_id = ANY ('{1,5,3}'::integer[])))
  • Rows Removed by Filter: 12932
19. 50.630 50.630 ↑ 1.0 1 5,063

Index Scan using pk_cached_leases on cached_leases cl (cost=0.42..8.36 rows=1 width=16) (actual time=0.010..0.010 rows=1 loops=5,063)

  • Index Cond: ((cid = 2101) AND (id = l.lease_id))
  • Filter: (lease_status_type_id <> 2)
  • Rows Removed by Filter: 0
20. 201.638 201.638 ↑ 1.0 1 4,918

Index Scan using idx_cached_lease_logs_cid_lease_id_log_datetime_date on cached_lease_logs cll (cost=0.43..7.90 rows=1 width=53) (actual time=0.041..0.041 rows=1 loops=4,918)

  • Index Cond: ((cid = 2101) AND (lease_id = cl.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: 19
21. 29.508 29.508 ↑ 1.0 1 4,918

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.006 rows=1 loops=4,918)

  • Index Cond: (property_id = cll.property_id)
  • Filter: (cid = 2101)
22. 791.798 2,129.494 ↑ 1.0 1 4,918

Aggregate (cost=93.91..93.92 rows=1 width=80) (actual time=0.433..0.433 rows=1 loops=4,918)

23. 1,337.696 1,337.696 ↓ 90.0 90 4,918

Index Scan using idx_cached_application_logs_cid_app_opening_log on cached_application_logs cal_inner (cost=0.56..93.91 rows=1 width=16) (actual time=0.018..0.272 rows=90 loops=4,918)

  • Index Cond: ((cid = 2101) AND (application_id = l.application_id))
  • Filter: ((post_date <= '2018-12-31'::date) AND (property_id = l.property_id))
  • Rows Removed by Filter: 11
24. 44.262 44.262 ↑ 1.0 1 4,918

Index Scan using idx_lease_intervals on lease_intervals li (cost=0.43..8.41 rows=1 width=24) (actual time=0.009..0.009 rows=1 loops=4,918)

  • Index Cond: (id = l.lease_interval_id)
  • Filter: ((cid = 2101) AND (cid = l.cid) AND (lease_id = l.lease_id))
  • Rows Removed by Filter: 0
25. 24.590 24.590 ↑ 1.0 1 4,918

Index Scan using pk_lease_terms on lease_terms lt (cost=0.29..0.31 rows=1 width=12) (actual time=0.005..0.005 rows=1 loops=4,918)

  • Index Cond: ((cid = li.cid) AND (cid = 2101) AND (id = li.lease_term_id))
26. 4.918 44.262 ↓ 0.0 0 4,918

Limit (cost=8.33..8.34 rows=1 width=8) (actual time=0.009..0.009 rows=0 loops=4,918)

27. 19.672 39.344 ↓ 0.0 0 4,918

Sort (cost=8.33..8.34 rows=1 width=8) (actual time=0.008..0.008 rows=0 loops=4,918)

  • Sort Key: e.event_datetime
  • Sort Method: quicksort Memory: 25kB
28. 19.672 19.672 ↓ 0.0 0 4,918

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=4,918)

  • Index Cond: (lease_interval_id = l.lease_interval_id)
  • Filter: ((cid = 2101) 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
29. 8,134.372 81,240.442 ↓ 105.9 1,694 4,918

Subquery Scan on past_recent_lease (cost=465.18..595.50 rows=16 width=68) (actual time=7.848..16.519 rows=1,694 loops=4,918)

  • Filter: ((past_recent_lease.lease_id IS NOT NULL) AND (past_recent_lease.cid = 2101) AND (past_recent_lease.prior_lease_row_num = 1))
  • Rows Removed by Filter: 4573
30. 30,044.062 73,106.070 ↓ 1.9 6,267 4,918

WindowAgg (cost=465.18..546.63 rows=3,258 width=80) (actual time=7.847..14.865 rows=6,267 loops=4,918)

31. 24,614.590 43,062.008 ↓ 1.9 6,267 4,918

Sort (cost=465.18..473.33 rows=3,258 width=72) (actual time=7.843..8.756 rows=6,267 loops=4,918)

  • 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: 1076kB
32. 18,447.418 18,447.418 ↓ 1.9 6,267 4,918

Seq Scan on available_cached_leases cl_1 (cost=0.00..275.08 rows=3,258 width=72) (actual time=0.062..3.751 rows=6,267 loops=4,918)

  • Filter: ((lease_interval_id <> l.lease_interval_id) AND (lease_start_date < li.lease_start_date) AND (cid = 2101))
  • Rows Removed by Filter: 3509
33. 24.714 24.714 ↑ 1.0 1 4,119

Index Scan using idx_temp_cached_leases_scheduled_charges_lease_interval_id on cached_leases_scheduled_charges lsc (cost=0.29..7.81 rows=1 width=156) (actual time=0.005..0.006 rows=1 loops=4,119)

  • Index Cond: (lease_interval_id = past_recent_lease.lease_interval_id)
  • Filter: ((cid = 2101) AND (cid = past_recent_lease.cid) AND (lease_id = past_recent_lease.lease_id))
34. 288.330 7,838.457 ↑ 1.0 1 4,119

GroupAggregate (cost=380.62..382.45 rows=1 width=176) (actual time=1.903..1.903 rows=1 loops=4,119)

  • Group Key: sc.one_time_concession
35. 32.952 7,550.127 ↓ 5.0 5 4,119

Sort (cost=380.62..380.63 rows=1 width=73) (actual time=1.832..1.833 rows=5 loops=4,119)

  • Sort Key: sc.one_time_concession
  • Sort Method: quicksort Memory: 25kB
36. 12.357 7,517.175 ↓ 5.0 5 4,119

Subquery Scan on sc (cost=380.57..380.61 rows=1 width=73) (actual time=1.814..1.825 rows=5 loops=4,119)

37. 45.309 7,504.818 ↓ 5.0 5 4,119

WindowAgg (cost=380.57..380.60 rows=1 width=121) (actual time=1.813..1.822 rows=5 loops=4,119)

38. 45.309 7,459.509 ↓ 5.0 5 4,119

Sort (cost=380.57..380.57 rows=1 width=81) (actual time=1.810..1.811 rows=5 loops=4,119)

  • 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
39. 24.714 7,414.200 ↓ 5.0 5 4,119

Group (cost=380.52..380.56 rows=1 width=81) (actual time=1.795..1.800 rows=5 loops=4,119)

  • 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, (sum(ar.transaction_amount))
40. 65.904 7,389.486 ↓ 6.0 6 4,119

Sort (cost=380.52..380.52 rows=1 width=81) (actual time=1.793..1.794 rows=6 loops=4,119)

  • 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, (sum(ar.transaction_amount))
  • Sort Method: quicksort Memory: 25kB
41. 37.032 7,323.582 ↓ 6.0 6 4,119

Nested Loop Left Join (cost=9.88..380.51 rows=1 width=81) (actual time=0.488..1.778 rows=6 loops=4,119)

42. 135.927 263.616 ↓ 6.0 6 4,119

Bitmap Heap Scan on scheduled_charges sc_charges (cost=9.45..13.47 rows=1 width=49) (actual time=0.048..0.064 rows=6 loops=4,119)

  • Recheck Cond: ((cid = 2101) 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: 9
  • Heap Blocks: exact=24705
43. 12.368 127.689 ↓ 0.0 0 4,119

BitmapAnd (cost=9.45..9.45 rows=1 width=0) (actual time=0.031..0.031 rows=0 loops=4,119)

44. 70.023 70.023 ↓ 6.6 46 4,119

Bitmap Index Scan on idx_scheduled_charges_remote_primary_key (cost=0.00..4.50 rows=7 width=0) (actual time=0.017..0.017 rows=46 loops=4,119)

  • Index Cond: ((cid = 2101) AND (lease_id = l.lease_id))
45. 45.298 45.298 ↑ 2.4 15 4,118

Bitmap Index Scan on idx_scheduled_charges_lease_interval_id (cost=0.00..4.70 rows=36 width=0) (actual time=0.011..0.011 rows=15 loops=4,118)

  • Index Cond: (lease_interval_id = li.id)
46. 92.712 7,022.934 ↓ 0.0 0 23,178

GroupAggregate (cost=0.43..367.02 rows=1 width=44) (actual time=0.303..0.303 rows=0 loops=23,178)

  • Group Key: ar.cid, ar.lease_id, ar.lease_interval_id
47. 6,930.222 6,930.222 ↓ 7.0 7 23,178

Index Scan using idx_ar_transactions_lease_id on ar_transactions ar (cost=0.43..367.00 rows=1 width=17) (actual time=0.253..0.299 rows=7 loops=23,178)

  • Index Cond: (lease_id = l.lease_id)
  • Filter: ((scheduled_charge_id IS NULL) AND (NOT is_deleted) AND (NOT is_reversal) AND (transaction_amount < '0'::numeric) AND (cid = 2101) AND (lease_interval_id = li.id) AND (ar_trigger_id = ANY ('{201,202,204,205,206,207,208,209,210,211,212}'::integer[])) AND (ar_code_id = ANY ('{32842,82624,134674,36389,82664,82665,147329,146927,82673,143082,90355,144257,82591,36335,104346,82592,146792,143046,32854,194090,36019,83967,143033,82593,82594,82595,32843,83647,83646,194509,129449,82596,82597,82598,82599,144258,144259,82600,82601,82602,82603,82605,137217,82606,135698,147337,143049,82607,63238,82608,63211,82609,63216,82610,147558,82611,143047,143072,82642,147305,82612,143048,82613,82614,82615,82616,82617,63242,63214,194083,147307,63231,82618,143045,147301,136176,63210,82619,147299,194086,147308,82620,82604,147412,93862,147310,194088,147302,143059,143044,82621,82622,194089,115852,147309,194087,143073,82623,143087,143051,147304,82625,82626,86151,135555,82627,82628,143055,82629,143056,82630,146445,82631,82632,82634,143058,127404,82635,147485,193888,138813,143060,137252,82636,82637,143063,82638,143064,143031,205564,143043,205565,127554,143065,141458,141459,143042,93863,194022,143066,82639,82640,143067,143068,134786,143080,143035,144849,82641,194084,63251,111259,143069,147559,82643,32850,143041,82644,143070,82645,147326,82646,143036,147300,143077,143078,82647,82648,82649,143074,82650,82651,82652,82653,82654,82655,82656,82657,82658,82659,143053,143037,146449,146450,146843,82660,146451,146452,146454,82661,143038,143081,147483,143054,147311,63232,79913,147306,82662,82663,82666,82667,82668,109071,146427,147328,143086,147334,118513,118514,205913,36029,194091,194085,82670,143085,82671,143039,143083,143084,82672,90356,105248,147303,86152,143088,143089,143090,82674,82675,147324,147314,147321,147323,147344,143052,147345,143057,147312,147313,194530,147342,147341,147322,147317,147319,147316,147318,147315,143079,147320,194094,194096,194097,194098,194095,147325,147343,147340,194151,147338,147339,194508,194507,147288,147284,194531,205572,205828,147290,147287,147293,147292,194514,194150,147289,147285,147291,205569,147286,205686,147283,205617,145870,147298,32844,147330,193782,127555,147295,82676,147294,82677,32845,32855,194438,194379,82633,147296,145871,141718,147297,194513,141721,82669,145873,145874,145872}'::integer[])))
  • Rows Removed by Filter: 220
48. 16.476 16.476 ↑ 1.0 1 4,119

Index Scan using pk_lease_interval_types on lease_interval_types lit (cost=0.13..0.28 rows=1 width=16) (actual time=0.004..0.004 rows=1 loops=4,119)

  • Index Cond: (id = l.lease_interval_type_id)
49. 20.595 20.595 ↑ 1.0 1 4,119

Index Scan using idx_property_floorplans on property_floorplans pf (cost=0.28..3.64 rows=1 width=17) (actual time=0.005..0.005 rows=1 loops=4,119)

  • Index Cond: (id = l.property_floorplan_id)
  • Filter: ((cid = 2101) AND (cid = l.cid))
50. 20.595 20.595 ↑ 1.0 1 4,119

Index Scan using idx_unit_types_id on unit_types ut (cost=0.28..3.95 rows=1 width=246) (actual time=0.005..0.005 rows=1 loops=4,119)

  • Index Cond: (id = l.unit_type_id)
  • Filter: ((cid = 2101) AND (cid = l.cid))
51. 28.833 28.833 ↑ 1.0 1 4,119

Index Scan using pk_property_units on property_units pu (cost=0.29..7.69 rows=1 width=12) (actual time=0.007..0.007 rows=1 loops=4,119)

  • Index Cond: ((cid = l.cid) AND (cid = 2101) AND (id = l.property_unit_id))
52. 45.309 45.309 ↑ 1.0 1 4,119

Index Scan using uk_property_preferences_cid_property_id_key on property_preferences pp_applications (cost=0.42..8.27 rows=1 width=27) (actual time=0.011..0.011 rows=1 loops=4,119)

  • Index Cond: ((cid = l.cid) AND (cid = 2101) AND (property_id = l.property_id) AND ((key)::text = 'CHANGE_UNIT_STATUS_TO_RENTED'::text))
53. 32.952 32.952 ↑ 1.0 1 4,119

Index Scan using uk_property_preferences_cid_property_id_key on property_preferences pp_transfers (cost=0.42..8.27 rows=1 width=27) (actual time=0.008..0.008 rows=1 loops=4,119)

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