explain.depesz.com

PostgreSQL's explain analyze made readable

Result: cjH6

Settings

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 81.391 1,829.690 ↓ 54.6 22,514 1

Unique (cost=569.79..593.48 rows=412 width=194) (actual time=1,562.858..1,829.690 rows=22,514 loops=1)

2. 405.144 1,748.299 ↓ 138.6 57,086 1

Sort (cost=569.79..570.82 rows=412 width=194) (actual time=1,562.857..1,748.299 rows=57,086 loops=1)

  • Sort Key: e.alta, 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.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
  • Sort Method: external merge Disk: 12008kB
3. 87.136 1,343.155 ↓ 138.6 57,086 1

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

4. 27.246 570.987 ↓ 137.9 57,086 1

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

5. 3.740 7.137 ↓ 129.3 388 1

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

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

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

7. 0.002 0.027 ↑ 1.0 1 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
8. 0.025 0.025 ↑ 1.0 1 1

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

  • Index Cond: (id = 24117)
9. 536.604 536.604 ↑ 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.024..1.383 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
10. 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.010..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 : 1.815 ms
Execution time : 1,835.656 ms