explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 1k5T

Settings
# exclusive inclusive rows x rows loops node
1. 0.000 0.000 ↓ 0.0

Limit (cost=11.01..502,937.05 rows=25 width=185) (actual rows= loops=)

2. 0.000 0.000 ↓ 0.0

Nested Loop (cost=11.01..3,714,772,702.58 rows=184,658 width=185) (actual rows= loops=)

  • Join Filter: (ap.ap_payment_type_id = apt.id)
3. 0.000 0.000 ↓ 0.0

Nested Loop (cost=11.01..3,714,635,191.53 rows=184,658 width=142) (actual rows= loops=)

4. 0.000 0.000 ↓ 0.0

Nested Loop (cost=10.59..3,714,549,048.48 rows=184,658 width=143) (actual rows= loops=)

5. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=3.11..3,711,286,457.61 rows=184,658 width=107) (actual rows= loops=)

6. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.84..3,704,964,836.46 rows=184,658 width=103) (actual rows= loops=)

  • Join Filter: (ap.bank_account_id = ba.id)
7. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.84..3,699,884,812.95 rows=184,658 width=75) (actual rows= loops=)

  • Join Filter: ((max(LEAST(ah_1.id, ah_1.reversal_ap_header_id))) = ah.id)
8. 0.000 0.000 ↓ 0.0

Index Scan using idx_ap_headers_post_month on ap_headers ah (cost=0.42..40,736.90 rows=568,856 width=21) (actual rows= loops=)

  • Filter: ((deleted_on IS NULL) AND (NOT is_initial_import) AND (cid = 3395))
9. 0.000 0.000 ↓ 0.0

Materialize (cost=0.42..494,332.72 rows=185,804 width=58) (actual rows= loops=)

10. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.42..493,403.70 rows=185,804 width=58) (actual rows= loops=)

11. 0.000 0.000 ↓ 0.0

Seq Scan on ap_payments ap (cost=0.00..16,816.44 rows=185,804 width=54) (actual rows= loops=)

  • Filter: ((NOT is_unclaimed_property) AND (cid = 3395) AND (ap_payment_type_id = ANY ('{1,2,3,4,5,6,7,8,9,10,11,12,13}'::integer[])))
12. 0.000 0.000 ↓ 0.0

GroupAggregate (cost=0.42..2.50 rows=1 width=12) (actual rows= loops=)

  • Group Key: ah_1.cid, ah_1.ap_payment_id
13. 0.000 0.000 ↓ 0.0

Index Scan using idx_ap_headers_ap_payment_id_partial on ap_headers ah_1 (cost=0.42..2.47 rows=1 width=16) (actual rows= loops=)

  • Index Cond: (ap_payment_id = ap.id)
  • Filter: ((deleted_on IS NULL) AND (cid = ap.cid) AND (ap_header_type_id = 5) AND (gl_transaction_type_id = 3))
14. 0.000 0.000 ↓ 0.0

Materialize (cost=0.00..77.51 rows=787 width=36) (actual rows= loops=)

15. 0.000 0.000 ↓ 0.0

Seq Scan on bank_accounts ba (cost=0.00..73.58 rows=787 width=36) (actual rows= loops=)

  • Filter: (cid = 3395)
16. 0.000 0.000 ↓ 0.0

Limit (cost=2.27..34.17 rows=1 width=8) (actual rows= loops=)

17. 0.000 0.000 ↓ 0.0

Result (cost=2.27..34.17 rows=1 width=8) (actual rows= loops=)

  • One-Time Filter: (ah.cid = 3395)
18. 0.000 0.000 ↓ 0.0

Nested Loop Semi Join (cost=2.27..34.17 rows=1 width=8) (actual rows= loops=)

  • Join Filter: (ad.property_id = load_properties_info.property_id)
19. 0.000 0.000 ↓ 0.0

Nested Loop (cost=2.26..18.73 rows=1 width=12) (actual rows= loops=)

  • Join Filter: (aa.cid = gr.cid)
20. 0.000 0.000 ↓ 0.0

Nested Loop (cost=1.98..18.38 rows=1 width=24) (actual rows= loops=)

  • Join Filter: ((aa.cid = gd.cid) AND (CASE WHEN ((aa.origin_ap_allocation_id IS NOT NULL) OR (aa.lump_ap_header_id IS NOT NULL)) THEN (aa.allocation_amount * '-1'::numeric) ELSE aa.allocation_amount END = gd.amount) AND (CASE WHEN (ba.reimbursed_property_id <> aa.property_id) THEN ba.reimbursed_property_id ELSE aa.property_id END = gd.property_id))
21. 0.000 0.000 ↓ 0.0

Nested Loop (cost=1.41..11.85 rows=1 width=38) (actual rows= loops=)

22. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.85..9.93 rows=1 width=38) (actual rows= loops=)

23. 0.000 0.000 ↓ 0.0

Index Scan using idx_ap_details_ap_header_id on ap_details ad (cost=0.42..7.44 rows=1 width=12) (actual rows= loops=)

  • Index Cond: (ah.id = ap_header_id)
  • Filter: ((deleted_on IS NULL) AND (ah.gl_transaction_type_id = gl_transaction_type_id) AND (ah.post_month = post_month))
24. 0.000 0.000 ↓ 0.0

Index Scan using idx_ap_allocations_credit_ap_detail_id on ap_allocations aa (cost=0.42..2.47 rows=1 width=34) (actual rows= loops=)

  • Index Cond: (credit_ap_detail_id = ad.id)
  • Filter: ((gl_transaction_type_id = 4) AND (ad.cid = cid))
25. 0.000 0.000 ↓ 0.0

Index Scan using idx_gl_headers_cid_reference_id on gl_headers gh (cost=0.56..1.89 rows=1 width=16) (actual rows= loops=)

  • Index Cond: ((cid = aa.cid) AND (reference_id = aa.id))
  • Filter: (gl_transaction_type_id = 4)
26. 0.000 0.000 ↓ 0.0

Index Scan using idx_gl_details_gl_header_id on gl_details gd (cost=0.57..6.48 rows=1 width=21) (actual rows= loops=)

  • Index Cond: (gl_header_id = gh.id)
  • Filter: ((gl_reconciliation_id IS NOT NULL) AND (gh.cid = cid))
27. 0.000 0.000 ↓ 0.0

Index Scan using pk_gl_reconciliations on gl_reconciliations gr (cost=0.28..0.32 rows=1 width=12) (actual rows= loops=)

  • Index Cond: ((cid = gd.cid) AND (id = gd.gl_reconciliation_id))
28. 0.000 0.000 ↓ 0.0

Seq Scan on load_properties_info (cost=0.00..8.45 rows=215 width=4) (actual rows= loops=)

29. 0.000 0.000 ↓ 0.0

GroupAggregate (cost=7.48..17.61 rows=1 width=48) (actual rows= loops=)

  • Group Key: (ah.cid), (ah.id)
30. 0.000 0.000 ↓ 0.0

Result (cost=7.48..17.57 rows=1 width=30) (actual rows= loops=)

  • One-Time Filter: (ah.cid = 3395)
31. 0.000 0.000 ↓ 0.0

Hash Join (cost=7.48..17.57 rows=1 width=30) (actual rows= loops=)

  • Hash Cond: ((lp.cid = ad_1.cid) AND (lp.property_id = ad_1.property_id))
32. 0.000 0.000 ↓ 0.0

Seq Scan on load_properties_info lp (cost=0.00..8.45 rows=215 width=26) (actual rows= loops=)

33. 0.000 0.000 ↓ 0.0

Hash (cost=7.44..7.44 rows=1 width=8) (actual rows= loops=)

34. 0.000 0.000 ↓ 0.0

Index Scan using idx_ap_details_ap_header_id on ap_details ad_1 (cost=0.42..7.44 rows=1 width=8) (actual rows= loops=)

  • Index Cond: (ah.id = ap_header_id)
  • Filter: ((deleted_on IS NULL) AND (ah.gl_transaction_type_id = gl_transaction_type_id) AND (ah.post_month = post_month))
35. 0.000 0.000 ↓ 0.0

Index Scan using idx_ap_payee_locations_id on ap_payee_locations apl (cost=0.42..0.47 rows=1 width=15) (actual rows= loops=)

  • Index Cond: (id = ah.ap_payee_location_id)
  • Filter: (cid = 3395)
36. 0.000 0.000 ↓ 0.0

Materialize (cost=0.00..2.49 rows=14 width=15) (actual rows= loops=)

37. 0.000 0.000 ↓ 0.0

Seq Scan on ap_payment_types apt (cost=0.00..2.42 rows=14 width=15) (actual rows= loops=)