explain.depesz.com

PostgreSQL's explain analyze made readable

Result: oYOx

Settings
# exclusive inclusive rows x rows loops node
1. 0.057 1,571.041 ↓ 23.0 23 1

Nested Loop Left Join (cost=471.95..18,080.40 rows=1 width=16) (actual time=0.832..1,571.041 rows=23 loops=1)

2.          

CTE agendados

3. 0.092 0.522 ↑ 38.2 70 1

Unique (cost=455.07..468.49 rows=2,673 width=22) (actual time=0.327..0.522 rows=70 loops=1)

4. 0.165 0.430 ↑ 37.8 71 1

Sort (cost=455.07..461.78 rows=2,684 width=22) (actual time=0.326..0.430 rows=71 loops=1)

  • Sort Key: agenda.cod_pac, agenda.ini_agen
  • Sort Method: quicksort Memory: 30kB
5. 0.265 0.265 ↑ 37.8 71 1

Index Scan using agenda_idx on agenda (cost=0.44..302.22 rows=2,684 width=22) (actual time=0.034..0.265 rows=71 loops=1)

  • Index Cond: (fec_agen = ('now'::cstring)::date)
  • Filter: (cod_pac <> '0'::double precision)
  • Rows Removed by Filter: 13
6. 0.095 1,566.064 ↓ 20.0 20 1

Nested Loop Anti Join (cost=2.16..17,603.26 rows=1 width=16) (actual time=0.632..1,566.064 rows=20 loops=1)

7. 0.100 1,560.389 ↓ 20.0 20 1

Nested Loop Anti Join (cost=1.73..17,597.47 rows=1 width=16) (actual time=0.509..1,560.389 rows=20 loops=1)

8. 0.590 1,553.129 ↓ 40.0 40 1

Nested Loop Left Join (cost=1.29..17,594.90 rows=1 width=16) (actual time=0.438..1,553.129 rows=40 loops=1)

  • Filter: ((cp.cod_pac IS NULL) OR (cd.folio_diag IS NULL))
  • Rows Removed by Filter: 119
9. 0.734 1,262.682 ↑ 16.8 159 1

Nested Loop Left Join (cost=0.86..14,246.63 rows=2,673 width=30) (actual time=0.435..1,262.682 rows=159 loops=1)

10. 0.185 2.158 ↑ 38.2 70 1

Nested Loop (cost=0.43..10,969.67 rows=2,673 width=16) (actual time=0.364..2.158 rows=70 loops=1)

11. 0.643 0.643 ↑ 38.2 70 1

CTE Scan on agendados ag (cost=0.00..53.46 rows=2,673 width=16) (actual time=0.330..0.643 rows=70 loops=1)

12. 1.330 1.330 ↑ 1.0 1 70

Index Only Scan using paciente_pkey on paciente pac (cost=0.43..4.07 rows=1 width=8) (actual time=0.018..0.019 rows=1 loops=70)

  • Index Cond: (cod_pac = ag.cod_pac)
  • Heap Fetches: 0
13. 1,259.790 1,259.790 ↓ 2.0 2 70

Index Scan using cabe_presu_idx1 on cabe_presu cp (cost=0.43..1.22 rows=1 width=14) (actual time=10.010..17.997 rows=2 loops=70)

  • Index Cond: (cod_pac = (pac.cod_pac)::numeric)
  • Filter: ((fecha_presu < ('now'::cstring)::date) AND (fecha_presu > date_trunc('day'::text, (now() - '6 mons'::interval))))
  • Rows Removed by Filter: 8
14. 289.857 289.857 ↑ 1.0 1 159

Index Scan using cabe_diag_idx on cabe_diag cd (cost=0.43..1.24 rows=1 width=8) (actual time=1.823..1.823 rows=1 loops=159)

  • Index Cond: (folio_diag = cp.folio_diag)
  • Filter: (cod_esp <> '23'::numeric)
  • Rows Removed by Filter: 0
15. 7.160 7.160 ↓ 0.0 0 40

Index Scan using agenda_idx3 on agenda a (cost=0.43..2.12 rows=2 width=8) (actual time=0.179..0.179 rows=0 loops=40)

  • Index Cond: (cod_pac = pac.cod_pac)
  • Filter: ((cod_serv = '3'::double precision) AND (fec_agen < ('now'::cstring)::date) AND (fec_agen > date_trunc('day'::text, (now() - '6 mons'::interval))))
  • Rows Removed by Filter: 59
16. 5.580 5.580 ↓ 0.0 0 20

Index Scan using c_maestro_mov_idx1 on c_maestro_mov mov (cost=0.44..3.11 rows=1 width=6) (actual time=0.279..0.279 rows=0 loops=20)

  • Index Cond: (cod_pac = (pac.cod_pac)::numeric)
  • Filter: (((tipo_mov)::text = 'AC'::text) AND (activo = '1'::double precision) AND ((fecha_tra)::double precision < date_part('epoch'::text, (('now'::cstring)::date)::timestamp without time zone)) AND ((fecha_tra)::double precision > date_part('epoch'::text, date_trunc('day'::text, ((now())::date - '6 mons'::interval)))))
  • Rows Removed by Filter: 62
17. 0.056 4.920 ↓ 0.0 0 20

Nested Loop (cost=1.29..8.64 rows=1 width=6) (actual time=0.234..0.246 rows=0 loops=20)

18. 0.287 1.840 ↓ 2.0 6 20

Nested Loop (cost=0.86..4.87 rows=3 width=14) (actual time=0.030..0.092 rows=6 loops=20)

19. 0.320 0.320 ↑ 1.1 7 20

Index Scan using cabe_presu_idx1 on cabe_presu cp_1 (cost=0.43..1.08 rows=8 width=14) (actual time=0.009..0.016 rows=7 loops=20)

  • Index Cond: (cod_pac = (pac.cod_pac)::numeric)
20. 1.233 1.233 ↑ 1.0 1 137

Index Scan using cabe_tratamiento_folio_presu_key on cabe_tratamiento ct (cost=0.43..0.46 rows=1 width=16) (actual time=0.009..0.009 rows=1 loops=137)

  • Index Cond: (folio_presu = cp_1.folio_presu)
21. 3.024 3.024 ↓ 0.0 0 112

Index Scan using deta_tratamiento_folio_trata_idx on deta_tratamiento dt (cost=0.43..1.25 rows=1 width=8) (actual time=0.026..0.027 rows=0 loops=112)

  • Index Cond: (folio_trata = ct.folio_trata)
  • Filter: ((cod_sucursal > date_part('epoch'::text, date_trunc('day'::text, (now() - '6 mons'::interval)))) AND (cod_sucursal < date_part('epoch'::text, (('now'::cstring)::date)::timestamp without time zone)))
  • Rows Removed by Filter: 6
Planning time : 5.801 ms