explain.depesz.com

PostgreSQL's explain analyze made readable

Result: TtS6

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

Sort (cost=2,640.68..2,640.84 rows=65 width=1,128) (actual rows= loops=)

  • Sort Key: "*SELECT* 1".ordem
2.          

CTE statustrabalhando

3. 0.000 0.000 ↓ 0.0

Hash Semi Join (cost=15.44..30.40 rows=7 width=4) (actual rows= loops=)

  • Hash Cond: ((sys_lookup.intkey)::text = (unnest(string_to_array("substring"((sys_var.varvalue)::text, 3), ','::text))))
4. 0.000 0.000 ↓ 0.0

Bitmap Heap Scan on sys_lookup (cost=4.39..19.21 rows=14 width=4) (actual rows= loops=)

  • Recheck Cond: ((grupo)::text = 'StatusDigitacao'::text)
5. 0.000 0.000 ↓ 0.0

Bitmap Index Scan on idxsyslookupgrupointkey (cost=0.00..4.38 rows=14 width=0) (actual rows= loops=)

  • Index Cond: ((grupo)::text = 'StatusDigitacao'::text)
6. 0.000 0.000 ↓ 0.0

Hash (cost=9.81..9.81 rows=100 width=32) (actual rows= loops=)

7. 0.000 0.000 ↓ 0.0

ProjectSet (cost=0.28..8.81 rows=100 width=32) (actual rows= loops=)

8. 0.000 0.000 ↓ 0.0

Index Scan using idxsysvarname on sys_var (cost=0.28..8.29 rows=1 width=9) (actual rows= loops=)

  • Index Cond: ((name)::text = '/Company/StatusDigitacaoReceptivoTrabalhando'::text)
9.          

CTE statusagendados

10. 0.000 0.000 ↓ 0.0

Hash Semi Join (cost=24.51..39.66 rows=4 width=4) (actual rows= loops=)

  • Hash Cond: ((sys_lookup_1.intkey)::text = (unnest(string_to_array("substring"((sys_var_2.varvalue)::text, 3), ','::text))))
11. 0.000 0.000 ↓ 0.0

Bitmap Heap Scan on sys_lookup sys_lookup_1 (cost=13.46..28.53 rows=8 width=4) (actual rows= loops=)

  • Recheck Cond: ((grupo)::text = 'StatusVisita'::text)
  • Filter: (NOT (hashed SubPlan 2))
12. 0.000 0.000 ↓ 0.0

Bitmap Index Scan on idxsyslookupgrupointkey (cost=0.00..4.40 rows=16 width=0) (actual rows= loops=)

  • Index Cond: ((grupo)::text = 'StatusVisita'::text)
13.          

SubPlan (forBitmap Heap Scan)

14. 0.000 0.000 ↓ 0.0

ProjectSet (cost=0.28..8.81 rows=100 width=32) (actual rows= loops=)

15. 0.000 0.000 ↓ 0.0

Index Scan using idxsysvarname on sys_var sys_var_1 (cost=0.28..8.29 rows=1 width=9) (actual rows= loops=)

  • Index Cond: ((name)::text = '/Company/StatusDigitacaoReceptivoDescartarAgendados'::text)
16. 0.000 0.000 ↓ 0.0

Hash (cost=9.81..9.81 rows=100 width=32) (actual rows= loops=)

17. 0.000 0.000 ↓ 0.0

ProjectSet (cost=0.28..8.81 rows=100 width=32) (actual rows= loops=)

18. 0.000 0.000 ↓ 0.0

Index Scan using idxsysvarname on sys_var sys_var_2 (cost=0.28..8.29 rows=1 width=9) (actual rows= loops=)

  • Index Cond: ((name)::text = '/Company/StatusDigitacaoReceptivoAgendados'::text)
19.          

CTE todos

20. 0.000 0.000 ↓ 0.0

Merge Right Join (cost=2,152.17..2,282.99 rows=2,504 width=828) (actual rows= loops=)

  • Merge Cond: ((visitanome.digitacao_id)::integer = (d.digitacao_id)::integer)
21. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=4.99..56,111.59 rows=77,463 width=46) (actual rows= loops=)

22. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=4.69..22,162.21 rows=77,463 width=27) (actual rows= loops=)

  • Join Filter: ((visitastatus.intkey)::integer = (visitanome.status)::smallint)
23. 0.000 0.000 ↓ 0.0

Index Scan using idxvisitadigitacao on cad_visita visitanome (cost=0.29..3,551.70 rows=77,463 width=10) (actual rows= loops=)

24. 0.000 0.000 ↓ 0.0

Materialize (cost=4.40..19.43 rows=16 width=21) (actual rows= loops=)

25. 0.000 0.000 ↓ 0.0

Bitmap Heap Scan on sys_lookup visitastatus (cost=4.40..19.35 rows=16 width=21) (actual rows= loops=)

  • Recheck Cond: ((grupo)::text = 'StatusVisita'::text)
26. 0.000 0.000 ↓ 0.0

Bitmap Index Scan on idxsyslookupgrupointkey (cost=0.00..4.40 rows=16 width=0) (actual rows= loops=)

  • Index Cond: ((grupo)::text = 'StatusVisita'::text)
27. 0.000 0.000 ↓ 0.0

Index Scan using pkpessoa on cad_pessoa pessoanome (cost=0.29..0.44 rows=1 width=27) (actual rows= loops=)

  • Index Cond: ((pessoa_id)::integer = (visitanome.pessoa_id)::integer)
28. 0.000 0.000 ↓ 0.0

Sort (cost=2,146.94..2,148.64 rows=682 width=756) (actual rows= loops=)

  • Sort Key: d.digitacao_id
29. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=1,301.36..2,114.84 rows=682 width=756) (actual rows= loops=)

  • Hash Cond: ((d.status)::smallint = (status.intkey)::integer)
30. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=1,281.98..2,081.79 rows=682 width=739) (actual rows= loops=)

  • Hash Cond: ((d.escolaridade)::smallint = (escolaridade.intkey)::integer)
31. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=1,263.51..2,053.08 rows=682 width=722) (actual rows= loops=)

  • Hash Cond: ((fonte.midia)::smallint = (midia.intkey)::integer)
32. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=1,233.51..1,959.83 rows=682 width=705) (actual rows= loops=)

  • Hash Cond: ((d.curso_id)::integer = (curso.curso_id)::integer)
33. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=1,219.91..1,944.43 rows=682 width=673) (actual rows= loops=)

34. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=1,219.62..1,411.81 rows=682 width=650) (actual rows= loops=)

  • Hash Cond: ((d.telemarketing_id)::integer = (telemarketing.pessoa_id)::integer)
35. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=1,213.06..1,401.72 rows=682 width=639) (actual rows= loops=)

  • Hash Cond: ((d.digitador_id)::integer = (digitador.account_id)::integer)
36. 0.000 0.000 ↓ 0.0

Nested Loop (cost=29.52..215.51 rows=682 width=616) (actual rows= loops=)

37. 0.000 0.000 ↓ 0.0

Hash Join (cost=29.24..54.61 rows=7 width=17) (actual rows= loops=)

  • Hash Cond: ((fonte.tipofonte)::smallint = (tipofonte.intkey)::integer)
38. 0.000 0.000 ↓ 0.0

Seq Scan on cad_fonte fonte (cost=0.00..24.62 rows=136 width=19) (actual rows= loops=)

  • Filter: ((ativo)::smallint = 1)
39. 0.000 0.000 ↓ 0.0

Hash (cost=29.21..29.21 rows=2 width=4) (actual rows= loops=)

40. 0.000 0.000 ↓ 0.0

Seq Scan on sys_lookup tipofonte (cost=0.00..29.21 rows=2 width=4) (actual rows= loops=)

  • Filter: ((descricao)::text = 'Campanhas'::text)
41. 0.000 0.000 ↓ 0.0

Index Scan using idxdigitacaofonte on cad_digitacao d (cost=0.29..20.72 rows=227 width=603) (actual rows= loops=)

  • Index Cond: ((fonte_id)::integer = (fonte.fonte_id)::integer)
42. 0.000 0.000 ↓ 0.0

Hash (cost=1,181.56..1,181.56 rows=158 width=27) (actual rows= loops=)

43. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=0.29..1,181.56 rows=158 width=27) (actual rows= loops=)

44. 0.000 0.000 ↓ 0.0

Seq Scan on sys_account digitador (cost=0.00..4.58 rows=158 width=8) (actual rows= loops=)

45. 0.000 0.000 ↓ 0.0

Index Scan using pkpessoa on cad_pessoa digitadorpessoa (cost=0.29..7.45 rows=1 width=27) (actual rows= loops=)

  • Index Cond: ((digitador.pessoa_id)::integer = (pessoa_id)::integer)
46. 0.000 0.000 ↓ 0.0

Hash (cost=4.58..4.58 rows=158 width=15) (actual rows= loops=)

47. 0.000 0.000 ↓ 0.0

Seq Scan on sys_account telemarketing (cost=0.00..4.58 rows=158 width=15) (actual rows= loops=)

48. 0.000 0.000 ↓ 0.0

Index Scan using pkpessoa on cad_pessoa pesquisador (cost=0.29..0.78 rows=1 width=27) (actual rows= loops=)

  • Index Cond: ((pessoa_id)::integer = (d.pesquisador_id)::integer)
49. 0.000 0.000 ↓ 0.0

Hash (cost=11.60..11.60 rows=160 width=36) (actual rows= loops=)

50. 0.000 0.000 ↓ 0.0

Seq Scan on col_curso curso (cost=0.00..11.60 rows=160 width=36) (actual rows= loops=)

51. 0.000 0.000 ↓ 0.0

Hash (cost=27.06..27.06 rows=236 width=23) (actual rows= loops=)

52. 0.000 0.000 ↓ 0.0

Bitmap Heap Scan on sys_lookup midia (cost=10.11..27.06 rows=236 width=23) (actual rows= loops=)

  • Recheck Cond: ((grupo)::text = 'Midia'::text)
53. 0.000 0.000 ↓ 0.0

Bitmap Index Scan on idxsyslookupgrupointkey (cost=0.00..10.05 rows=236 width=0) (actual rows= loops=)

  • Index Cond: ((grupo)::text = 'Midia'::text)
54. 0.000 0.000 ↓ 0.0

Hash (cost=18.34..18.34 rows=10 width=21) (actual rows= loops=)

55. 0.000 0.000 ↓ 0.0

Bitmap Heap Scan on sys_lookup escolaridade (cost=4.36..18.34 rows=10 width=21) (actual rows= loops=)

  • Recheck Cond: ((grupo)::text = 'Escolaridade'::text)
56. 0.000 0.000 ↓ 0.0

Bitmap Index Scan on idxsyslookupgrupointkey (cost=0.00..4.35 rows=10 width=0) (actual rows= loops=)

  • Index Cond: ((grupo)::text = 'Escolaridade'::text)
57. 0.000 0.000 ↓ 0.0

Hash (cost=19.21..19.21 rows=14 width=21) (actual rows= loops=)

58. 0.000 0.000 ↓ 0.0

Bitmap Heap Scan on sys_lookup status (cost=4.39..19.21 rows=14 width=21) (actual rows= loops=)

  • Recheck Cond: ((grupo)::text = 'StatusDigitacao'::text)
59. 0.000 0.000 ↓ 0.0

Bitmap Index Scan on idxsyslookupgrupointkey (cost=0.00..4.38 rows=14 width=0) (actual rows= loops=)

  • Index Cond: ((grupo)::text = 'StatusDigitacao'::text)
60.          

SubPlan (forMerge Right Join)

61. 0.000 0.000 ↓ 0.0

CTE Scan on statustrabalhando (cost=0.00..0.14 rows=7 width=4) (actual rows= loops=)

62. 0.000 0.000 ↓ 0.0

CTE Scan on statusagendados (cost=0.00..0.08 rows=4 width=4) (actual rows= loops=)

63.          

CTE naoatribuidos

64. 0.000 0.000 ↓ 0.0

CTE Scan on todos (cost=0.00..56.34 rows=13 width=1,164) (actual rows= loops=)

  • Filter: (fluxo = 'Não Atribuido'::text)
65.          

CTE atribuidos

66. 0.000 0.000 ↓ 0.0

CTE Scan on todos todos_1 (cost=0.00..56.34 rows=13 width=1,164) (actual rows= loops=)

  • Filter: (fluxo = 'Atribuido'::text)
67.          

CTE trabalhando

68. 0.000 0.000 ↓ 0.0

CTE Scan on todos todos_2 (cost=0.00..56.34 rows=13 width=1,164) (actual rows= loops=)

  • Filter: (fluxo = 'Trabalhando'::text)
69.          

CTE agendados

70. 0.000 0.000 ↓ 0.0

CTE Scan on todos todos_3 (cost=0.00..56.34 rows=13 width=1,164) (actual rows= loops=)

  • Filter: (fluxo = 'Agendados'::text)
71.          

CTE descartados

72. 0.000 0.000 ↓ 0.0

CTE Scan on todos todos_4 (cost=0.00..56.34 rows=13 width=1,164) (actual rows= loops=)

  • Filter: (fluxo = 'Descartados'::text)
73. 0.000 0.000 ↓ 0.0

Append (cost=1.80..3.98 rows=65 width=1,128) (actual rows= loops=)

74. 0.000 0.000 ↓ 0.0

Subquery Scan on *SELECT* 1 (cost=1.80..2.09 rows=13 width=1,128) (actual rows= loops=)

75. 0.000 0.000 ↓ 0.0

Subquery Scan on na (cost=1.80..1.96 rows=13 width=1,128) (actual rows= loops=)

76. 0.000 0.000 ↓ 0.0

Sort (cost=1.80..1.83 rows=13 width=1,160) (actual rows= loops=)

  • Sort Key: naoatribuidos.prioridade DESC, naoatribuidos.cadastro
77. 0.000 0.000 ↓ 0.0

CTE Scan on naoatribuidos (cost=0.00..1.56 rows=13 width=1,160) (actual rows= loops=)

78. 0.000 0.000 ↓ 0.0

Subquery Scan on *SELECT* 2 (cost=0.00..0.39 rows=13 width=1,128) (actual rows= loops=)

79. 0.000 0.000 ↓ 0.0

CTE Scan on atribuidos (cost=0.00..0.26 rows=13 width=1,128) (actual rows= loops=)

80. 0.000 0.000 ↓ 0.0

Subquery Scan on *SELECT* 3 (cost=0.00..0.39 rows=13 width=1,128) (actual rows= loops=)

81. 0.000 0.000 ↓ 0.0

CTE Scan on trabalhando (cost=0.00..0.26 rows=13 width=1,128) (actual rows= loops=)

82. 0.000 0.000 ↓ 0.0

Subquery Scan on *SELECT* 4 (cost=0.00..0.39 rows=13 width=1,128) (actual rows= loops=)

83. 0.000 0.000 ↓ 0.0

CTE Scan on agendados (cost=0.00..0.26 rows=13 width=1,128) (actual rows= loops=)

84. 0.000 0.000 ↓ 0.0

Subquery Scan on *SELECT* 5 (cost=0.00..0.39 rows=13 width=1,128) (actual rows= loops=)

85. 0.000 0.000 ↓ 0.0

CTE Scan on descartados (cost=0.00..0.26 rows=13 width=1,128) (actual rows= loops=)