explain.depesz.com

PostgreSQL's explain analyze made readable

Result: wZIC : fn_migra_040_atendimento_agenda_V4

Settings

Optimization path:

# exclusive inclusive rows x rows loops node
1. 0.195 359.404 ↑ 1.0 600 1

Limit (cost=20,821.89..27,762.22 rows=600 width=164) (actual time=273.981..359.404 rows=600 loops=1)

2. 72.320 359.209 ↑ 33,868.6 600 1

Hash Left Join (cost=20,821.89..235,080,467.48 rows=20,321,189 width=164) (actual time=273.979..359.209 rows=600 loops=1)

  • Hash Cond: (b.numero_prontuario = (c.numero_prontuario)::numeric)
3. 10.184 13.472 ↑ 1,144.6 2,340 1

Nested Loop Left Join (cost=0.00..1,773,581.48 rows=2,678,448 width=75) (actual time=0.055..13.472 rows=2,340 loops=1)

  • Join Filter: ((sa.nome)::text = translate(translate((b.nome_setor)::text, ';./\¨-_*?,()[]{}@#$%"&'::text, ' '::text), 'áàãââÁÀÃÂéêÉÊíÍóõôÓÔÕúüÚÜçÇ'::text, 'aaaaaAAAAeeEEiIoooOOOuuUUcC'::text))
  • Rows Removed by Join Filter: 2340
4. 1.220 3.288 ↑ 1,144.6 2,340 1

Nested Loop Left Join (cost=0.00..1,720,011.51 rows=2,678,448 width=71) (actual time=0.039..3.288 rows=2,340 loops=1)

  • Join Filter: ((ta.descricao)::text = (b.tipo_atendimento)::text)
  • Rows Removed by Join Filter: 2340
5. 1.426 2.068 ↑ 1,144.6 2,340 1

Nested Loop Left Join (cost=0.00..1,679,833.78 rows=2,678,448 width=67) (actual time=0.028..2.068 rows=2,340 loops=1)

  • Join Filter: (ba.isn = b."ISN")
6. 0.642 0.642 ↑ 1,144.6 2,340 1

Seq Scan on tb_boletim_atendimento b (cost=0.00..72,754.48 rows=2,678,448 width=63) (actual time=0.019..0.642 rows=2,340 loops=1)

7. 0.000 0.000 ↓ 0.0 0 2,340

Materialize (cost=0.00..10.60 rows=40 width=8) (actual time=0.000..0.000 rows=0 loops=2,340)

8. 0.003 0.003 ↓ 0.0 0 1

Seq Scan on tb_boletim_atendimento ba (cost=0.00..10.40 rows=40 width=8) (actual time=0.003..0.003 rows=0 loops=1)

9. 0.000 0.000 ↑ 1.0 1 2,340

Materialize (cost=0.00..1.01 rows=1 width=222) (actual time=0.000..0.000 rows=1 loops=2,340)

10. 0.007 0.007 ↑ 1.0 1 1

Seq Scan on tb_tipo_atendimento ta (cost=0.00..1.01 rows=1 width=222) (actual time=0.006..0.007 rows=1 loops=1)

11. 0.000 0.000 ↑ 1.0 1 2,340

Materialize (cost=0.00..1.01 rows=1 width=222) (actual time=0.000..0.000 rows=1 loops=2,340)

12. 0.007 0.007 ↑ 1.0 1 1

Seq Scan on tb_setor_atendimento sa (cost=0.00..1.01 rows=1 width=222) (actual time=0.007..0.007 rows=1 loops=1)

13. 171.515 273.417 ↑ 1.0 340,084 1

Hash (cost=13,580.84..13,580.84 rows=340,084 width=42) (actual time=273.417..273.417 rows=340,084 loops=1)

  • Buckets: 65536 Batches: 8 Memory Usage: 3727kB
14. 101.902 101.902 ↑ 1.0 340,084 1

Seq Scan on tb_migra_controle c (cost=0.00..13,580.84 rows=340,084 width=42) (actual time=0.013..101.902 rows=340,084 loops=1)

Planning time : 1.562 ms
Execution time : 364.192 ms