explain.depesz.com

PostgreSQL's explain analyze made readable

Result: Ngyk

Settings
# exclusive inclusive rows x rows loops node
1. 703.441 13,596.063 ↑ 1.0 1,001 1

HashAggregate (cost=2,694.39..2,706.91 rows=1,001 width=36) (actual time=13,588.816..13,596.063 rows=1,001 loops=1)

  • Group Key: tr.user_id
2.          

CTE _

3. 18.656 109.568 ↓ 1.0 1,461 1

Append (cost=140.34..228.86 rows=1,459 width=112) (actual time=23.110..109.568 rows=1,461 loops=1)

4.          

CTE last_rates

5. 10.061 19.220 ↑ 1.3 3 1

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

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

7. 20.582 53.112 ↑ 1.0 1,457 1

WindowAgg (cost=104.78..137.56 rows=1,457 width=28) (actual time=23.096..53.112 rows=1,457 loops=1)

8. 20.965 32.530 ↑ 1.0 1,457 1

Sort (cost=104.78..108.42 rows=1,457 width=20) (actual time=23.074..32.530 rows=1,457 loops=1)

  • Sort Key: exchange_rates_1.from_currency, exchange_rates_1.ts
  • Sort Method: quicksort Memory: 162kB
9. 11.565 11.565 ↑ 1.0 1,457 1

Seq Scan on exchange_rates exchange_rates_1 (cost=0.00..28.23 rows=1,457 width=20) (actual time=0.017..11.565 rows=1,457 loops=1)

  • Filter: ((to_currency)::text = 'GBP'::text)
  • Rows Removed by Filter: 1
10. 0.030 0.049 ↑ 1.0 1 1

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

11. 0.019 0.019 ↑ 1.0 1 1

Result (cost=0.00..0.01 rows=1 width=84) (actual time=0.007..0.019 rows=1 loops=1)

12. 9.456 37.751 ↓ 3.0 3 1

Hash Join (cost=0.15..41.14 rows=1 width=52) (actual time=19.541..37.751 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. 8.995 8.995 ↑ 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.023..8.995 rows=1,458 loops=1)

14. 0.033 19.300 ↑ 1.3 3 1

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

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

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

16. 12,180.384 12,892.622 ↑ 1.0 86,412 1

Hash Left Join (cost=32.91..1,817.44 rows=86,412 width=40) (actual time=139.915..12,892.622 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. 572.431 572.431 ↑ 1.0 86,412 1

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

18. 9.967 139.807 ↓ 208.6 1,460 1

Hash (cost=32.83..32.83 rows=7 width=80) (actual time=139.801..139.807 rows=1,460 loops=1)

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

CTE Scan on _ er (cost=0.00..32.83 rows=7 width=80) (actual time=23.132..129.840 rows=1,460 loops=1)

  • Filter: ((to_currency)::text = 'GBP'::text)
  • Rows Removed by Filter: 1
Planning time : 0.454 ms
Execution time : 13,602.735 ms