explain.depesz.com

PostgreSQL's explain analyze made readable

Result: hOZC

Settings
# exclusive inclusive rows x rows loops node
1. 3.369 61,137.589 ↓ 2,259.0 2,259 1

Nested Loop Left Join (cost=467.01..17,911.01 rows=1 width=16) (actual time=44.422..61,137.589 rows=2,259 loops=1)

2.          

CTE agendados

3. 5.161 57.772 ↓ 2.6 6,890 1

Unique (cost=450.21..463.55 rows=2,659 width=22) (actual time=43.364..57.772 rows=6,890 loops=1)

4. 15.830 52.611 ↓ 3.2 8,413 1

Sort (cost=450.21..456.88 rows=2,669 width=22) (actual time=43.363..52.611 rows=8,413 loops=1)

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

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

  • Index Cond: (fec_agen = ('now'::cstring)::date)
  • Filter: (cod_pac <> '0'::double precision)
  • Rows Removed by Filter: 266
6. 7.168 60,633.856 ↓ 2,214.0 2,214 1

Nested Loop Anti Join (cost=2.17..17,438.33 rows=1 width=16) (actual time=44.010..60,633.856 rows=2,214 loops=1)

7. 2.343 60,375.828 ↓ 2,220.0 2,220 1

Nested Loop Anti Join (cost=1.73..17,432.49 rows=1 width=16) (actual time=43.832..60,375.828 rows=2,220 loops=1)

8. 20.410 60,036.239 ↓ 3,094.0 3,094 1

Nested Loop Left Join (cost=1.29..17,430.07 rows=1 width=16) (actual time=43.679..60,036.239 rows=3,094 loops=1)

  • Filter: ((cp.cod_pac IS NULL) OR (cd.folio_diag IS NULL))
  • Rows Removed by Filter: 16,600
9. 43.772 55,486.209 ↓ 7.4 19,694 1

Nested Loop Left Join (cost=0.86..14,695.05 rows=2,659 width=30) (actual time=43.670..55,486.209 rows=19,694 loops=1)

10. 10.503 198.417 ↓ 2.6 6,890 1

Nested Loop (cost=0.43..11,331.02 rows=2,659 width=16) (actual time=43.449..198.417 rows=6,890 loops=1)

11. 63.894 63.894 ↓ 2.6 6,890 1

CTE Scan on agendados ag (cost=0.00..53.18 rows=2,659 width=16) (actual time=43.370..63.894 rows=6,890 loops=1)

12. 124.020 124.020 ↑ 1.0 1 6,890

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

  • Index Cond: (cod_pac = ag.cod_pac)
  • Heap Fetches: 3,819
13. 55,244.020 55,244.020 ↓ 2.0 2 6,890

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

  • 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. 4,529.620 4,529.620 ↑ 1.0 1 19,694

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

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

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

  • 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. 250.860 250.860 ↓ 0.0 0 2,220

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

  • 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.192 500.364 ↓ 0.0 0 2,214

Nested Loop (cost=1.29..9.11 rows=1 width=6) (actual time=0.225..0.226 rows=0 loops=2,214)

18. 10.926 181.548 ↑ 3.0 1 2,214

Nested Loop (cost=0.86..5.35 rows=3 width=14) (actual time=0.048..0.082 rows=1 loops=2,214)

19. 15.498 15.498 ↑ 4.5 2 2,214

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

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

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

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

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

  • 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