explain.depesz.com

PostgreSQL's explain analyze made readable

Result: RzW

Settings
# exclusive inclusive rows x rows loops node
1. 714.105 13,803.595 ↑ 1.0 1,001 1

HashAggregate (cost=2,690.86..2,703.38 rows=1,001 width=36) (actual time=13,796.707..13,803.595 rows=1,001 loops=1)

  • Group Key: tr.user_id
2.          

CTE _

3. 18.726 113.013 ↓ 1.0 1,462 1

Append (cost=136.75..225.31 rows=1,460 width=112) (actual time=23.916..113.013 rows=1,462 loops=1)

4.          

CTE last_rates

5. 10.341 19.699 ↑ 1.3 3 1

HashAggregate (cost=35.52..35.55 rows=4 width=16) (actual time=19.673..19.699 rows=3 loops=1)

  • Group Key: exchange_rates.from_currency, exchange_rates.to_currency
6. 9.358 9.358 ↑ 1.0 1,458 1

Seq Scan on exchange_rates (cost=0.00..24.58 rows=1,458 width=16) (actual time=0.010..9.358 rows=1,458 loops=1)

7. 21.256 54.823 ↑ 1.0 1,458 1

WindowAgg (cost=101.20..134.00 rows=1,458 width=28) (actual time=23.901..54.823 rows=1,458 loops=1)

8. 22.496 33.567 ↑ 1.0 1,458 1

Sort (cost=101.20..104.84 rows=1,458 width=20) (actual time=23.878..33.567 rows=1,458 loops=1)

  • Sort Key: exchange_rates_1.from_currency, exchange_rates_1.to_currency, exchange_rates_1.ts
  • Sort Method: quicksort Memory: 162kB
9. 11.071 11.071 ↑ 1.0 1,458 1

Seq Scan on exchange_rates exchange_rates_1 (cost=0.00..24.58 rows=1,458 width=20) (actual time=0.020..11.071 rows=1,458 loops=1)

10. 0.033 0.053 ↑ 1.0 1 1

Subquery Scan on *SELECT* 2 (cost=0.00..0.02 rows=1 width=112) (actual time=0.028..0.053 rows=1 loops=1)

11. 0.020 0.020 ↑ 1.0 1 1

Result (cost=0.00..0.01 rows=1 width=84) (actual time=0.008..0.020 rows=1 loops=1)

12. 10.083 39.411 ↓ 3.0 3 1

Hash Join (cost=0.15..41.14 rows=1 width=52) (actual time=20.056..39.411 rows=3 loops=1)

  • Hash Cond: (((er_1.from_currency)::text = (lr.from_currency)::text) AND ((er_1.to_currency)::text = (lr.to_currency)::text) AND (er_1.ts = lr.ts))
13. 9.532 9.532 ↑ 1.0 1,458 1

Seq Scan on exchange_rates er_1 (cost=0.00..24.58 rows=1,458 width=20) (actual time=0.022..9.532 rows=1,458 loops=1)

14. 0.046 19.796 ↑ 1.3 3 1

Hash (cost=0.08..0.08 rows=4 width=40) (actual time=19.790..19.796 rows=3 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
15. 19.750 19.750 ↑ 1.3 3 1

CTE Scan on last_rates lr (cost=0.00..0.08 rows=4 width=40) (actual time=19.688..19.750 rows=3 loops=1)

16. 12,367.712 13,089.490 ↑ 1.0 86,412 1

Hash Left Join (cost=32.94..1,817.46 rows=86,412 width=40) (actual time=143.811..13,089.490 rows=86,412 loops=1)

  • Hash Cond: ((tr.currency)::text = (er.from_currency)::text)
  • Join Filter: ((tr.ts >= er.start_ts) AND (tr.ts < er.end_ts))
  • Rows Removed by Join Filter: 62947342
17. 578.096 578.096 ↑ 1.0 86,412 1

Seq Scan on transactions tr (cost=0.00..1,415.12 rows=86,412 width=20) (actual time=0.017..578.096 rows=86,412 loops=1)

18. 10.322 143.682 ↓ 208.6 1,460 1

Hash (cost=32.85..32.85 rows=7 width=80) (actual time=143.676..143.682 rows=1,460 loops=1)

  • Buckets: 2048 (originally 1024) Batches: 1 (originally 1) Memory Usage: 102kB
19. 133.360 133.360 ↓ 208.6 1,460 1

CTE Scan on _ er (cost=0.00..32.85 rows=7 width=80) (actual time=23.939..133.360 rows=1,460 loops=1)

  • Filter: ((to_currency)::text = 'GBP'::text)
  • Rows Removed by Filter: 2
Planning time : 0.375 ms
Execution time : 13,810.141 ms