explain.depesz.com

PostgreSQL's explain analyze made readable

Result: D2Hd

Settings
# exclusive inclusive rows x rows loops node
1. 0.000 0.000 ↓ 0.0

Nested Loop (cost=1,586,453.77..3,020,070.46 rows=1 width=794) (actual rows= loops=)

  • Join Filter: (login.id_pessoa = pessoa.id_pessoa)
2. 0.000 0.000 ↓ 0.0

Index Scan using pk_login on login (cost=0.00..8.36 rows=1 width=197) (actual rows= loops=)

  • Index Cond: (id_login = 5357)
3. 0.000 0.000 ↓ 0.0

HashAggregate (cost=1,586,453.77..3,018,389.49 rows=74,338 width=533) (actual rows= loops=)

4.          

CTE unidade_relacionada

5. 0.000 0.000 ↓ 0.0

HashAggregate (cost=23.05..24.85 rows=180 width=8) (actual rows= loops=)

6. 0.000 0.000 ↓ 0.0

Append (cost=8.05..22.15 rows=180 width=8) (actual rows= loops=)

7. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=8.05..13.43 rows=90 width=8) (actual rows= loops=)

  • Hash Cond: (unidade_principal.id_unidade = COALESCE(unidade_relacionada.id_unidade_principal, unidade_relacionada.id_unidade))
8. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=4.03..8.16 rows=90 width=8) (actual rows= loops=)

  • Hash Cond: (COALESCE(senai.unidade.id_unidade_principal, senai.unidade.id_unidade) = unidade_principal.id_unidade)
9. 0.000 0.000 ↓ 0.0

Seq Scan on unidade (cost=0.00..2.90 rows=90 width=8) (actual rows= loops=)

10. 0.000 0.000 ↓ 0.0

Hash (cost=2.90..2.90 rows=90 width=4) (actual rows= loops=)

11. 0.000 0.000 ↓ 0.0

Seq Scan on unidade unidade_principal (cost=0.00..2.90 rows=90 width=4) (actual rows= loops=)

12. 0.000 0.000 ↓ 0.0

Hash (cost=2.90..2.90 rows=90 width=8) (actual rows= loops=)

13. 0.000 0.000 ↓ 0.0

Seq Scan on unidade unidade_relacionada (cost=0.00..2.90 rows=90 width=8) (actual rows= loops=)

14. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.00..6.93 rows=90 width=8) (actual rows= loops=)

15. 0.000 0.000 ↓ 0.0

Seq Scan on unidade unidade_gestao (cost=0.00..3.12 rows=1 width=4) (actual rows= loops=)

  • Filter: ((tipo)::text = 'Gestão'::text)
16. 0.000 0.000 ↓ 0.0

Seq Scan on unidade unidade_relacionada (cost=0.00..2.90 rows=90 width=4) (actual rows= loops=)

17.          

CTE unidade_regional

18. 0.000 0.000 ↓ 0.0

Hash Join (cost=2.69..5.52 rows=89 width=8) (actual rows= loops=)

  • Hash Cond: (lotacao.id_regional = regional_unidade.id_regional)
19. 0.000 0.000 ↓ 0.0

Seq Scan on regional_unidade lotacao (cost=0.00..1.75 rows=13 width=8) (actual rows= loops=)

  • Filter: lotacao
20. 0.000 0.000 ↓ 0.0

Hash (cost=1.75..1.75 rows=75 width=8) (actual rows= loops=)

21. 0.000 0.000 ↓ 0.0

Seq Scan on regional_unidade (cost=0.00..1.75 rows=75 width=8) (actual rows= loops=)

22. 0.000 0.000 ↓ 0.0

Hash Join (cost=100,569.00..1,583,821.56 rows=74,338 width=533) (actual rows= loops=)

  • Hash Cond: (colaborador.id_unidade = unidade_relacionada.id_unidade)
  • Join Filter: ((senai.unidade.id_unidade = unidade_relacionada.id_unidade_relacionada) OR (senai.unidade.id_unidade = unidade_colaborador.id_unidade) OR (senai.unidade.id_unidade = unidade_regional.id_unidade))
23. 0.000 0.000 ↓ 0.0

Hash Right Join (cost=100,154.99..101,513.52 rows=30,001 width=67) (actual rows= loops=)

  • Hash Cond: (unidade_colaborador.id_colaborador = colaborador.id_colaborador)
24. 0.000 0.000 ↓ 0.0

Seq Scan on unidade_colaborador (cost=0.00..646.01 rows=30,001 width=8) (actual rows= loops=)

25. 0.000 0.000 ↓ 0.0

Hash (cost=99,929.33..99,929.33 rows=18,053 width=63) (actual rows= loops=)

26. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=35,798.67..99,929.33 rows=18,053 width=63) (actual rows= loops=)

  • Hash Cond: (colaborador.id_unidade = unidade_regional.id_unidade_lotacao)
  • Join Filter: (alternatives: SubPlan 5 or hashed SubPlan 6)
27. 0.000 0.000 ↓ 0.0

Hash Join (cost=35,795.78..36,718.37 rows=18,053 width=63) (actual rows= loops=)

  • Hash Cond: (colaborador.id_pessoa = pessoa.id_pessoa)
28. 0.000 0.000 ↓ 0.0

Seq Scan on colaborador (cost=0.00..561.53 rows=18,053 width=20) (actual rows= loops=)

29. 0.000 0.000 ↓ 0.0

Hash (cost=26,184.79..26,184.79 rows=768,879 width=47) (actual rows= loops=)

30. 0.000 0.000 ↓ 0.0

Seq Scan on pessoa (cost=0.00..26,184.79 rows=768,879 width=47) (actual rows= loops=)

31. 0.000 0.000 ↓ 0.0

Hash (cost=1.78..1.78 rows=89 width=8) (actual rows= loops=)

32. 0.000 0.000 ↓ 0.0

CTE Scan on unidade_regional (cost=0.00..1.78 rows=89 width=8) (actual rows= loops=)

33.          

SubPlan (forHash Left Join)

34. 0.000 0.000 ↓ 0.0

Seq Scan on nucleo (cost=0.00..3.49 rows=1 width=0) (actual rows= loops=)

  • Filter: (compartilhado AND (id_nucleo = colaborador.id_nucleo))
35. 0.000 0.000 ↓ 0.0

Seq Scan on nucleo (cost=0.00..3.19 rows=1 width=4) (actual rows= loops=)

  • Filter: compartilhado
36. 0.000 0.000 ↓ 0.0

Hash (cost=211.51..211.51 rows=16,200 width=486) (actual rows= loops=)

37. 0.000 0.000 ↓ 0.0

Nested Loop (cost=1.04..211.51 rows=16,200 width=486) (actual rows= loops=)

38. 0.000 0.000 ↓ 0.0

CTE Scan on unidade_relacionada (cost=0.00..3.60 rows=180 width=8) (actual rows= loops=)

39. 0.000 0.000 ↓ 0.0

Materialize (cost=1.04..5.63 rows=90 width=478) (actual rows= loops=)

40. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=1.04..5.18 rows=90 width=478) (actual rows= loops=)

  • Hash Cond: (senai.unidade.id_entidade = entidade.id_entidade)
41. 0.000 0.000 ↓ 0.0

Seq Scan on unidade (cost=0.00..2.90 rows=90 width=64) (actual rows= loops=)

42. 0.000 0.000 ↓ 0.0

Hash (cost=1.02..1.02 rows=2 width=422) (actual rows= loops=)

43. 0.000 0.000 ↓ 0.0

Seq Scan on entidade (cost=0.00..1.02 rows=2 width=422) (actual rows= loops=)

44.          

SubPlan (forHash Join)

45. 0.000 0.000 ↓ 0.0

Aggregate (cost=7.38..7.39 rows=1 width=418) (actual rows= loops=)

46. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.00..6.88 rows=2 width=418) (actual rows= loops=)

  • Join Filter: (senai.negocio.id_negocio = senai.unidade_negocio.id_negocio)
47. 0.000 0.000 ↓ 0.0

Seq Scan on negocio (cost=0.00..1.05 rows=5 width=422) (actual rows= loops=)

48. 0.000 0.000 ↓ 0.0

Materialize (cost=0.00..5.69 rows=2 width=4) (actual rows= loops=)

49. 0.000 0.000 ↓ 0.0

Seq Scan on unidade_negocio (cost=0.00..5.68 rows=2 width=4) (actual rows= loops=)

  • Filter: (id_unidade = senai.unidade.id_unidade)
50. 0.000 0.000 ↓ 0.0

Aggregate (cost=11.85..11.86 rows=1 width=418) (actual rows= loops=)

51. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.00..11.60 rows=1 width=418) (actual rows= loops=)

  • Join Filter: (senai.negocio.id_negocio = senai.unidade_negocio.id_negocio)
52. 0.000 0.000 ↓ 0.0

Seq Scan on unidade_negocio (cost=0.00..10.49 rows=1 width=4) (actual rows= loops=)

  • Filter: ((id_unidade = senai.unidade.id_unidade) AND ((('now'::cstring)::date)::timestamp without time zone >= inicio) AND ((('now'::cstring)::date)::timestamp without time zone <= COALESCE((termino)::timestamp without time zone, 'infinity'::timestamp without time zone)))
53. 0.000 0.000 ↓ 0.0

Seq Scan on negocio (cost=0.00..1.05 rows=5 width=422) (actual rows= loops=)