explain.depesz.com

PostgreSQL's explain analyze made readable

Result: uYo8

Settings
# exclusive inclusive rows x rows loops node
1. 0.005 805.391 ↑ 1.0 2 1

Nested Loop Left Join (cost=50,011.09..50,027.44 rows=2 width=66) (actual time=805.259..805.391 rows=2 loops=1)

2. 0.127 805.362 ↑ 1.0 2 1

Limit (cost=50,010.81..50,010.82 rows=2 width=36) (actual time=805.236..805.362 rows=2 loops=1)

3. 1.616 805.235 ↑ 1,091.5 2 1

Sort (cost=50,010.81..50,016.27 rows=2,183 width=36) (actual time=805.235..805.235 rows=2 loops=1)

  • Sort Key: (sum(d.dispensaciones)) DESC
  • Sort Method: top-N heapsort Memory: 25kB
4. 11.499 803.619 ↑ 1.0 2,183 1

Finalize GroupAggregate (cost=49,918.04..49,988.98 rows=2,183 width=36) (actual time=790.602..803.619 rows=2,183 loops=1)

  • Group Key: d.id_medicamento
5. 5.143 792.120 ↓ 1.5 6,549 1

Sort (cost=49,918.04..49,928.95 rows=4,366 width=36) (actual time=790.587..792.120 rows=6,549 loops=1)

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

Gather (cost=49,190.18..49,654.07 rows=4,366 width=36) (actual time=775.082..786.977 rows=6,549 loops=1)

  • Workers Planned: 2
  • Workers Launched: 2
7. 243.668 775.574 ↑ 1.0 2,183 3 / 3

Partial HashAggregate (cost=48,190.18..48,217.47 rows=2,183 width=36) (actual time=773.025..775.574 rows=2,183 loops=3)

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

Parallel Seq Scan on dispensaciones_cache d (cost=0.00..46,386.66 rows=360,704 width=12) (actual time=133.595..531.906 rows=298,598 loops=3)

  • Filter: ((administraciond_normalizada >= 20,180,101) AND (administraciond_normalizada <= 20,181,231) AND (id_hospital = 290))
  • Rows Removed by Filter: 287,230
9. 0.024 0.024 ↑ 1.0 1 2

Index Scan using medicamentos_id on medicamentos m (cost=0.28..8.30 rows=1 width=34) (actual time=0.012..0.012 rows=1 loops=2)

  • Index Cond: (d.id_medicamento = id)
Planning time : 0.264 ms
Execution time : 806.638 ms