explain.depesz.com

PostgreSQL's explain analyze made readable

Result: VsAX

Settings
# exclusive inclusive rows x rows loops node
1. 690.409 13,456.280 ↑ 1.0 1,001 1

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

  • Group Key: tr.user_id
2.          

CTE _

3. 19.015 114.140 ↓ 1.0 1,462 1

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

4.          

CTE last_rates

5. 10.544 20.073 ↑ 1.3 3 1

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

  • Group Key: exchange_rates.from_currency, exchange_rates.to_currency
6. 9.529 9.529 ↑ 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.529 rows=1,458 loops=1)

7. 21.024 55.030 ↑ 1.0 1,458 1

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

8. 22.617 34.006 ↑ 1.0 1,458 1

Sort (cost=101.20..104.84 rows=1,458 width=20) (actual time=24.204..34.006 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.389 11.389 ↑ 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.008..11.389 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.182 40.042 ↓ 3.0 3 1

Hash Join (cost=0.15..41.14 rows=1 width=52) (actual time=20.434..40.042 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.692 9.692 ↑ 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.692 rows=1,458 loops=1)

14. 0.040 20.168 ↑ 1.3 3 1

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

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

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

16. 12,058.311 12,765.871 ↑ 1.0 86,412 1

Hash Left Join (cost=32.94..1,817.46 rows=86,412 width=40) (actual time=144.874..12,765.871 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. 562.772 562.772 ↑ 1.0 86,412 1

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

18. 10.298 144.788 ↓ 208.6 1,460 1

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

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

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

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