explain.depesz.com

PostgreSQL's explain analyze made readable

Result: HwfV : Optimization for: plan #6WYg

Settings

Optimization path:

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 0.239 11,245.960 ↓ 5.0 1,001 1

Sort (cost=423,839.34..423,839.84 rows=200 width=40) (actual time=11,245.905..11,245.960 rows=1,001 loops=1)

  • Sort Key: tr.user_id
  • Sort Method: quicksort Memory: 71kB
2. 94.221 11,245.721 ↓ 5.0 1,001 1

HashAggregate (cost=423,829.20..423,831.70 rows=200 width=40) (actual time=11,245.533..11,245.721 rows=1,001 loops=1)

  • Group Key: tr.user_id
3. 79.218 11,151.500 ↓ 1.7 86,412 1

Nested Loop Left Join (cost=8.31..423,449.01 rows=50,692 width=68) (actual time=0.038..11,151.500 rows=86,412 loops=1)

4. 11.546 11.546 ↓ 1.7 86,412 1

Seq Scan on transactions tr (cost=0.00..1,057.92 rows=50,692 width=60) (actual time=0.007..11.546 rows=86,412 loops=1)

5. 0.000 11,060.736 ↑ 1.0 1 86,412

Limit (cost=8.31..8.31 rows=1 width=40) (actual time=0.128..0.128 rows=1 loops=86,412)

6. 3,802.128 11,060.736 ↑ 1.0 1 86,412

Sort (cost=8.31..8.31 rows=1 width=40) (actual time=0.128..0.128 rows=1 loops=86,412)

  • Sort Key: er.ts DESC NULLS LAST
  • Sort Method: top-N heapsort Memory: 25kB
7. 7,258.608 7,258.608 ↓ 367.0 367 86,412

Index Scan using idx_ts_from_to on exchange_rates er (cost=0.28..8.30 rows=1 width=40) (actual time=0.010..0.084 rows=367 loops=86,412)

  • Index Cond: (((from_currency)::text = (tr.currency)::text) AND (ts <= tr.ts))
Planning time : 0.265 ms
Execution time : 11,246.042 ms