explain.depesz.com

PostgreSQL's explain analyze made readable

Result: RNpk

Settings
# exclusive inclusive rows x rows loops node
1. 0.000 2,125.010 ↓ 1.5 17 1

Finalize GroupAggregate (cost=49,810.17..49,817.57 rows=11 width=36) (actual time=1,895.739..2,125.010 rows=17 loops=1)

  • Output: sum(CASE WHEN ledger_entry.is_credit THEN ('-1'::numeric * ledger_entry.value) ELSE ledger_entry.value END), billing_account.currency
  • Group Key: billing_account.currency
  • Buffers: shared hit=35,976, temp read=430 written=433
2. 0.546 2,125.044 ↑ 1.3 17 1

Gather Merge (cost=49,810.17..49,817.27 rows=22 width=36) (actual time=1,895.662..2,125.044 rows=17 loops=1)

  • Output: billing_account.currency, (PARTIAL sum(CASE WHEN ledger_entry.is_credit THEN ('-1'::numeric * ledger_entry.value) ELSE ledger_entry.value END))
  • Workers Planned: 2
  • Workers Launched: 0
  • Buffers: shared hit=35,976, temp read=430 written=433
3. 139.047 2,124.498 ↓ 1.5 17 1

Partial GroupAggregate (cost=48,810.15..48,814.71 rows=11 width=36) (actual time=1,895.204..2,124.498 rows=17 loops=1)

  • Output: billing_account.currency, PARTIAL sum(CASE WHEN ledger_entry.is_credit THEN ('-1'::numeric * ledger_entry.value) ELSE ledger_entry.value END)
  • Group Key: billing_account.currency
  • Buffers: shared hit=35,976, temp read=430 written=433
4. 248.896 1,985.451 ↓ 394.7 174,455 1

Sort (cost=48,810.15..48,811.26 rows=442 width=10) (actual time=1,895.107..1,985.451 rows=174,455 loops=1)

  • Output: billing_account.currency, ledger_entry.is_credit, ledger_entry.value
  • Sort Key: billing_account.currency
  • Sort Method: external merge Disk: 3,440kB
  • Buffers: shared hit=35,976, temp read=430 written=433
5. 919.273 1,736.555 ↓ 394.7 174,455 1

Hash Join (cost=119.41..48,790.73 rows=442 width=10) (actual time=0.599..1,736.555 rows=174,455 loops=1)

  • Output: billing_account.currency, ledger_entry.is_credit, ledger_entry.value
  • Inner Unique: true
  • Hash Cond: (ledger_entry.account_id = billing_account.id)
  • Buffers: shared hit=35,976
6. 817.072 817.072 ↓ 2.4 2,415,830 1

Parallel Seq Scan on public.ledger_entry (cost=0.00..46,027.31 rows=1,007,131 width=14) (actual time=0.004..817.072 rows=2,415,830 loops=1)

  • Output: ledger_entry.id, ledger_entry.posted_date, ledger_entry.journal_id, ledger_entry.account_id, ledger_entry.value, ledger_entry.is_credit, ledger_entry.description, ledger_entry.invoice_id, ledger_entry.currency, ledger_entry.product_id, ledger_entry.corrected, ledger_entry.correction_for_ledger_entry_id, ledger_entry.customer_rebate_id
  • Buffers: shared hit=35,956
7. 0.009 0.210 ↑ 1.0 17 1

Hash (cost=119.20..119.20 rows=17 width=12) (actual time=0.210..0.210 rows=17 loops=1)

  • Output: billing_account.currency, billing_account.id
  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
  • Buffers: shared hit=20
8. 0.020 0.201 ↑ 1.0 17 1

Bitmap Heap Scan on public.billing_account (cost=59.47..119.20 rows=17 width=12) (actual time=0.189..0.201 rows=17 loops=1)

  • Output: billing_account.currency, billing_account.id
  • Recheck Cond: ((billing_account.customer_id = 175) AND (billing_account.account_group = 'CUSTOMER_PREPAID_FUNDS'::accountgroupenum))
  • Heap Blocks: exact=7
  • Buffers: shared hit=20
9. 0.008 0.181 ↓ 0.0 0 1

BitmapAnd (cost=59.47..59.47 rows=17 width=0) (actual time=0.181..0.181 rows=0 loops=1)

  • Buffers: shared hit=13
10. 0.025 0.025 ↑ 1.0 228 1

Bitmap Index Scan on billing_account_customer_id_idx (cost=0.00..6.05 rows=235 width=0) (actual time=0.024..0.025 rows=228 loops=1)

  • Index Cond: (billing_account.customer_id = 175)
  • Buffers: shared hit=2
11. 0.148 0.148 ↓ 1.0 2,788 1

Bitmap Index Scan on billing_account_account_group_idx (cost=0.00..53.15 rows=2,782 width=0) (actual time=0.148..0.148 rows=2,788 loops=1)

  • Index Cond: (billing_account.account_group = 'CUSTOMER_PREPAID_FUNDS'::accountgroupenum)
  • Buffers: shared hit=11