explain.depesz.com

PostgreSQL's explain analyze made readable

Result: r0dN

Settings
# exclusive inclusive rows x rows loops node
1. 2.117 704.852 ↓ 2,260.0 2,260 1

Nested Loop Left Join (cost=467.01..17,911.02 rows=1 width=16) (actual time=22.885..704.852 rows=2,260 loops=1)

2.          

CTE agendados

3. 3.307 31.465 ↓ 2.6 6,891 1

Unique (cost=450.21..463.55 rows=2,659 width=22) (actual time=22.434..31.465 rows=6,891 loops=1)

4. 12.488 28.158 ↓ 3.2 8,421 1

Sort (cost=450.21..456.88 rows=2,669 width=22) (actual time=22.432..28.158 rows=8,421 loops=1)

  • Sort Key: agenda.cod_pac, agenda.ini_agen
  • Sort Method: quicksort Memory: 1,042kB
5. 15.670 15.670 ↓ 3.2 8,421 1

Index Scan using agenda_idx on agenda (cost=0.44..298.31 rows=2,669 width=22) (actual time=0.056..15.670 rows=8,421 loops=1)

  • Index Cond: (fec_agen = ('now'::cstring)::date)
  • Filter: (cod_pac <> '0'::double precision)
  • Rows Removed by Filter: 266
6. 6.106 622.995 ↓ 2,215.0 2,215 1

Nested Loop Anti Join (cost=2.17..17,438.35 rows=1 width=16) (actual time=22.709..622.995 rows=2,215 loops=1)

7. 0.793 561.364 ↓ 2,221.0 2,221 1

Nested Loop Anti Join (cost=1.73..17,432.51 rows=1 width=16) (actual time=22.613..561.364 rows=2,221 loops=1)

8. 16.890 461.531 ↓ 3,095.0 3,095 1

Nested Loop Left Join (cost=1.29..17,430.08 rows=1 width=16) (actual time=22.544..461.531 rows=3,095 loops=1)

  • Filter: ((cp.cod_pac IS NULL) OR (cd.folio_diag IS NULL))
  • Rows Removed by Filter: 16,600
9. 23.363 346.166 ↓ 7.4 19,695 1

Nested Loop Left Join (cost=0.86..14,695.05 rows=2,659 width=30) (actual time=22.541..346.166 rows=19,695 loops=1)

10. 5.062 88.509 ↓ 2.6 6,891 1

Nested Loop (cost=0.43..11,331.02 rows=2,659 width=16) (actual time=22.462..88.509 rows=6,891 loops=1)

11. 35.210 35.210 ↓ 2.6 6,891 1

CTE Scan on agendados ag (cost=0.00..53.18 rows=2,659 width=16) (actual time=22.438..35.210 rows=6,891 loops=1)

12. 48.237 48.237 ↑ 1.0 1 6,891

Index Only Scan using paciente_pkey on paciente pac (cost=0.43..4.23 rows=1 width=8) (actual time=0.007..0.007 rows=1 loops=6,891)

  • Index Cond: (cod_pac = ag.cod_pac)
  • Heap Fetches: 3,833
13. 234.294 234.294 ↓ 2.0 2 6,891

Index Scan using cabe_presu_idx1 on cabe_presu cp (cost=0.43..1.26 rows=1 width=14) (actual time=0.018..0.034 rows=2 loops=6,891)

  • 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: 4
14. 98.475 98.475 ↑ 1.0 1 19,695

Index Scan using cabe_diag_idx on cabe_diag cd (cost=0.43..1.02 rows=1 width=8) (actual time=0.005..0.005 rows=1 loops=19,695)

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

Index Scan using agenda_idx3 on agenda a (cost=0.43..2.15 rows=2 width=8) (actual time=0.032..0.032 rows=0 loops=3,095)

  • 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: 10
16. 55.525 55.525 ↓ 0.0 0 2,221

Index Scan using c_maestro_mov_idx1 on c_maestro_mov mov (cost=0.44..3.14 rows=1 width=6) (actual time=0.025..0.025 rows=0 loops=2,221)

  • 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: 5
17. 2.325 79.740 ↓ 0.0 0 2,215

Nested Loop (cost=1.29..9.11 rows=1 width=6) (actual time=0.035..0.036 rows=0 loops=2,215)

18. 5.945 46.515 ↑ 3.0 1 2,215

Nested Loop (cost=0.86..5.35 rows=3 width=14) (actual time=0.014..0.021 rows=1 loops=2,215)

19. 15.505 15.505 ↑ 4.5 2 2,215

Index Scan using cabe_presu_idx1 on cabe_presu cp_1 (cost=0.43..1.10 rows=9 width=14) (actual time=0.005..0.007 rows=2 loops=2,215)

  • Index Cond: (cod_pac = (pac.cod_pac)::numeric)
20. 25.065 25.065 ↓ 0.0 0 5,013

Index Scan using cabe_tratamiento_folio_presu_key on cabe_tratamiento ct (cost=0.43..0.46 rows=1 width=16) (actual time=0.005..0.005 rows=0 loops=5,013)

  • Index Cond: (folio_presu = cp_1.folio_presu)
21. 30.900 30.900 ↓ 0.0 0 2,060

Index Scan using deta_tratamiento_folio_trata_idx on deta_tratamiento dt (cost=0.43..1.24 rows=1 width=8) (actual time=0.015..0.015 rows=0 loops=2,060)

  • 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: 3