explain.depesz.com

PostgreSQL's explain analyze made readable

Result: WWQw

Settings
# exclusive inclusive rows x rows loops node
1. 0.001 14,922.594 ↓ 0.0 0 1

Limit (cost=42,056.07..42,056.26 rows=15 width=2,212) (actual time=14,922.594..14,922.594 rows=0 loops=1)

2. 0.001 14,922.593 ↓ 0.0 0 1

Group (cost=42,056.07..42,065.23 rows=733 width=2,212) (actual time=14,922.593..14,922.593 rows=0 loops=1)

  • Group Key: (CASE WHEN ((transactions_invoices.type)::text = 'Transactions::MonthlyInvoice'::text) THEN transactions_invoices.created_at ELSE transactions_payments.created_at END), transactions_invoices.id, insurance_claims.id
3. 0.025 14,922.592 ↓ 0.0 0 1

Sort (cost=42,056.07..42,057.90 rows=733 width=2,211) (actual time=14,922.591..14,922.592 rows=0 loops=1)

  • Sort Key: (CASE WHEN ((transactions_invoices.type)::text = 'Transactions::MonthlyInvoice'::text) THEN transactions_invoices.created_at ELSE transactions_payments.created_at END) DESC, transactions_invoices.id, insurance_claims.id
  • Sort Method: quicksort Memory: 25kB
4. 0.001 14,922.567 ↓ 0.0 0 1

Hash Left Join (cost=21,545.08..42,021.19 rows=733 width=2,211) (actual time=14,922.567..14,922.567 rows=0 loops=1)

  • Hash Cond: (transactions_invoices.id = insurance_claims.invoice_id)
5. 579.307 14,922.566 ↓ 0.0 0 1

Hash Join (cost=21,541.67..42,013.18 rows=733 width=2,207) (actual time=14,922.566..14,922.566 rows=0 loops=1)

  • Hash Cond: (transactions_sub_payments.payment_id = transactions_payments.id)
6. 1,830.563 11,077.116 ↓ 4.9 723,317 1

Nested Loop (cost=1,001.28..21,088.13 rows=146,540 width=2,203) (actual time=34.932..11,077.116 rows=723,317 loops=1)

7. 0.000 3,515.025 ↓ 26,534.9 716,441 1

Gather (cost=1,000.85..16,738.30 rows=27 width=2,203) (actual time=22.202..3,515.025 rows=716,441 loops=1)

  • Workers Planned: 2
  • Workers Launched: 2
8. 2,918.652 5,754.105 ↓ 21,710.4 238,814 3

Nested Loop (cost=0.85..15,735.60 rows=11 width=2,203) (actual time=15.212..5,754.105 rows=238,814 loops=3)

9. 2,495.451 2,835.443 ↓ 21,710.4 238,814 3

Nested Loop (cost=0.43..15,715.84 rows=11 width=2,203) (actual time=10.902..2,835.443 rows=238,814 loops=3)

10. 339.984 339.984 ↓ 160.1 238,814 3

Parallel Seq Scan on transactions_invoices (cost=0.00..14,888.46 rows=1,492 width=2,199) (actual time=1.862..339.984 rows=238,814 loops=3)

  • Filter: (payment_receiver_id = 1)
11. 0.008 0.008 ↑ 27.0 1 716,441

Index Only Scan using index_tis_on_owner_id_and_owner_type on transactions_invoice_sequences (cost=0.43..3.86 rows=27 width=4) (actual time=0.008..0.008 rows=1 loops=716,441)

  • Index Cond: ((owner_id = transactions_invoices.id) AND (owner_type = 'Transactions::Invoice'::text))
  • Heap Fetches: 0
12. 0.010 0.010 ↑ 1.0 1 716,441

Index Only Scan using customers_pkey on customers (cost=0.42..1.80 rows=1 width=4) (actual time=0.010..0.010 rows=1 loops=716,441)

  • Index Cond: (id = transactions_invoices.customer_id)
  • Heap Fetches: 0
13. 5,731.528 5,731.528 ↑ 5,427.0 1 716,441

Index Scan using index_transactions_sub_payments_on_invoice_id on transactions_sub_payments (cost=0.43..106.83 rows=5,427 width=8) (actual time=0.007..0.008 rows=1 loops=716,441)

  • Index Cond: (invoice_id = transactions_invoice_sequences.owner_id)
14. 0.000 3,266.143 ↑ 5,419.0 1 1

Hash (cost=20,472.65..20,472.65 rows=5,419 width=12) (actual time=3,266.143..3,266.143 rows=1 loops=1)

  • Buckets: 8192 Batches: 1 Memory Usage: 65kB
15. 13.116 3,266.176 ↑ 5,419.0 1 1

Gather (cost=1,000.00..20,472.65 rows=5,419 width=12) (actual time=3,266.135..3,266.176 rows=1 loops=1)

  • Workers Planned: 2
  • Workers Launched: 2
16. 3,253.060 3,253.060 ↓ 0.0 0 3

Parallel Seq Scan on transactions_payments (cost=0.00..18,930.75 rows=2,258 width=12) (actual time=2,487.712..3,253.060 rows=0 loops=3)

  • Filter: ((created_at >= '2019-09-30 22:00:00'::timestamp without time zone) AND (created_at <= '2019-10-25 21:59:59.999999'::timestamp without time zone))
  • Rows Removed by Filter: 361268
17. 0.000 0.000 ↓ 0.0 0

Hash (cost=2.63..2.63 rows=63 width=8) (never executed)

18. 0.000 0.000 ↓ 0.0 0

Seq Scan on insurance_claims (cost=0.00..2.63 rows=63 width=8) (never executed)