explain.depesz.com

PostgreSQL's explain analyze made readable

Result: kCFw : Optimization for: plan #S4yQ

Settings

Optimization path:

# exclusive inclusive rows x rows loops node
1. 0.668 61,368.517 ↓ 64.0 448 1

GroupAggregate (cost=597,697.78..597,698.20 rows=7 width=71) (actual time=61,367.688..61,368.517 rows=448 loops=1)

  • Group Key: psd.cid, psd.property_id, st.id, pb.id, (COALESCE(sil.is_hera, sil2.is_hera)), (COALESCE(sil.family_size, sil2.family_size)), psa.id, sct.id, pb.cid
  • Planning time: 15.021 ms
  • Execution time: 61369.393 ms
2. 1.747 61,367.849 ↓ 64.0 448 1

Sort (cost=597,697.78..597,697.80 rows=7 width=63) (actual time=61,367.649..61,367.849 rows=448 loops=1)

  • Sort Key: st.id, pb.id, (COALESCE(sil.is_hera, sil2.is_hera)), (COALESCE(sil.family_size, sil2.family_size)), psa.id, sct.id, pb.cid
  • Sort Method: quicksort Memory: 60kB
3. 2.481 61,366.102 ↓ 64.0 448 1

Nested Loop Left Join (cost=3.55..597,697.68 rows=7 width=63) (actual time=183.045..61,366.102 rows=448 loops=1)

  • Join Filter: ((COALESCE(sil.is_hera, sil2.is_hera)) = ((st.id = 2) AND COALESCE(psd.tax_credit_use_hera_limits, false)))
  • Rows Removed by Join Filter: 448
4. 0.769 54.317 ↓ 8.0 56 1

Nested Loop Left Join (cost=2.70..47.81 rows=7 width=53) (actual time=35.085..54.317 rows=56 loops=1)

  • Join Filter: CASE WHEN (sct.id = 1) THEN (silt.id = CASE WHEN (sc.start_date <= '10/01/1981'::date) THEN 6 ELSE 3 END) WHEN (sct.id = 6) THEN (silt.id = 1) WHEN (sct.id = ANY ('{7,8}'::integer[])) THEN (silt.id = 3) WHEN (sct.id = ANY ('{3,2,9,4}'::integer[])) THEN (silt.id = 6) WHEN (sct.id = 5) THEN (silt.id = 7) WHEN (st.id = 2) THEN (silt.percent = psa.median_income_percent) WHEN (sct.id = 10) THEN (silt.id = 6) WHEN (sct.id = 11) THEN (silt.id = 3) ELSE NULL::boolean END
  • Rows Removed by Join Filter: 392
5. 0.286 53.156 ↓ 28.0 56 1

Nested Loop Left Join (cost=2.70..45.31 rows=2 width=53) (actual time=35.041..53.156 rows=56 loops=1)

6. 0.287 50.630 ↓ 28.0 56 1

Nested Loop Left Join (cost=2.42..35.82 rows=2 width=53) (actual time=34.927..50.630 rows=56 loops=1)

  • Join Filter: (sct.subsidy_type_id = st.id)
7. 0.356 50.287 ↓ 28.0 56 1

Nested Loop (cost=2.28..31.41 rows=2 width=50) (actual time=34.914..50.287 rows=56 loops=1)

8. 4.366 48.811 ↓ 14.0 56 1

Hash Join (cost=1.87..21.59 rows=4 width=63) (actual time=34.795..48.811 rows=56 loops=1)

  • Hash Cond: (pst.subsidy_type_id = st.id)
  • Join Filter: (((st.id = 2) AND psd.tax_credit_is_hold_harmless AND (COALESCE(sc.start_date, psa.placed_in_service_date) > silv.effective_date)) OR (silv.id = (SubPlan 1)))
  • Rows Removed by Join Filter: 1456
9. 2.189 3.604 ↓ 11.2 1,512 1

Nested Loop (cost=0.56..17.51 rows=135 width=68) (actual time=0.248..3.604 rows=1,512 loops=1)

10. 0.038 0.038 ↑ 1.0 27 1

Seq Scan on subsidy_income_limit_versions silv (cost=0.00..1.81 rows=27 width=8) (actual time=0.018..0.038 rows=27 loops=1)

11. 0.992 1.377 ↓ 11.2 56 27

Materialize (cost=0.56..11.32 rows=5 width=60) (actual time=0.009..0.051 rows=56 loops=27)

12. 0.075 0.385 ↓ 11.2 56 1

Nested Loop Left Join (cost=0.56..11.30 rows=5 width=60) (actual time=0.219..0.385 rows=56 loops=1)

13. 0.003 0.146 ↑ 1.0 1 1

Nested Loop Left Join (cost=0.28..5.01 rows=1 width=40) (actual time=0.140..0.146 rows=1 loops=1)

  • Join Filter: ((sc.cid = psd.cid) AND (sc.property_id = psd.property_id))
14. 0.006 0.120 ↑ 1.0 1 1

Nested Loop (cost=0.28..3.39 rows=1 width=32) (actual time=0.115..0.120 rows=1 loops=1)

15. 0.050 0.050 ↑ 1.0 1 1

Index Scan using uk_property_subsidy_details_cid_property_id on property_subsidy_details psd (cost=0.14..2.18 rows=1 width=28) (actual time=0.048..0.050 rows=1 loops=1)

  • Index Cond: ((cid = 14706) AND (property_id = 533143))
16. 0.064 0.064 ↑ 1.0 1 1

Index Only Scan using idx_property_subsidy_types_cid_pid_delon_subtypeid on property_subsidy_types pst (cost=0.14..1.19 rows=1 width=12) (actual time=0.062..0.064 rows=1 loops=1)

  • Index Cond: ((cid = 14706) AND (property_id = 533143) AND (deleted_on IS NULL))
  • Heap Fetches: 0
17. 0.023 0.023 ↓ 0.0 0 1

Seq Scan on subsidy_contracts sc (cost=0.00..1.58 rows=1 width=16) (actual time=0.023..0.023 rows=0 loops=1)

  • Filter: ((deleted_on IS NULL) AND (cid = 14706) AND (property_id = 533143) AND (CURRENT_DATE >= start_date) AND (CURRENT_DATE <= end_date))
  • Rows Removed by Filter: 13
18. 0.164 0.164 ↓ 11.2 56 1

Index Scan using idx_set_asides_cid_property_id_name on set_asides psa (cost=0.27..6.13 rows=5 width=25) (actual time=0.075..0.164 rows=56 loops=1)

  • Index Cond: ((cid = psd.cid) AND (cid = 14706) AND (property_id = psd.property_id) AND (property_id = 533143))
  • Filter: ((deleted_on IS NULL) AND ((property_building_id IS NOT NULL) = psd.is_tax_credit_multiple_building_project))
19. 0.009 0.017 ↑ 1.0 5 1

Hash (cost=1.15..1.15 rows=5 width=4) (actual time=0.016..0.017 rows=5 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
20. 0.008 0.008 ↑ 1.0 5 1

Seq Scan on subsidy_types st (cost=0.00..1.15 rows=5 width=4) (actual time=0.004..0.008 rows=5 loops=1)

21.          

SubPlan (forHash Join)

22. 4.536 40.824 ↑ 1.0 1 1,512

Limit (cost=2.37..2.37 rows=1 width=12) (actual time=0.025..0.027 rows=1 loops=1,512)

23. 7.560 36.288 ↑ 4.0 1 1,512

Sort (cost=2.37..2.38 rows=4 width=12) (actual time=0.023..0.024 rows=1 loops=1,512)

  • Sort Key: subsidy_income_limit_versions.property_id, subsidy_income_limit_versions.effective_date DESC, subsidy_income_limit_versions.id DESC
  • Sort Method: quicksort Memory: 25kB
24. 28.728 28.728 ↑ 4.0 1 1,512

Seq Scan on subsidy_income_limit_versions (cost=0.00..2.35 rows=4 width=12) (actual time=0.012..0.019 rows=1 loops=1,512)

  • Filter: (is_published AND (CURRENT_DATE >= effective_date) AND (CURRENT_DATE <= effective_through_date) AND (((pst.subsidy_type_id = 2) AND (property_id = 533143) AND (cid = 14706)) OR ((cid = 1) AND (property_id IS NULL))))
  • Rows Removed by Filter: 26
25. 1.120 1.120 ↑ 1.0 1 56

Index Scan using uk_subsidy_income_limit_areas_silvi_hmfa_code on subsidy_income_limit_areas sila (cost=0.41..2.45 rows=1 width=25) (actual time=0.020..0.020 rows=1 loops=56)

  • Index Cond: ((subsidy_income_limit_version_id = silv.id) AND (hmfa_code = psd.hmfa_code))
26. 0.056 0.056 ↓ 0.0 0 56

Index Scan using pk_subsidy_contract_types on subsidy_contract_types sct (cost=0.14..2.17 rows=1 width=11) (actual time=0.001..0.001 rows=0 loops=56)

  • Index Cond: (sc.subsidy_contract_type_id = id)
27. 2.240 2.240 ↑ 1.0 1 56

Index Only Scan using pk_property_buildings on property_buildings pb (cost=0.28..4.72 rows=1 width=8) (actual time=0.018..0.040 rows=1 loops=56)

  • Index Cond: ((cid = psa.cid) AND (cid = 14706))
  • Filter: (id = COALESCE(psa.property_building_id, id))
  • Rows Removed by Filter: 73
  • Heap Fetches: 1344
28. 0.363 0.392 ↑ 1.0 8 56

Materialize (cost=0.00..1.28 rows=8 width=9) (actual time=0.001..0.007 rows=8 loops=56)

29. 0.029 0.029 ↑ 1.0 8 1

Seq Scan on subsidy_income_level_types silt (cost=0.00..1.24 rows=8 width=9) (actual time=0.020..0.029 rows=8 loops=1)

30. 14.840 61,309.304 ↓ 16.0 16 56

Nested Loop Left Join (cost=0.85..85,378.49 rows=1 width=44) (actual time=113.931..1,094.809 rows=16 loops=56)

  • Join Filter: ((sil.subsidy_income_limit_version_id = sil2.subsidy_income_limit_version_id) AND (sil.subsidy_income_limit_area_id = sil2.subsidy_income_limit_area_id) AND (sil.subsidy_type_id = sil2.subsidy_type_id) AND (sil.is_hera = sil2.is_hera) AND (sil.family_size = sil2.family_size))
  • Rows Removed by Join Filter: 120
31. 3,609.984 3,609.984 ↓ 16.0 16 56

Index Scan using uk_subincomlimts_subtid_subilaid_famsize_subiltid_subtid_ishera on subsidy_income_limits sil2 (cost=0.43..42,689.22 rows=1 width=19) (actual time=55.253..64.464 rows=16 loops=56)

  • Index Cond: ((subsidy_income_limit_version_id = silv.id) AND (subsidy_income_limit_area_id = sila.id) AND (subsidy_income_level_type_id = 3) AND (subsidy_type_id = pst.subsidy_type_id))
32. 57,684.480 57,684.480 ↓ 8.0 8 896

Index Scan using uk_subincomlimts_subtid_subilaid_famsize_subiltid_subtid_ishera on subsidy_income_limits sil (cost=0.43..42,689.22 rows=1 width=19) (actual time=59.627..64.380 rows=8 loops=896)

  • Index Cond: ((subsidy_income_limit_version_id = silv.id) AND (subsidy_income_limit_area_id = sila.id) AND (subsidy_income_level_type_id = silt.id) AND (subsidy_type_id = pst.subsidy_type_id))