explain.depesz.com

PostgreSQL's explain analyze made readable

Result: xYSf : teste

Settings

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 950.560 149,467.655 ↑ 1.0 1,001 1

GroupAggregate (cost=8,500.45..3,183,721.90 rows=1,001 width=36) (actual time=455.505..149,467.655 rows=1,001 loops=1)

  • Group Key: t.user_id
2. 423.031 583.175 ↑ 1.0 86,412 1

Sort (cost=8,500.45..8,716.48 rows=86,412 width=20) (actual time=397.804..583.175 rows=86,412 loops=1)

  • Sort Key: t.user_id
  • Sort Method: external merge Disk: 2864kB
3. 160.144 160.144 ↑ 1.0 86,412 1

Seq Scan on transactions t (cost=0.00..1,415.12 rows=86,412 width=20) (actual time=0.025..160.144 rows=86,412 loops=1)

4.          

SubPlan (forGroupAggregate)

5. 1,382.560 147,933.920 ↑ 1.0 1 86,410

Limit (cost=36.73..36.73 rows=1 width=12) (actual time=1.703..1.712 rows=1 loops=86,410)

6. 60,487.000 146,551.360 ↑ 243.0 1 86,410

Sort (cost=36.73..37.34 rows=243 width=12) (actual time=1.695..1.696 rows=1 loops=86,410)

  • Sort Key: e.ts DESC
  • Sort Method: top-N heapsort Memory: 25kB
7. 86,064.360 86,064.360 ↓ 1.5 367 86,410

Seq Scan on exchange_rates e (cost=0.00..35.52 rows=243 width=12) (actual time=0.009..0.996 rows=367 loops=86,410)

  • Filter: ((ts <= t.ts) AND ((from_currency)::text = (t.currency)::text) AND ((to_currency)::text = 'GBP'::text))
  • Rows Removed by Filter: 1091