explain.depesz.com

PostgreSQL's explain analyze made readable

Result: x733 : Optimization for: Optimization for: Optimization for: Optimization for: plan #EfpZ; plan #1BwB; plan #X4wT; plan #Jenw

Settings

Optimization path:

# exclusive inclusive rows x rows loops node
1. 0.001 1.227 ↓ 0.0 0 1

Subquery Scan on totais_remessa_view (cost=53,614.33..610,628.16 rows=9,431 width=483) (actual time=1.227..1.227 rows=0 loops=1)

2. 0.002 1.226 ↓ 0.0 0 1

GroupAggregate (cost=53,614.33..610,533.85 rows=9,431 width=499) (actual time=1.226..1.226 rows=0 loops=1)

  • Group Key: remessa.id, justificativa.id, sistema_de_gestao.hospital_id, convenio.id, operadora.id, competencia.id, rpa.id
3. 0.010 1.224 ↓ 0.0 0 1

Sort (cost=53,614.33..53,637.91 rows=9,431 width=455) (actual time=1.224..1.224 rows=0 loops=1)

  • Sort Key: remessa.id, justificativa.id, sistema_de_gestao.hospital_id, convenio.id, operadora.id, competencia.id, rpa.id
  • Sort Method: quicksort Memory: 25kB
4. 0.001 1.214 ↓ 0.0 0 1

Hash Left Join (cost=305.44..52,991.73 rows=9,431 width=455) (actual time=1.214..1.214 rows=0 loops=1)

  • Hash Cond: ((convenio.convnome = rpa.nome_convenio) AND (remessa.rem_numero = rpa.numero_remessa))
5. 0.005 1.213 ↓ 0.0 0 1

Nested Loop (cost=289.94..52,926.72 rows=9,431 width=259) (actual time=1.213..1.213 rows=0 loops=1)

  • Join Filter: (remessa.sistema_de_gestao_id = sistema_de_gestao.id)
6. 0.462 0.462 ↑ 1.0 1 1

Seq Scan on sistema_de_gestao (cost=0.00..1.01 rows=1 width=16) (actual time=0.460..0.462 rows=1 loops=1)

7. 0.001 0.746 ↓ 0.0 0 1

Hash Left Join (cost=289.94..52,807.82 rows=9,431 width=251) (actual time=0.746..0.746 rows=0 loops=1)

  • Hash Cond: ((remessa.rem_numero = justificativa.numero_remessa) AND (remessa.sistema_de_gestao_id = justificativa.sistema_de_gestao_id))
8. 0.028 0.745 ↓ 0.0 0 1

Hash Join (cost=288.62..52,756.98 rows=9,431 width=179) (actual time=0.745..0.745 rows=0 loops=1)

  • Hash Cond: (remessa.operadora_id = operadora.id)
9. 0.001 0.351 ↓ 0.0 0 1

Hash Left Join (cost=286.54..52,727.97 rows=9,431 width=179) (actual time=0.350..0.351 rows=0 loops=1)

  • Hash Cond: (guia_convenio.recebimento_id = recebimento.id)
10. 0.001 0.350 ↓ 0.0 0 1

Nested Loop Left Join (cost=2.01..52,418.67 rows=9,431 width=183) (actual time=0.349..0.350 rows=0 loops=1)

11. 0.001 0.349 ↓ 0.0 0 1

Nested Loop Left Join (cost=1.58..48,050.60 rows=9,431 width=183) (actual time=0.349..0.349 rows=0 loops=1)

12. 0.000 0.348 ↓ 0.0 0 1

Nested Loop (cost=1.15..41,588.73 rows=9,431 width=167) (actual time=0.348..0.348 rows=0 loops=1)

13. 0.001 0.348 ↓ 0.0 0 1

Nested Loop (cost=0.72..795.95 rows=100 width=145) (actual time=0.348..0.348 rows=0 loops=1)

14. 0.001 0.347 ↓ 0.0 0 1

Nested Loop (cost=0.57..777.08 rows=100 width=128) (actual time=0.347..0.347 rows=0 loops=1)

15. 0.346 0.346 ↓ 0.0 0 1

Index Scan using fiboremessa_pkey on fiboremessa remessa (cost=0.29..559.33 rows=100 width=117) (actual time=0.346..0.346 rows=0 loops=1)

  • Index Cond: (id = ANY ('{1113686,901539,490170,872188,901678,489327,488820,488804,487946,487536,487524,484165,481353,480680,480676,479550,478814,478071,476987,476983,475563,475559,475149,473645,472342,472338,462938,462894,399488,517987,514770,514732,513898,513062,509552,509548,504868,504860,504675,504595,502275,502237,499797,499498,498668,498664,498457,498371,497998,497994,497990,520613,520094,509724,530914,520851,553276,530717,531138,545521,543946,545453,540386,530329,552170,549751,544039,544512,527613,546105,531225,534480,526483,543905,543929,526668,531678,534484,528846,526487,531674,526744,544792,544788,545427,531591,547866,544094,527609,2833225,2833253,2833149,2828923,2829019,2827457,2829015,2827014,2833001,2827010,2826261}'::bigint[]))
  • Filter: ((rem_numero IS NOT NULL) AND (sistema_de_gestao_id IS NOT NULL))
16. 0.000 0.000 ↓ 0.0 0

Index Scan using fibocompetencia_pkey on fibocompetencia competencia (cost=0.28..2.18 rows=1 width=19) (never executed)

  • Index Cond: (id = remessa.remcompetencia)
17. 0.000 0.000 ↓ 0.0 0

Index Scan using fiboconvenio_convnome_unique on fiboconvenio convenio (cost=0.14..0.19 rows=1 width=28) (never executed)

  • Index Cond: (convnome = competencia.comp_convenio)
18. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_fiboguia_guiremessa_idx on fiboguia guia_prestador (cost=0.43..406.60 rows=133 width=30) (never executed)

  • Index Cond: (guiremessa = remessa.id)
  • Filter: (discriminador <> 'RECURSO'::text)
19. 0.000 0.000 ↓ 0.0 0

Index Scan using fiboguia_pkey on fiboguia guia_convenio (cost=0.43..0.69 rows=1 width=24) (never executed)

  • Index Cond: (guia_prestador.guiguiaassoc = id)
20. 0.000 0.000 ↓ 0.0 0

Index Scan using fiboprotocolo_pkey on fiboprotocolo protocolo_convenio (cost=0.43..0.46 rows=1 width=16) (never executed)

  • Index Cond: (guia_convenio.guiprotocolo = id)
21. 0.000 0.000 ↓ 0.0 0

Hash (cost=213.68..213.68 rows=5,668 width=12) (never executed)

22. 0.000 0.000 ↓ 0.0 0

Seq Scan on recebimento (cost=0.00..213.68 rows=5,668 width=12) (never executed)

23. 0.028 0.366 ↑ 1.0 48 1

Hash (cost=1.48..1.48 rows=48 width=8) (actual time=0.366..0.366 rows=48 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 10kB
24. 0.338 0.338 ↑ 1.0 48 1

Seq Scan on fibooperadora operadora (cost=0.00..1.48 rows=48 width=8) (actual time=0.322..0.338 rows=48 loops=1)

25. 0.000 0.000 ↓ 0.0 0

Hash (cost=1.13..1.13 rows=13 width=112) (never executed)

26. 0.000 0.000 ↓ 0.0 0

Seq Scan on fibojustifdifvaloresfaturados justificativa (cost=0.00..1.13 rows=13 width=112) (never executed)

27. 0.000 0.000 ↓ 0.0 0

Hash (cost=12.20..12.20 rows=220 width=272) (never executed)

28. 0.000 0.000 ↓ 0.0 0

Seq Scan on detalhes_quitacao_rpa rpa (cost=0.00..12.20 rows=220 width=272) (never executed)

29.          

SubPlan (for GroupAggregate)

30. 0.000 0.000 ↓ 0.0 0

Aggregate (cost=8.30..8.31 rows=1 width=32) (never executed)

31. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_recebimento_remessa_remessa_id_idx on recebimento_remessa lancamentos_manuais_na_remessa (cost=0.28..8.29 rows=1 width=7) (never executed)

  • Index Cond: (remessa.id = remessa_id)
32. 0.000 0.000 ↓ 0.0 0

Index Only Scan using idx_recebimento_remessa_remessa_id_idx on recebimento_remessa lancamentos_manuais_na_remessa_1 (cost=0.28..8.29 rows=1 width=0) (never executed)

  • Index Cond: (remessa_id = remessa.id)
  • Heap Fetches: 0
33. 0.000 0.000 ↓ 0.0 0

Seq Scan on recebimento_remessa lancamentos_manuais_na_remessa_2 (cost=0.00..19.73 rows=873 width=8) (never executed)

34. 0.000 0.000 ↓ 0.0 0

Aggregate (cost=16.62..16.63 rows=1 width=32) (never executed)

35. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.56..16.61 rows=1 width=7) (never executed)

36. 0.000 0.000 ↓ 0.0 0

Index Scan using lancamento_remessa_remessa_id_fato_contabil_id_unique on lancamento_remessa lancamentos_acrescimos_na_remessa (cost=0.28..8.30 rows=1 width=15) (never executed)

  • Index Cond: (remessa.id = remessa_id)
37. 0.000 0.000 ↓ 0.0 0

Index Scan using fato_contabil_pkey on fato_contabil (cost=0.28..8.30 rows=1 width=8) (never executed)

  • Index Cond: (id = lancamentos_acrescimos_na_remessa.fato_contabil_id)
  • Filter: (tipo = 'Acrescimo'::text)
38. 0.000 0.000 ↓ 0.0 0

Aggregate (cost=16.66..16.67 rows=1 width=32) (never executed)

39. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.56..16.65 rows=1 width=7) (never executed)

40. 0.000 0.000 ↓ 0.0 0

Index Scan using lancamento_remessa_remessa_id_fato_contabil_id_unique on lancamento_remessa lancamentos_deducoes_na_remessa (cost=0.28..8.30 rows=1 width=15) (never executed)

  • Index Cond: (remessa.id = remessa_id)
41. 0.000 0.000 ↓ 0.0 0

Index Scan using fato_contabil_pkey on fato_contabil fato_contabil_1 (cost=0.28..8.30 rows=1 width=8) (never executed)

  • Index Cond: (id = lancamentos_deducoes_na_remessa.fato_contabil_id)
  • Filter: (tipo = 'Deducao'::text)
42. 0.000 0.000 ↓ 0.0 0

Index Only Scan using idx_lancamento_remessa_remessa_id_idx on lancamento_remessa lancamentos_fatos_contabeis_na_remessa (cost=0.28..8.30 rows=1 width=0) (never executed)

  • Index Cond: (remessa_id = remessa.id)
  • Heap Fetches: 0
43. 0.000 0.000 ↓ 0.0 0

Seq Scan on lancamento_remessa lancamentos_fatos_contabeis_na_remessa_1 (cost=0.00..77.82 rows=3,982 width=8) (never executed)

Planning time : 2,367.137 ms
Execution time : 1.884 ms