explain.depesz.com

PostgreSQL's explain analyze made readable

Result: Kl6P

Settings
# exclusive inclusive rows x rows loops node
1. 7.174 23,963.414 ↓ 974.0 974 1

Sort (cost=1,753.89..1,753.90 rows=1 width=1,140) (actual time=23,963.282..23,963.414 rows=974 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: 527kB
2. 34.823 23,956.240 ↓ 974.0 974 1

Nested Loop Left Join (cost=710.59..1,753.88 rows=1 width=1,140) (actual time=764.265..23,956.240 rows=974 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: 1053
3. 4.789 23,907.228 ↓ 2,027.0 2,027 1

Nested Loop Left Join (cost=710.17..1,744.49 rows=1 width=1,097) (actual time=11.168..23,907.228 rows=2,027 loops=1)

4. 6.774 23,880.142 ↓ 2,027.0 2,027 1

Nested Loop Left Join (cost=709.75..1,735.87 rows=1 width=1,078) (actual time=11.144..23,880.142 rows=2,027 loops=1)

5. 5.367 23,861.206 ↓ 2,027.0 2,027 1

Nested Loop Left Join (cost=709.45..1,727.76 rows=1 width=1,078) (actual time=11.130..23,861.206 rows=2,027 loops=1)

6. 5.868 23,845.704 ↓ 2,027.0 2,027 1

Nested Loop Left Join (cost=709.17..1,722.32 rows=1 width=844) (actual time=11.111..23,845.704 rows=2,027 loops=1)

7. 6.624 23,829.701 ↓ 2,027.0 2,027 1

Nested Loop Left Join (cost=708.89..1,717.29 rows=1 width=839) (actual time=11.099..23,829.701 rows=2,027 loops=1)

8. 6.046 23,816.996 ↓ 2,027.0 2,027 1

Nested Loop Left Join (cost=708.76..1,716.72 rows=1 width=827) (actual time=11.089..23,816.996 rows=2,027 loops=1)

9. 5.603 20,322.483 ↓ 2,027.0 2,027 1

Nested Loop Left Join (cost=328.14..1,334.25 rows=1 width=693) (actual time=10.119..20,322.483 rows=2,027 loops=1)

10. 387.353 20,306.745 ↓ 2,027.0 2,027 1

Nested Loop (cost=327.86..1,326.44 rows=1 width=557) (actual time=10.101..20,306.745 rows=2,027 loops=1)

  • Join Filter: (cll.unit_space_id = past_recent_lease.unit_space_id)
  • Rows Removed by Join Filter: 1769595
11. 3.495 1,166.112 ↓ 1,046.5 2,093 1

Nested Loop Left Join (cost=104.09..748.86 rows=2 width=501) (actual time=1.160..1,166.112 rows=2,093 loops=1)

12. 4.443 1,143.780 ↓ 1,046.5 2,093 1

Nested Loop Left Join (cost=95.75..732.14 rows=2 width=493) (actual time=1.133..1,143.780 rows=2,093 loops=1)

13. 5.493 1,128.872 ↓ 2,093.0 2,093 1

Nested Loop Left Join (cost=95.47..731.83 rows=1 width=497) (actual time=1.121..1,128.872 rows=2,093 loops=1)

14. 4.680 1,104.542 ↓ 2,093.0 2,093 1

Nested Loop (cost=95.04..723.37 rows=1 width=477) (actual time=1.107..1,104.542 rows=2,093 loops=1)

15. 4.405 122.431 ↓ 2,093.0 2,093 1

Nested Loop (cost=1.13..629.42 rows=1 width=465) (actual time=0.855..122.431 rows=2,093 loops=1)

16. 4.239 107.561 ↓ 2,093.0 2,093 1

Nested Loop (cost=0.85..629.11 rows=1 width=471) (actual time=0.846..107.561 rows=2,093 loops=1)

  • Join Filter: (l.lease_id = cll.lease_id)
17. 6.359 30.067 ↓ 697.7 2,093 1

Nested Loop (cost=0.42..605.37 rows=3 width=426) (actual time=0.810..30.067 rows=2,093 loops=1)

18. 4.529 4.529 ↓ 54.6 2,131 1

Seq Scan on leads l (cost=0.00..276.01 rows=39 width=414) (actual time=0.790..4.529 rows=2,131 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: 5763
19. 19.179 19.179 ↑ 1.0 1 2,131

Index Scan using pk_cached_leases on cached_leases cl (cost=0.42..8.44 rows=1 width=16) (actual time=0.009..0.009 rows=1 loops=2,131)

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

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.034..0.035 rows=1 loops=2,093)

  • 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: 15
21. 10.465 10.465 ↑ 1.0 1 2,093

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.005 rows=1 loops=2,093)

  • Index Cond: (property_id = cll.property_id)
  • Filter: (cid = 2101)
22. 355.810 977.431 ↑ 1.0 1 2,093

Aggregate (cost=93.91..93.92 rows=1 width=80) (actual time=0.467..0.467 rows=1 loops=2,093)

23. 621.621 621.621 ↓ 94.0 94 2,093

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.017..0.297 rows=94 loops=2,093)

  • 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: 10
24. 18.837 18.837 ↑ 1.0 1 2,093

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

  • 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. 10.465 10.465 ↑ 1.0 1 2,093

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=2,093)

  • Index Cond: ((cid = li.cid) AND (cid = 2101) AND (id = li.lease_term_id))
26. 2.093 18.837 ↓ 0.0 0 2,093

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

27. 8.372 16.744 ↓ 0.0 0 2,093

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

  • Sort Key: e.event_datetime
  • Sort Method: quicksort Memory: 25kB
28. 8.372 8.372 ↓ 0.0 0 2,093

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=2,093)

  • 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))))
29. 1,747.655 18,753.280 ↓ 105.8 846 2,093

Subquery Scan on past_recent_lease (cost=223.77..288.69 rows=8 width=68) (actual time=4.298..8.960 rows=846 loops=2,093)

  • 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: 2573
30. 7,001.085 17,005.625 ↓ 2.1 3,419 2,093

WindowAgg (cost=223.77..264.34 rows=1,623 width=80) (actual time=4.297..8.125 rows=3,419 loops=2,093)

31. 5,757.843 10,004.540 ↓ 2.1 3,419 2,093

Sort (cost=223.77..227.82 rows=1,623 width=72) (actual time=4.294..4.780 rows=3,419 loops=2,093)

  • 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: 587kB
32. 4,246.697 4,246.697 ↓ 2.1 3,419 2,093

Seq Scan on available_cached_leases cl_1 (cost=0.00..137.23 rows=1,623 width=72) (actual time=0.005..2.029 rows=3,419 loops=2,093)

  • Filter: ((lease_interval_id <> l.lease_interval_id) AND (lease_start_date < li.lease_start_date) AND (cid = 2101))
  • Rows Removed by Filter: 1451
33. 10.135 10.135 ↑ 1.0 1 2,027

Index Scan using idx_temp_cached_leases_scheduled_charges_lease_interval_id on cached_leases_scheduled_charges lsc (cost=0.28..7.81 rows=1 width=156) (actual time=0.005..0.005 rows=1 loops=2,027)

  • 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. 129.728 3,488.467 ↑ 1.0 1 2,027

GroupAggregate (cost=380.62..382.45 rows=1 width=176) (actual time=1.721..1.721 rows=1 loops=2,027)

  • Group Key: sc.one_time_concession
35. 16.216 3,358.739 ↓ 5.0 5 2,027

Sort (cost=380.62..380.63 rows=1 width=73) (actual time=1.656..1.657 rows=5 loops=2,027)

  • Sort Key: sc.one_time_concession
  • Sort Method: quicksort Memory: 25kB
36. 6.081 3,342.523 ↓ 5.0 5 2,027

Subquery Scan on sc (cost=380.57..380.61 rows=1 width=73) (actual time=1.638..1.649 rows=5 loops=2,027)

37. 22.297 3,336.442 ↓ 5.0 5 2,027

WindowAgg (cost=380.57..380.60 rows=1 width=121) (actual time=1.637..1.646 rows=5 loops=2,027)

38. 20.270 3,314.145 ↓ 5.0 5 2,027

Sort (cost=380.57..380.57 rows=1 width=81) (actual time=1.634..1.635 rows=5 loops=2,027)

  • 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. 12.162 3,293.875 ↓ 5.0 5 2,027

Group (cost=380.52..380.56 rows=1 width=81) (actual time=1.620..1.625 rows=5 loops=2,027)

  • 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. 30.405 3,281.713 ↓ 6.0 6 2,027

Sort (cost=380.52..380.52 rows=1 width=81) (actual time=1.618..1.619 rows=6 loops=2,027)

  • 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. 26.258 3,251.308 ↓ 6.0 6 2,027

Nested Loop Left Join (cost=9.88..380.51 rows=1 width=81) (actual time=0.452..1.604 rows=6 loops=2,027)

42. 58.783 117.566 ↓ 6.0 6 2,027

Bitmap Heap Scan on scheduled_charges sc_charges (cost=9.45..13.47 rows=1 width=49) (actual time=0.043..0.058 rows=6 loops=2,027)

  • 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: 8
  • Heap Blocks: exact=11660
43. 8.118 58.783 ↓ 0.0 0 2,027

BitmapAnd (cost=9.45..9.45 rows=1 width=0) (actual time=0.029..0.029 rows=0 loops=2,027)

44. 30.405 30.405 ↓ 5.4 38 2,027

Bitmap Index Scan on idx_scheduled_charges_remote_primary_key (cost=0.00..4.50 rows=7 width=0) (actual time=0.015..0.015 rows=38 loops=2,027)

  • Index Cond: ((cid = 2101) AND (lease_id = l.lease_id))
45. 20.260 20.260 ↑ 2.8 13 2,026

Bitmap Index Scan on idx_scheduled_charges_lease_interval_id (cost=0.00..4.70 rows=36 width=0) (actual time=0.010..0.010 rows=13 loops=2,026)

  • Index Cond: (lease_interval_id = li.id)
46. 22.518 3,107.484 ↓ 0.0 0 11,259

GroupAggregate (cost=0.43..367.02 rows=1 width=44) (actual time=0.276..0.276 rows=0 loops=11,259)

  • Group Key: ar.cid, ar.lease_id, ar.lease_interval_id
47. 3,084.966 3,084.966 ↓ 4.0 4 11,259

Index Scan using idx_ar_transactions_lease_id on ar_transactions ar (cost=0.43..367.00 rows=1 width=17) (actual time=0.232..0.274 rows=4 loops=11,259)

  • 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: 195
48. 6.081 6.081 ↑ 1.0 1 2,027

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

  • Index Cond: (id = l.lease_interval_type_id)
49. 10.135 10.135 ↑ 1.0 1 2,027

Index Scan using idx_property_floorplans on property_floorplans pf (cost=0.28..5.02 rows=1 width=17) (actual time=0.005..0.005 rows=1 loops=2,027)

  • Index Cond: (id = l.property_floorplan_id)
  • Filter: ((cid = 2101) AND (cid = l.cid))
50. 10.135 10.135 ↑ 1.0 1 2,027

Index Scan using idx_unit_types_id on unit_types ut (cost=0.28..5.43 rows=1 width=246) (actual time=0.005..0.005 rows=1 loops=2,027)

  • Index Cond: (id = l.unit_type_id)
  • Filter: ((cid = 2101) AND (cid = l.cid))
51. 12.162 12.162 ↑ 1.0 1 2,027

Index Scan using pk_property_units on property_units pu (cost=0.29..8.11 rows=1 width=12) (actual time=0.006..0.006 rows=1 loops=2,027)

  • Index Cond: ((cid = l.cid) AND (cid = 2101) AND (id = l.property_unit_id))
52. 22.297 22.297 ↑ 1.0 1 2,027

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.011..0.011 rows=1 loops=2,027)

  • Index Cond: ((cid = l.cid) AND (cid = 2101) AND (property_id = l.property_id) AND ((key)::text = 'CHANGE_UNIT_STATUS_TO_RENTED'::text))
53. 14.189 14.189 ↑ 1.0 1 2,027

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=2,027)

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