explain.depesz.com

PostgreSQL's explain analyze made readable

Result: mWjY

Settings

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 0.022 1,030.119 ↑ 1.0 10 1

Nested Loop Left Join (cost=53,825.22..53,892.05 rows=10 width=42) (actual time=1,029.907..1,030.119 rows=10 loops=1)

2. 0.166 1,030.037 ↑ 1.0 10 1

Limit (cost=53,824.94..53,824.97 rows=10 width=12) (actual time=1,029.873..1,030.037 rows=10 loops=1)

3. 1.011 1,029.871 ↑ 218.3 10 1

Sort (cost=53,824.94..53,830.40 rows=2,183 width=12) (actual time=1,029.869..1,029.871 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: 25kB
4. 4.826 1,028.860 ↑ 1.0 2,183 1

Finalize GroupAggregate (cost=53,706.82..53,777.77 rows=2,183 width=12) (actual time=1,022.231..1,028.860 rows=2,183 loops=1)

  • Group Key: d.id_medicamento
5. 6.487 1,024.034 ↓ 1.5 6,549 1

Sort (cost=53,706.82..53,717.74 rows=4,366 width=16) (actual time=1,022.218..1,024.034 rows=6,549 loops=1)

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

Gather (cost=52,984.42..53,442.85 rows=4,366 width=16) (actual time=1,013.477..1,017.547 rows=6,549 loops=1)

  • Workers Planned: 2
  • Workers Launched: 2
7. 390.107 1,010.153 ↑ 1.0 2,183 3 / 3

Partial HashAggregate (cost=51,984.42..52,006.25 rows=2,183 width=16) (actual time=1,009.220..1,010.153 rows=2,183 loops=3)

  • Group Key: d.id_medicamento
8. 620.046 620.046 ↑ 1.2 298,598 3 / 3

Parallel Seq Scan on dispensaciones_cache d (cost=0.00..48,310.47 rows=367,395 width=16) (actual time=162.386..620.046 rows=298,598 loops=3)

  • Filter: ((administraciond_normalizada >= 20180101) AND (administraciond_normalizada <= 20181231) AND (id_hospital = 290))
  • Rows Removed by Filter: 287230
9. 0.060 0.060 ↑ 1.0 1 10

Index Scan using medicamentos_id on medicamentos m (cost=0.28..6.70 rows=1 width=34) (actual time=0.006..0.006 rows=1 loops=10)

  • Index Cond: (d.id_medicamento = id)
Planning time : 0.436 ms
Execution time : 1,030.268 ms