explain.depesz.com

PostgreSQL's explain analyze made readable

Result: ZyjC

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

Limit (cost=2,585,225,383.96..2,585,225,384.03 rows=30 width=66) (actual rows= loops=)

2. 0.000 0.000 ↓ 0.0

Sort (cost=2,585,225,383.96..2,585,225,384.03 rows=30 width=66) (actual rows= loops=)

  • Sort Key: i.invoice_date DESC
3. 0.000 0.000 ↓ 0.0

GroupAggregate (cost=0.43..2,585,225,383.22 rows=30 width=66) (actual rows= loops=)

  • Group Key: i.id
4. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=0.43..2,585,221,664.20 rows=39 width=44) (actual rows= loops=)

  • Join Filter: (t.id = stt.transaction_id)
5. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.43..2,579,589,132.80 rows=39 width=44) (actual rows= loops=)

  • Join Filter: (t.charge_code_id = cc.id)
6. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.43..2,579,588,987.59 rows=39 width=48) (actual rows= loops=)

  • Join Filter: (i.id = t.invoice_id)
7. 0.000 0.000 ↓ 0.0

Index Scan using pk_company_invoices on invoices i (cost=0.43..535,814.39 rows=30 width=34) (actual rows= loops=)

  • Filter: ((deleted_by IS NULL) AND (deleted_on IS NULL) AND (invoice_status_type_id < 6) AND (account_id = 3618))
8. 0.000 0.000 ↓ 0.0

Materialize (cost=0.00..2,575,185,573.00 rows=8,642,682 width=18) (actual rows= loops=)

9. 0.000 0.000 ↓ 0.0

Seq Scan on transactions t (cost=0.00..2,575,142,359.59 rows=8,642,682 width=18) (actual rows= loops=)

  • Filter: (((company_payment_id IS NULL) OR (transaction_amount > '0'::numeric)) AND ((transaction_amount - COALESCE((SubPlan 2), '0'::numeric)) > '0'::numeric))
10.          

SubPlan (forSeq Scan)

11. 0.000 0.000 ↓ 0.0

Aggregate (cost=95.33..95.34 rows=1 width=32) (actual rows= loops=)

12. 0.000 0.000 ↓ 0.0

Bitmap Heap Scan on allocations a_1 (cost=9.03..95.16 rows=22 width=10) (actual rows= loops=)

  • Recheck Cond: ((charge_transaction_id = t.id) OR (credit_transaction_id = t.id))
13. 0.000 0.000 ↓ 0.0

BitmapOr (cost=9.03..9.03 rows=22 width=0) (actual rows= loops=)

14. 0.000 0.000 ↓ 0.0

Bitmap Index Scan on idx_allocations_charge_transaction_id (cost=0.00..4.44 rows=1 width=0) (actual rows= loops=)

  • Index Cond: (charge_transaction_id = t.id)
15. 0.000 0.000 ↓ 0.0

Bitmap Index Scan on idx_allocations_credit_transaction_id (cost=0.00..4.58 rows=21 width=0) (actual rows= loops=)

  • Index Cond: (credit_transaction_id = t.id)
16. 0.000 0.000 ↓ 0.0

Materialize (cost=0.00..9.50 rows=233 width=4) (actual rows= loops=)

17. 0.000 0.000 ↓ 0.0

Seq Scan on charge_codes cc (cost=0.00..8.33 rows=233 width=4) (actual rows= loops=)

18. 0.000 0.000 ↓ 0.0

Materialize (cost=0.00..288,253.51 rows=9,174,726 width=4) (actual rows= loops=)

19. 0.000 0.000 ↓ 0.0

Seq Scan on sales_tax_transactions stt (cost=0.00..242,379.88 rows=9,174,726 width=4) (actual rows= loops=)

  • Filter: (is_adjustment = 0)
20.          

SubPlan (forGroupAggregate)

21. 0.000 0.000 ↓ 0.0

Aggregate (cost=95.33..95.34 rows=1 width=32) (actual rows= loops=)

22. 0.000 0.000 ↓ 0.0

Bitmap Heap Scan on allocations a (cost=9.03..95.16 rows=22 width=10) (actual rows= loops=)

  • Recheck Cond: ((charge_transaction_id = t.id) OR (credit_transaction_id = t.id))
23. 0.000 0.000 ↓ 0.0

BitmapOr (cost=9.03..9.03 rows=22 width=0) (actual rows= loops=)

24. 0.000 0.000 ↓ 0.0

Bitmap Index Scan on idx_allocations_charge_transaction_id (cost=0.00..4.44 rows=1 width=0) (actual rows= loops=)

  • Index Cond: (charge_transaction_id = t.id)
25. 0.000 0.000 ↓ 0.0

Bitmap Index Scan on idx_allocations_credit_transaction_id (cost=0.00..4.58 rows=21 width=0) (actual rows= loops=)