explain.depesz.com

PostgreSQL's explain analyze made readable

Result: RIdw : Optimization for: plan #cjH6

Settings

Optimization path:

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 249.116 1,571.363 ↓ 54.6 22,514 1

HashAggregate (cost=574.55..578.67 rows=412 width=194) (actual time=1,549.804..1,571.363 rows=22,514 loops=1)

  • Group Key: e.id, e.historia, e.episodio, e.edad, e.sexo, e.grd, e.fullgrd, e.gravedad, e.servicio, e.fullservicio, e.circunstancia_alta, e.complejidad, e.ingreso, e.alta, e.reingreso, e.cronico, e.exitus, e.dias_estancia_totales, e.dias_estancia_uci, e.id_planta, e.coste_medio_esperado_alta_depurado, e.coste_farmacia_episodio
2. 59.975 1,322.247 ↓ 138.6 57,086 1

Nested Loop (cost=9.16..551.89 rows=412 width=194) (actual time=0.575..1,322.247 rows=57,086 loops=1)

3. 22.737 577.240 ↓ 137.9 57,086 1

Nested Loop (cost=8.74..307.62 rows=414 width=4) (actual time=0.555..577.240 rows=57,086 loops=1)

4. 2.641 4.319 ↓ 129.3 388 1

Hash Join (cost=8.31..140.19 rows=3 width=4) (actual time=0.501..4.319 rows=388 loops=1)

  • Hash Cond: ((pa.cod_atc)::text = (m.codigo)::text)
5. 1.645 1.645 ↑ 1.0 6,087 1

Seq Scan on prescripciones_atc pa (cost=0.00..115.87 rows=6,087 width=11) (actual time=0.023..1.645 rows=6,087 loops=1)

6. 0.002 0.033 ↑ 1.0 1 1

Hash (cost=8.30..8.30 rows=1 width=7) (actual time=0.033..0.033 rows=1 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
7. 0.031 0.031 ↑ 1.0 1 1

Index Scan using medicamentos_id on medicamentos m (cost=0.28..8.30 rows=1 width=7) (actual time=0.030..0.031 rows=1 loops=1)

  • Index Cond: (id = 24117)
8. 550.184 550.184 ↑ 1.0 147 388

Index Scan using unidosis_id_medicamento on unidosis_dispensacion_hospital u (cost=0.43..54.32 rows=149 width=8) (actual time=0.022..1.418 rows=147 loops=388)

  • Index Cond: (id_prescripcion = pa.id_prescripcion)
  • Filter: ((administracion >= '2018-01-01 00:00:00'::timestamp without time zone) AND (administracion <= '2018-12-31 23:59:59'::timestamp without time zone))
  • Rows Removed by Filter: 142
9. 685.032 685.032 ↑ 1.0 1 57,086

Index Scan using id_nf on episodios_cache_nf e (cost=0.42..0.58 rows=1 width=194) (actual time=0.009..0.012 rows=1 loops=57,086)

  • Index Cond: (id = u.id_episodio)
  • Filter: ((id_hospital = 290) AND (id_norma = 1))
  • Rows Removed by Filter: 4
Planning time : 4.933 ms
Execution time : 1,573.926 ms