explain.depesz.com

PostgreSQL's explain analyze made readable

Result: Z39U

Settings

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 0.000 0.000 ↓ 5.0 1,001 1

Sort (cost=7,551.47..7,551.97 rows=200 width=36) (actual rows=1,001 loops=1)

  • Sort Key: t.user_id
  • Sort Method: quicksort Memory: 71kB
2.          

CTE sorted_er

3. 0.000 0.000 ↓ 364.2 1,457 1

Sort (cost=20.16..20.18 rows=4 width=72) (actual rows=1,457 loops=1)

  • Sort Key: exchange_rates.from_currency, exchange_rates.ts DESC
  • Sort Method: quicksort Memory: 162kB
4. 0.000 0.000 ↓ 364.2 1,457 1

Seq Scan on exchange_rates (cost=0.00..20.12 rows=4 width=72) (actual rows=1,457 loops=1)

  • Filter: ((to_currency)::text = 'GBP'::text)
  • Rows Removed by Filter: 1
5. 0.000 0.000 ↓ 5.0 1,001 1

HashAggregate (cost=7,521.15..7,523.65 rows=200 width=36) (actual rows=1,001 loops=1)

  • Group Key: t.user_id
6. 0.000 0.000 ↓ 1.7 86,412 1

Nested Loop Left Join (cost=0.00..7,140.96 rows=50,692 width=68) (actual rows=86,412 loops=1)

7. 0.000 0.000 ↓ 1.7 86,412 1

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

8. 0.000 0.000 ↑ 1.0 1 86,412

Unique (cost=0.00..0.10 rows=1 width=48) (actual rows=1 loops=86,412)

9. 0.000 0.000 ↓ 367.0 367 86,412

CTE Scan on sorted_er (cost=0.00..0.10 rows=1 width=48) (actual rows=367 loops=86,412)

  • Filter: ((ts <= t.ts) AND ((t.currency)::text = (from_currency)::text))
  • Rows Removed by Filter: 1090
Planning time : 0.231 ms
Execution time : 8,900.068 ms