explain.depesz.com

PostgreSQL's explain analyze made readable

Result: wDLS : Optimization for: Optimization for: plan #mWjY; plan #IrtJ

Settings

Optimization path:

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 0.068 755.803 ↑ 1.0 10 1

Limit (cost=51,801.01..51,801.03 rows=10 width=42) (actual time=755.735..755.803 rows=10 loops=1)

2. 0.765 755.735 ↑ 218.3 10 1

Sort (cost=51,801.01..51,806.47 rows=2,183 width=42) (actual time=755.734..755.735 rows=10 loops=1)

  • Sort Key: ((sum((d.unidades_totales_administradas * d.coste_unidad_medicamento_mes)) / sum(d.unidades_totales_administradas))) DESC
  • Sort Method: top-N heapsort Memory: 26kB
3. 1.695 754.970 ↑ 1.0 2,183 1

Merge Join (cost=51,539.56..51,753.83 rows=2,183 width=42) (actual time=748.223..754.97 rows=2,183 loops=1)

4. 3.194 752.426 ↑ 1.0 2,183 1

Aggregate (cost=51,539.28..51,610.23 rows=2,183 width=12) (actual time=748.153..752.426 rows=2,183 loops=1)

5. 5.425 749.232 ↓ 1.5 6,549 1

Sort (cost=51,539.28..51,550.2 rows=4,366 width=16) (actual time=748.14..749.232 rows=6,549 loops=1)

  • Sort Key: d.id_medicamento
  • Sort Method: quicksort Memory: 704kB
6. 10.195 743.807 ↓ 1.5 6,549 1

Gather (cost=50,816.88..51,275.31 rows=4,366 width=16) (actual time=735.899..743.807 rows=6,549 loops=1)

  • Workers Planned: 2
  • Workers Launched: 2
7. 253.031 733.612 ↑ 1.0 2,183 3 / 3

Aggregate (cost=49,816.88..49,838.71 rows=2,183 width=16) (actual time=732.132..733.612 rows=2,183 loops=3)

8. 480.581 480.581 ↑ 1.2 291,715 3 / 3

Seq Scan on dispensaciones_cache d (cost=0..46,251.63 rows=356,525 width=16) (actual time=127.876..480.581 rows=291,715 loops=3)

  • Filter: ((administraciond_normalizada >= 20180101) AND (administraciond_normalizada <= 20181231) AND (id_hospital = 290))
9. 0.849 0.849 ↑ 1.0 2,183 1

Index Scan using medicamentos_id on medicamentos m (cost=0.28..89.03 rows=2,183 width=34) (actual time=0.066..0.849 rows=2,183 loops=1)

Planning time : 0.418 ms
Execution time : 755.902 ms