explain.depesz.com

PostgreSQL's explain analyze made readable

Result: P6dt : teste_vidal_pg12

Settings
# exclusive inclusive rows x rows loops node
1. 3.595 96.522 ↓ 12.0 12 1

Result (cost=3,769.38..4,104.43 rows=1 width=2,858) (actual time=92.669..96.522 rows=12 loops=1)

2.          

CTE with_ctrc_emitido

3. 0.376 34.753 ↓ 6.2 310 1

Nested Loop Left Join (cost=0.86..591.97 rows=50 width=4) (actual time=0.438..34.753 rows=310 loops=1)

  • Filter: CASE WHEN (cte_1.cd_ctrc IS NOT NULL) THEN (cte_1.id_ambiente = 1) ELSE true END
4. 28.487 28.487 ↓ 3.1 310 1

Index Scan using idx_ctrc_dt_emissao on ctrc ct_3 (cost=0.43..325.97 rows=100 width=4) (actual time=0.409..28.487 rows=310 loops=1)

  • Index Cond: ((dt_emissao >= '2020-06-22'::date) AND (dt_emissao <= '2020-06-22'::date))
  • Filter: ((dt_cancelamento IS NULL) AND (id_operacao = 1) AND (cd_pessoa_filial = 70,194))
  • Rows Removed by Filter: 1,913
5. 5.890 5.890 ↑ 1.0 1 310

Index Scan using pk_ctrc_cte on ctrc_cte cte_1 (cost=0.43..2.65 rows=1 width=6) (actual time=0.019..0.019 rows=1 loops=310)

  • Index Cond: (cd_ctrc = ct_3.cd_ctrc)
6. 0.226 90.863 ↓ 12.0 12 1

Sort (cost=3,177.41..3,177.42 rows=1 width=2,449) (actual time=90.859..90.863 rows=12 loops=1)

  • Sort Key: pr.nm_pessoa, ct.cd_pessoa_embarque, ct.dt_emissao, ct.nr_ctrc
  • Sort Method: quicksort Memory: 49kB
7. 0.397 90.637 ↓ 12.0 12 1

Nested Loop Left Join (cost=3,024.50..3,177.40 rows=1 width=2,449) (actual time=68.238..90.637 rows=12 loops=1)

8. 0.026 90.228 ↓ 12.0 12 1

Nested Loop Left Join (cost=3,024.07..3,176.64 rows=1 width=1,668) (actual time=68.079..90.228 rows=12 loops=1)

9. 0.031 90.190 ↓ 12.0 12 1

Nested Loop Left Join (cost=3,023.93..3,176.48 rows=1 width=1,648) (actual time=68.063..90.190 rows=12 loops=1)

10. 0.030 90.027 ↓ 12.0 12 1

Nested Loop Left Join (cost=3,023.50..3,175.97 rows=1 width=1,603) (actual time=68.033..90.027 rows=12 loops=1)

11. 0.025 89.985 ↓ 12.0 12 1

Nested Loop Left Join (cost=3,023.07..3,175.47 rows=1 width=1,597) (actual time=68.016..89.985 rows=12 loops=1)

12. 0.033 89.948 ↓ 12.0 12 1

Nested Loop Left Join (cost=3,022.94..3,175.23 rows=1 width=1,586) (actual time=68.002..89.948 rows=12 loops=1)

13. 0.033 89.903 ↓ 12.0 12 1

Nested Loop Left Join (cost=3,022.79..3,175.07 rows=1 width=1,573) (actual time=67.987..89.903 rows=12 loops=1)

14. 0.026 89.858 ↓ 12.0 12 1

Nested Loop Left Join (cost=3,022.65..3,174.91 rows=1 width=1,560) (actual time=67.972..89.858 rows=12 loops=1)

15. 0.037 89.808 ↓ 12.0 12 1

Nested Loop Left Join (cost=3,022.50..3,174.75 rows=1 width=1,547) (actual time=67.954..89.808 rows=12 loops=1)

16. 0.033 89.747 ↓ 12.0 12 1

Nested Loop Left Join (cost=3,022.36..3,174.58 rows=1 width=1,534) (actual time=67.931..89.747 rows=12 loops=1)

17. 0.030 89.702 ↓ 12.0 12 1

Nested Loop Left Join (cost=3,021.93..3,173.51 rows=1 width=1,531) (actual time=67.915..89.702 rows=12 loops=1)

18. 0.032 89.660 ↓ 12.0 12 1

Nested Loop Left Join (cost=3,021.51..3,172.70 rows=1 width=1,506) (actual time=67.899..89.660 rows=12 loops=1)

19. 0.037 89.604 ↓ 12.0 12 1

Nested Loop Left Join (cost=3,021.22..3,172.40 rows=1 width=1,490) (actual time=67.877..89.604 rows=12 loops=1)

20. 0.023 89.495 ↓ 12.0 12 1

Nested Loop Left Join (cost=3,020.80..3,171.96 rows=1 width=1,469) (actual time=67.848..89.495 rows=12 loops=1)

21. 0.029 89.460 ↓ 12.0 12 1

Nested Loop Left Join (cost=3,020.65..3,167.37 rows=1 width=1,437) (actual time=67.835..89.460 rows=12 loops=1)

22. 0.024 89.395 ↓ 12.0 12 1

Nested Loop Left Join (cost=3,020.53..3,167.21 rows=1 width=1,433) (actual time=67.809..89.395 rows=12 loops=1)

23. 0.039 89.323 ↓ 12.0 12 1

Nested Loop Left Join (cost=3,020.24..3,166.91 rows=1 width=1,421) (actual time=67.789..89.323 rows=12 loops=1)

24. 0.037 89.116 ↓ 12.0 12 1

Nested Loop Left Join (cost=3,019.81..3,166.45 rows=1 width=1,409) (actual time=67.753..89.116 rows=12 loops=1)

25. 0.041 88.911 ↓ 12.0 12 1

Nested Loop Left Join (cost=3,019.38..3,166.00 rows=1 width=1,397) (actual time=67.722..88.911 rows=12 loops=1)

26. 0.040 88.354 ↓ 12.0 12 1

Nested Loop Left Join (cost=3,019.23..3,159.36 rows=1 width=1,397) (actual time=67.599..88.354 rows=12 loops=1)

27. 0.087 88.194 ↓ 12.0 12 1

Nested Loop Left Join (cost=3,018.81..3,158.92 rows=1 width=1,391) (actual time=67.556..88.194 rows=12 loops=1)

  • Filter: ((hashed SubPlan 21) OR ((cc.vl_manifestador > '0'::numeric) AND (cc.cd_agencia_manifestador = 1)) OR ((cc.vl_agenciador > '0'::numeric) AND (cc.cd_agencia_agenciador = 1)) OR ((cc.vl_supervisor > '0'::numeric) AND (cc.cd_agencia_supervisor = 1)) OR ((cc.vl_gerente > '0'::numeric) AND (cc.cd_agencia_gerente = 1)) OR (hashed SubPlan 22))
28. 0.047 87.945 ↓ 12.0 12 1

Nested Loop Left Join (cost=3,014.42..3,154.46 rows=1 width=1,369) (actual time=67.474..87.945 rows=12 loops=1)

29. 0.036 87.862 ↓ 12.0 12 1

Nested Loop Left Join (cost=3,014.29..3,154.30 rows=1 width=1,363) (actual time=67.440..87.862 rows=12 loops=1)

30. 0.266 87.670 ↓ 12.0 12 1

Nested Loop Left Join (cost=3,013.86..3,153.85 rows=1 width=1,356) (actual time=67.404..87.670 rows=12 loops=1)

  • Join Filter: ("*SELECT* 1".cd_ctrc = ct.cd_ctrc)
  • Rows Removed by Join Filter: 3,637
31. 0.023 76.712 ↓ 12.0 12 1

Nested Loop Left Join (cost=2,716.83..2,855.20 rows=1 width=896) (actual time=57.994..76.712 rows=12 loops=1)

32. 0.028 76.653 ↓ 12.0 12 1

Nested Loop Left Join (cost=2,716.55..2,854.90 rows=1 width=890) (actual time=57.981..76.653 rows=12 loops=1)

33. 0.024 76.469 ↓ 12.0 12 1

Nested Loop Left Join (cost=2,716.12..2,854.44 rows=1 width=878) (actual time=57.946..76.469 rows=12 loops=1)

34. 0.026 76.409 ↓ 12.0 12 1

Nested Loop Left Join (cost=2,715.98..2,854.28 rows=1 width=865) (actual time=57.926..76.409 rows=12 loops=1)

35. 0.024 76.371 ↓ 12.0 12 1

Nested Loop Left Join (cost=2,715.56..2,853.84 rows=1 width=844) (actual time=57.915..76.371 rows=12 loops=1)

36. 0.027 76.335 ↓ 12.0 12 1

Nested Loop Left Join (cost=2,715.41..2,853.67 rows=1 width=831) (actual time=57.907..76.335 rows=12 loops=1)

37. 0.040 76.200 ↓ 12.0 12 1

Nested Loop Left Join (cost=2,714.98..2,853.20 rows=1 width=819) (actual time=57.898..76.200 rows=12 loops=1)

38. 0.024 76.124 ↓ 12.0 12 1

Nested Loop Left Join (cost=2,714.84..2,853.04 rows=1 width=816) (actual time=57.884..76.124 rows=12 loops=1)

39. 0.030 75.800 ↓ 12.0 12 1

Nested Loop Left Join (cost=2,714.42..2,852.60 rows=1 width=795) (actual time=57.847..75.800 rows=12 loops=1)

40. 0.017 75.746 ↓ 12.0 12 1

Nested Loop Left Join (cost=2,714.00..2,852.16 rows=1 width=770) (actual time=57.836..75.746 rows=12 loops=1)

41. 0.026 75.705 ↓ 12.0 12 1

Nested Loop Left Join (cost=2,713.85..2,852.00 rows=1 width=771) (actual time=57.823..75.705 rows=12 loops=1)

42. 0.021 75.655 ↓ 12.0 12 1

Nested Loop Left Join (cost=2,713.57..2,851.70 rows=1 width=759) (actual time=57.810..75.655 rows=12 loops=1)

43. 0.030 75.586 ↓ 12.0 12 1

Nested Loop Left Join (cost=2,713.15..2,851.25 rows=1 width=730) (actual time=57.795..75.586 rows=12 loops=1)

44. 0.025 75.532 ↓ 12.0 12 1

Nested Loop Left Join (cost=2,712.73..2,850.81 rows=1 width=701) (actual time=57.785..75.532 rows=12 loops=1)

45. 0.026 75.399 ↓ 12.0 12 1

Nested Loop Left Join (cost=2,712.30..2,850.37 rows=1 width=672) (actual time=57.771..75.399 rows=12 loops=1)

46. 0.031 75.121 ↓ 12.0 12 1

Nested Loop Left Join (cost=2,711.88..2,849.89 rows=1 width=647) (actual time=57.731..75.121 rows=12 loops=1)

47. 0.043 74.838 ↓ 12.0 12 1

Nested Loop Left Join (cost=2,711.46..2,849.45 rows=1 width=647) (actual time=57.677..74.838 rows=12 loops=1)

48. 0.028 74.699 ↓ 12.0 12 1

Nested Loop Left Join (cost=2,711.04..2,849.01 rows=1 width=607) (actual time=57.632..74.699 rows=12 loops=1)

  • Join Filter: (ct_2.nr_embarque = ct.nr_embarque)
  • Rows Removed by Join Filter: 45
49. 0.026 66.871 ↓ 12.0 12 1

Nested Loop (cost=2,577.29..2,713.39 rows=1 width=543) (actual time=49.871..66.871 rows=12 loops=1)

50. 0.024 66.809 ↓ 12.0 12 1

Nested Loop (cost=2,576.86..2,712.93 rows=1 width=516) (actual time=49.859..66.809 rows=12 loops=1)

51. 0.018 66.773 ↓ 12.0 12 1

Nested Loop (cost=2,576.72..2,712.77 rows=1 width=517) (actual time=49.849..66.773 rows=12 loops=1)

52. 0.022 66.731 ↓ 12.0 12 1

Nested Loop (cost=2,576.43..2,712.47 rows=1 width=505) (actual time=49.838..66.731 rows=12 loops=1)

53. 0.015 66.697 ↓ 12.0 12 1

Nested Loop (cost=2,576.29..2,712.31 rows=1 width=506) (actual time=49.829..66.697 rows=12 loops=1)

54. 0.024 66.658 ↓ 12.0 12 1

Nested Loop (cost=2,576.01..2,712.01 rows=1 width=494) (actual time=49.820..66.658 rows=12 loops=1)

55. 0.023 66.622 ↓ 12.0 12 1

Nested Loop (cost=2,575.87..2,711.85 rows=1 width=495) (actual time=49.810..66.622 rows=12 loops=1)

56. 0.024 66.575 ↓ 12.0 12 1

Nested Loop (cost=2,575.58..2,710.17 rows=1 width=483) (actual time=49.800..66.575 rows=12 loops=1)

57. 0.028 66.539 ↓ 12.0 12 1

Nested Loop (cost=2,575.44..2,710.01 rows=1 width=480) (actual time=49.791..66.539 rows=12 loops=1)

58. 0.029 66.487 ↓ 12.0 12 1

Nested Loop (cost=2,575.16..2,709.71 rows=1 width=464) (actual time=49.780..66.487 rows=12 loops=1)

59. 0.027 66.434 ↓ 12.0 12 1

Nested Loop (cost=2,575.02..2,709.55 rows=1 width=461) (actual time=49.768..66.434 rows=12 loops=1)

60. 0.013 66.347 ↓ 12.0 12 1

Nested Loop (cost=2,574.73..2,709.25 rows=1 width=445) (actual time=49.749..66.347 rows=12 loops=1)

61. 0.189 64.784 ↓ 310.0 310 1

Nested Loop (cost=2,574.31..2,708.80 rows=1 width=420) (actual time=44.818..64.784 rows=310 loops=1)

62. 0.360 63.045 ↓ 310.0 310 1

Nested Loop (cost=2,574.02..2,708.49 rows=1 width=416) (actual time=44.790..63.045 rows=310 loops=1)

63. 0.332 61.135 ↓ 310.0 310 1

Nested Loop (cost=2,573.60..2,708.05 rows=1 width=387) (actual time=44.761..61.135 rows=310 loops=1)

64. 0.297 58.943 ↓ 310.0 310 1

Nested Loop (cost=2,573.17..2,707.60 rows=1 width=354) (actual time=44.738..58.943 rows=310 loops=1)

65. 0.163 57.406 ↓ 310.0 310 1

Nested Loop (cost=2,572.75..2,707.16 rows=1 width=329) (actual time=44.714..57.406 rows=310 loops=1)

  • Join Filter: (pgeg.cd_pessoa = p_1.cd_pessoa)
  • Rows Removed by Join Filter: 1,550
66. 0.097 56.933 ↓ 310.0 310 1

Nested Loop (cost=2,555.68..2,689.94 rows=1 width=301) (actual time=44.658..56.933 rows=310 loops=1)

67. 0.258 55.906 ↓ 310.0 310 1

Nested Loop (cost=2,555.54..2,689.36 rows=1 width=305) (actual time=44.612..55.906 rows=310 loops=1)

68. 1.147 55.338 ↓ 310.0 310 1

Nested Loop (cost=2,555.41..2,689.21 rows=1 width=301) (actual time=44.588..55.338 rows=310 loops=1)

  • Join Filter: (ct.cd_pessoa_filial = p.cd_pessoa)
  • Rows Removed by Join Filter: 9,300
69. 0.442 41.791 ↓ 310.0 310 1

Nested Loop (cost=5.68..138.72 rows=1 width=265) (actual time=35.111..41.791 rows=310 loops=1)

  • Join Filter: (wce_1.cd_ctrc = ct_1.cd_ctrc)
70. 0.454 40.109 ↓ 310.0 310 1

Nested Loop (cost=5.25..138.20 rows=1 width=255) (actual time=35.097..40.109 rows=310 loops=1)

71. 0.153 35.315 ↓ 6.2 310 1

Merge Join (cost=4.82..5.82 rows=50 width=8) (actual time=35.068..35.315 rows=310 loops=1)

  • Merge Cond: (wce.cd_ctrc = wce_1.cd_ctrc)
72. 0.149 35.012 ↓ 6.2 310 1

Sort (cost=2.41..2.54 rows=50 width=4) (actual time=34.965..35.012 rows=310 loops=1)

  • Sort Key: wce.cd_ctrc
  • Sort Method: quicksort Memory: 39kB
73. 34.863 34.863 ↓ 6.2 310 1

CTE Scan on with_ctrc_emitido wce (cost=0.00..1.00 rows=50 width=4) (actual time=0.440..34.863 rows=310 loops=1)

74. 0.122 0.150 ↓ 6.2 310 1

Sort (cost=2.41..2.54 rows=50 width=4) (actual time=0.098..0.150 rows=310 loops=1)

  • Sort Key: wce_1.cd_ctrc
  • Sort Method: quicksort Memory: 39kB
75. 0.028 0.028 ↓ 6.2 310 1

CTE Scan on with_ctrc_emitido wce_1 (cost=0.00..1.00 rows=50 width=4) (actual time=0.001..0.028 rows=310 loops=1)

76. 4.340 4.340 ↑ 1.0 1 310

Index Scan using pk_ctrc on ctrc ct (cost=0.43..2.65 rows=1 width=247) (actual time=0.014..0.014 rows=1 loops=310)

  • Index Cond: (cd_ctrc = wce_1.cd_ctrc)
77. 1.240 1.240 ↑ 1.0 1 310

Index Scan using pk_ctrc on ctrc ct_1 (cost=0.43..0.51 rows=1 width=22) (actual time=0.004..0.004 rows=1 loops=310)

  • Index Cond: (cd_ctrc = ct.cd_ctrc)
78. 2.480 12.400 ↓ 1.7 31 310

Unique (cost=2,549.73..2,550.09 rows=18 width=126) (actual time=0.031..0.040 rows=31 loops=310)

79. 0.515 9.920 ↓ 1.7 31 310

Sort (cost=2,549.73..2,549.77 rows=18 width=126) (actual time=0.031..0.032 rows=31 loops=310)

  • Sort Key: (COALESCE(p.nm_fantasia, p.nm_pessoa)), p.cd_pessoa, p.cd_cidade, (((ci.nm_cidade || ' / '::text) || (uf.ds_sigla)::text)), ((COALESCE(pj.nr_cnpj, pf.nr_cpf))::character varying(14)), (COALESCE(substr((pj.nr_cnpj)::text, 1, 8), (pf.nr_cpf)::text)), (COALESCE((SubPlan 23), f.cd_pessoa_matriz))
  • Sort Method: quicksort Memory: 29kB
80. 0.073 9.405 ↓ 1.7 31 1

Nested Loop (cost=3.94..2,549.35 rows=18 width=126) (actual time=1.195..9.405 rows=31 loops=1)

81. 0.034 0.559 ↓ 1.7 31 1

Nested Loop (cost=3.79..150.73 rows=18 width=90) (actual time=0.152..0.559 rows=31 loops=1)

82. 0.040 0.401 ↓ 1.7 31 1

Nested Loop (cost=3.51..145.33 rows=18 width=74) (actual time=0.136..0.401 rows=31 loops=1)

83. 0.028 0.299 ↓ 1.7 31 1

Hash Left Join (cost=3.09..97.81 rows=18 width=35) (actual time=0.108..0.299 rows=31 loops=1)

  • Hash Cond: (f.cd_pessoa_matriz = pg.cd_empresa)
84. 0.011 0.259 ↓ 1.7 31 1

Nested Loop Left Join (cost=2.06..96.70 rows=18 width=35) (actual time=0.080..0.259 rows=31 loops=1)

85. 0.032 0.186 ↓ 1.7 31 1

Nested Loop Left Join (cost=1.64..49.18 rows=18 width=23) (actual time=0.064..0.186 rows=31 loops=1)

86. 0.033 0.061 ↓ 1.7 31 1

Hash Join (cost=1.22..2.82 rows=18 width=8) (actual time=0.040..0.061 rows=31 loops=1)

  • Hash Cond: (f.cd_pessoa_matriz = eg.cd_pessoa)
87. 0.016 0.016 ↑ 1.0 37 1

Seq Scan on filial f (cost=0.00..1.46 rows=37 width=8) (actual time=0.010..0.016 rows=37 loops=1)

  • Filter: (id_ativo = 1)
88. 0.005 0.012 ↑ 1.0 6 1

Hash (cost=1.15..1.15 rows=6 width=4) (actual time=0.011..0.012 rows=6 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
89. 0.007 0.007 ↑ 1.0 6 1

Seq Scan on empresa_grupo eg (cost=0.00..1.15 rows=6 width=4) (actual time=0.006..0.007 rows=6 loops=1)

  • Filter: (id_ativo = 1)
  • Rows Removed by Filter: 6
90. 0.093 0.093 ↑ 1.0 1 31

Index Scan using pk_pessoa_juridica on pessoa_juridica pj (cost=0.42..2.58 rows=1 width=19) (actual time=0.003..0.003 rows=1 loops=31)

  • Index Cond: (cd_pessoa = f.cd_pessoa_filial)
  • Filter: (nr_cnpj IS NOT NULL)
91. 0.062 0.062 ↓ 0.0 0 31

Index Scan using pk_pessoa_fisica on pessoa_fisica pf (cost=0.42..2.64 rows=1 width=16) (actual time=0.002..0.002 rows=0 loops=31)

  • Index Cond: (cd_pessoa = f.cd_pessoa_filial)
  • Filter: (nr_cpf IS NOT NULL)
92. 0.002 0.012 ↑ 1.0 1 1

Hash (cost=1.01..1.01 rows=1 width=4) (actual time=0.012..0.012 rows=1 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
93. 0.010 0.010 ↑ 1.0 1 1

Seq Scan on parametro_geral pg (cost=0.00..1.01 rows=1 width=4) (actual time=0.009..0.010 rows=1 loops=1)

94. 0.062 0.062 ↑ 1.0 1 31

Index Scan using pk_pessoa on pessoa p (cost=0.42..2.64 rows=1 width=43) (actual time=0.002..0.002 rows=1 loops=31)

  • Index Cond: (cd_pessoa = f.cd_pessoa_filial)
95. 0.124 0.124 ↑ 1.0 1 31

Index Scan using pk_cidade on cidade ci (cost=0.28..0.30 rows=1 width=20) (actual time=0.004..0.004 rows=1 loops=31)

  • Index Cond: (cd_cidade = p.cd_cidade)
96. 0.031 0.031 ↑ 1.0 1 31

Index Scan using pk_uf on uf (cost=0.14..0.16 rows=1 width=7) (actual time=0.001..0.001 rows=1 loops=31)

  • Index Cond: (cd_uf = ci.cd_uf)
97.          

SubPlan (for Nested Loop)

98. 0.031 8.742 ↑ 1.0 1 31

Limit (cost=133.07..133.08 rows=1 width=4) (actual time=0.282..0.282 rows=1 loops=31)

99. 0.000 8.711 ↑ 1.0 1 31

Unique (cost=133.07..133.08 rows=1 width=4) (actual time=0.281..0.281 rows=1 loops=31)

100. 0.093 8.711 ↑ 1.0 1 31

Sort (cost=133.07..133.07 rows=1 width=4) (actual time=0.281..0.281 rows=1 loops=31)

  • Sort Key: p_1_4.cd_pessoa
  • Sort Method: quicksort Memory: 25kB
101. 0.837 8.618 ↑ 1.0 1 31

Nested Loop Left Join (cost=1.26..133.06 rows=1 width=4) (actual time=0.054..0.278 rows=1 loops=31)

  • Filter: ((substr((pjm_3.nr_cnpj)::text, 1, 12) = (substr((pj.nr_cnpj)::text, 1, 8) || '0001'::text)) OR (pfm_3.nr_cpf = pf.nr_cpf))
  • Rows Removed by Filter: 36
102. 0.093 5.487 ↑ 1.0 37 31

Nested Loop Left Join (cost=0.84..115.84 rows=37 width=16) (actual time=0.007..0.177 rows=37 loops=31)

103. 0.682 3.100 ↑ 1.0 37 31

Nested Loop (cost=0.42..99.05 rows=37 width=4) (actual time=0.005..0.100 rows=37 loops=31)

104. 0.124 0.124 ↑ 1.0 37 31

Seq Scan on filial f_1_3 (cost=0.00..1.37 rows=37 width=4) (actual time=0.001..0.004 rows=37 loops=31)

105. 2.294 2.294 ↑ 1.0 1 1,147

Index Only Scan using pk_pessoa on pessoa p_1_4 (cost=0.42..2.64 rows=1 width=4) (actual time=0.002..0.002 rows=1 loops=1,147)

  • Index Cond: (cd_pessoa = f_1_3.cd_pessoa_filial)
  • Heap Fetches: 1,147
106. 2.294 2.294 ↓ 0.0 0 1,147

Index Scan using pk_pessoa_fisica on pessoa_fisica pfm_3 (cost=0.42..0.45 rows=1 width=16) (actual time=0.002..0.002 rows=0 loops=1,147)

  • Index Cond: (cd_pessoa = p_1_4.cd_pessoa)
  • Filter: (nr_cpf IS NOT NULL)
107. 2.294 2.294 ↑ 1.0 1 1,147

Index Scan using pk_pessoa_juridica on pessoa_juridica pjm_3 (cost=0.42..0.44 rows=1 width=19) (actual time=0.002..0.002 rows=1 loops=1,147)

  • Index Cond: (cd_pessoa = p_1_4.cd_pessoa)
  • Filter: (nr_cnpj IS NOT NULL)
108. 0.310 0.310 ↑ 1.0 1 310

Index Only Scan using pk_parametro_empresa_grupo on parametro_empresa_grupo pgeg (cost=0.13..0.15 rows=1 width=4) (actual time=0.001..0.001 rows=1 loops=310)

  • Index Cond: (cd_pessoa = ct.cd_pessoa_matriz)
  • Heap Fetches: 310
109. 0.930 0.930 ↑ 1.0 1 310

Index Only Scan using pk_parametro_filial on parametro_filial pgf (cost=0.14..0.57 rows=1 width=4) (actual time=0.002..0.003 rows=1 loops=310)

  • Index Cond: (cd_pessoa_filial = ct.cd_pessoa_filial)
  • Heap Fetches: 930
110. 0.280 0.310 ↑ 1.0 6 310

Sort (cost=17.07..17.08 rows=6 width=36) (actual time=0.000..0.001 rows=6 loops=310)

  • Sort Key: (COALESCE(p_1.nm_fantasia, p_1.nm_pessoa))
  • Sort Method: quicksort Memory: 25kB
111. 0.005 0.030 ↑ 1.0 6 1

Nested Loop (cost=0.42..16.99 rows=6 width=36) (actual time=0.016..0.030 rows=6 loops=1)

112. 0.007 0.007 ↑ 1.0 6 1

Seq Scan on empresa_grupo eg_1 (cost=0.00..1.15 rows=6 width=4) (actual time=0.006..0.007 rows=6 loops=1)

  • Filter: (id_ativo = 1)
  • Rows Removed by Filter: 6
113. 0.018 0.018 ↑ 1.0 1 6

Index Scan using pk_pessoa on pessoa p_1 (cost=0.42..2.64 rows=1 width=39) (actual time=0.003..0.003 rows=1 loops=6)

  • Index Cond: (cd_pessoa = eg_1.cd_pessoa)
114. 1.240 1.240 ↑ 1.0 1 310

Index Scan using pk_pessoa on pessoa pu (cost=0.42..0.44 rows=1 width=29) (actual time=0.004..0.004 rows=1 loops=310)

  • Index Cond: (cd_pessoa = ct.cd_pessoa_usuario)
115. 1.860 1.860 ↑ 1.0 1 310

Index Scan using pk_pessoa on pessoa pr (cost=0.42..0.44 rows=1 width=33) (actual time=0.006..0.006 rows=1 loops=310)

  • Index Cond: (cd_pessoa = ct.cd_pessoa_embarque)
116. 1.550 1.550 ↑ 1.0 1 310

Index Scan using pk_pessoa on pessoa pd (cost=0.42..0.44 rows=1 width=33) (actual time=0.005..0.005 rows=1 loops=310)

  • Index Cond: (cd_pessoa = ct.cd_pessoa_entrega)
117. 1.550 1.550 ↑ 1.0 1 310

Index Only Scan using pk_cliente on cliente cl (cost=0.29..0.31 rows=1 width=4) (actual time=0.005..0.005 rows=1 loops=310)

  • Index Cond: (cd_pessoa = ct.cd_pessoa_pagador)
  • Heap Fetches: 1,523
118. 1.550 1.550 ↓ 0.0 0 310

Index Scan using pk_pessoa on pessoa pag (cost=0.42..0.45 rows=1 width=33) (actual time=0.005..0.005 rows=0 loops=310)

  • Index Cond: (cd_pessoa = ct.cd_pessoa_pagador)
  • Filter: (nm_pessoa ~* 'amaggi'::text)
  • Rows Removed by Filter: 1
119. 0.060 0.060 ↑ 1.0 1 12

Index Scan using pk_cidade on cidade cio (cost=0.28..0.30 rows=1 width=20) (actual time=0.005..0.005 rows=1 loops=12)

  • Index Cond: (cd_cidade = ct.cd_cidade_origem)
120. 0.024 0.024 ↑ 1.0 1 12

Index Scan using pk_uf on uf ufo (cost=0.14..0.16 rows=1 width=7) (actual time=0.002..0.002 rows=1 loops=12)

  • Index Cond: (cd_uf = cio.cd_uf)
121. 0.024 0.024 ↑ 1.0 1 12

Index Scan using pk_cidade on cidade cid (cost=0.28..0.30 rows=1 width=20) (actual time=0.002..0.002 rows=1 loops=12)

  • Index Cond: (cd_cidade = ct.cd_cidade_destino)
122. 0.012 0.012 ↑ 1.0 1 12

Index Scan using pk_uf on uf ufd (cost=0.14..0.16 rows=1 width=7) (actual time=0.001..0.001 rows=1 loops=12)

  • Index Cond: (cd_uf = cid.cd_uf)
123. 0.024 0.024 ↑ 1.0 1 12

Index Scan using pk_cidade on cidade cpag (cost=0.28..1.68 rows=1 width=20) (actual time=0.002..0.002 rows=1 loops=12)

  • Index Cond: (cd_cidade = pag.cd_cidade)
124. 0.012 0.012 ↑ 1.0 1 12

Index Scan using pk_uf on uf ufpag (cost=0.14..0.16 rows=1 width=7) (actual time=0.001..0.001 rows=1 loops=12)

  • Index Cond: (cd_uf = cpag.cd_uf)
125. 0.024 0.024 ↑ 1.0 1 12

Index Scan using pk_cidade on cidade cdes (cost=0.28..0.30 rows=1 width=20) (actual time=0.002..0.002 rows=1 loops=12)

  • Index Cond: (cd_cidade = pd.cd_cidade)
126. 0.012 0.012 ↑ 1.0 1 12

Index Scan using pk_uf on uf ufdes (cost=0.14..0.16 rows=1 width=7) (actual time=0.001..0.001 rows=1 loops=12)

  • Index Cond: (cd_uf = cdes.cd_uf)
127. 0.024 0.024 ↑ 1.0 1 12

Index Scan using pk_cidade on cidade crem (cost=0.28..0.30 rows=1 width=20) (actual time=0.002..0.002 rows=1 loops=12)

  • Index Cond: (cd_cidade = pr.cd_cidade)
128. 0.012 0.012 ↑ 1.0 1 12

Index Scan using pk_uf on uf ufrem (cost=0.14..0.16 rows=1 width=7) (actual time=0.001..0.001 rows=1 loops=12)

  • Index Cond: (cd_uf = crem.cd_uf)
129. 0.036 0.036 ↑ 1.0 1 12

Index Scan using pk_pessoa on pessoa pt (cost=0.43..0.46 rows=1 width=29) (actual time=0.003..0.003 rows=1 loops=12)

  • Index Cond: (cd_pessoa = CASE ct.id_frete WHEN 0 THEN ct.cd_pessoa_entrega WHEN 1 THEN ct.cd_pessoa_embarque WHEN 2 THEN ct.cd_pessoa_consignatario WHEN 3 THEN ct.cd_pessoa_pagador WHEN 4 THEN ct.cd_pessoa_consignatario_embarque ELSE NULL::integer END)
130. 0.172 7.800 ↑ 12.5 4 12

HashAggregate (cost=133.75..134.50 rows=50 width=68) (actual time=0.648..0.650 rows=4 loops=12)

  • Group Key: ct_2.nr_embarque
131. 0.142 7.628 ↓ 6.2 310 1

Nested Loop (cost=0.43..133.38 rows=50 width=16) (actual time=0.011..7.628 rows=310 loops=1)

132. 0.046 0.046 ↓ 6.2 310 1

CTE Scan on with_ctrc_emitido wce_2 (cost=0.00..1.00 rows=50 width=4) (actual time=0.001..0.046 rows=310 loops=1)

133. 7.440 7.440 ↑ 1.0 1 310

Index Scan using pk_ctrc on ctrc ct_2 (cost=0.43..2.65 rows=1 width=20) (actual time=0.024..0.024 rows=1 loops=310)

  • Index Cond: (cd_ctrc = wce_2.cd_ctrc)
134. 0.096 0.096 ↑ 1.0 1 12

Index Scan using pk_lote_carregamento on lote_carregamento lc (cost=0.42..0.44 rows=1 width=48) (actual time=0.008..0.008 rows=1 loops=12)

  • Index Cond: (cd_lote = ct.cd_lote)
135. 0.252 0.252 ↑ 1.0 1 12

Index Only Scan using pk_motorista on motorista m (cost=0.42..0.44 rows=1 width=4) (actual time=0.021..0.021 rows=1 loops=12)

  • Index Cond: (cd_pessoa = ct.cd_pessoa_motorista)
  • Heap Fetches: 21
136. 0.252 0.252 ↑ 1.0 1 12

Index Scan using pk_pessoa on pessoa pm (cost=0.42..0.48 rows=1 width=29) (actual time=0.021..0.021 rows=1 loops=12)

  • Index Cond: (cd_pessoa = m.cd_pessoa)
137. 0.108 0.108 ↑ 1.0 1 12

Index Scan using pk_pessoa on pessoa ptp (cost=0.42..0.44 rows=1 width=29) (actual time=0.009..0.009 rows=1 loops=12)

  • Index Cond: (cd_pessoa = ct.cd_pessoa_transportadora)
138. 0.024 0.024 ↑ 1.0 1 12

Index Scan using pk_pessoa on pessoa ptd (cost=0.42..0.44 rows=1 width=29) (actual time=0.002..0.002 rows=1 loops=12)

  • Index Cond: (cd_pessoa = ct.cd_pessoa_transportadora_doc)
139. 0.048 0.048 ↑ 1.0 1 12

Index Scan using pk_pessoa on pessoa pc (cost=0.42..0.44 rows=1 width=33) (actual time=0.004..0.004 rows=1 loops=12)

  • Index Cond: (cd_pessoa = ct.cd_pessoa_consignatario)
140. 0.024 0.024 ↑ 1.0 1 12

Index Scan using pk_cidade on cidade ccon (cost=0.28..0.30 rows=1 width=20) (actual time=0.002..0.002 rows=1 loops=12)

  • Index Cond: (cd_cidade = pc.cd_cidade)
141. 0.024 0.024 ↑ 1.0 1 12

Index Scan using pk_uf on uf ufcon (cost=0.14..0.16 rows=1 width=7) (actual time=0.002..0.002 rows=1 loops=12)

  • Index Cond: (cd_uf = ccon.cd_uf)
142. 0.024 0.024 ↓ 0.0 0 12

Index Scan using pk_pessoa on pessoa pce (cost=0.42..0.44 rows=1 width=29) (actual time=0.002..0.002 rows=0 loops=12)

  • Index Cond: (cd_pessoa = ct.cd_pessoa_consignatario_embarque)
143. 0.300 0.300 ↑ 1.0 1 12

Index Scan using pk_veiculo on veiculo v (cost=0.42..0.44 rows=1 width=25) (actual time=0.025..0.025 rows=1 loops=12)

  • Index Cond: (cd_veiculo = ct.cd_veiculo)
144. 0.036 0.036 ↑ 1.0 1 12

Index Scan using pk_veiculo_marca on veiculo_marca vm (cost=0.14..0.16 rows=1 width=11) (actual time=0.003..0.003 rows=1 loops=12)

  • Index Cond: (cd_marca = v.cd_marca)
145. 0.108 0.108 ↓ 0.0 0 12

Index Scan using pk_ordem_carregamento on ordem_carregamento oc (cost=0.43..0.47 rows=1 width=16) (actual time=0.009..0.009 rows=0 loops=12)

  • Index Cond: (cd_ordem = ct.cd_ordem)
146. 0.012 0.012 ↓ 0.0 0 12

Index Scan using pk_agencia on agencia ao (cost=0.14..0.16 rows=1 width=17) (actual time=0.001..0.001 rows=0 loops=12)

  • Index Cond: (cd_agencia = oc.cd_agencia)
147. 0.012 0.012 ↓ 0.0 0 12

Index Scan using pk_pessoa on pessoa uo (cost=0.42..0.44 rows=1 width=29) (actual time=0.001..0.001 rows=0 loops=12)

  • Index Cond: (cd_pessoa = COALESCE(oc.cd_pessoa_usuario_agenciador, oc.cd_pessoa_usuario))
148. 0.036 0.036 ↑ 1.0 1 12

Index Scan using pk_agencia on agencia a (cost=0.14..0.16 rows=1 width=17) (actual time=0.003..0.003 rows=1 loops=12)

  • Index Cond: (cd_agencia = ct.cd_agencia)
149. 0.156 0.156 ↑ 1.0 1 12

Index Scan using pk_ctrc_icms on ctrc_icms cicms (cost=0.43..0.46 rows=1 width=16) (actual time=0.013..0.013 rows=1 loops=12)

  • Index Cond: (cd_ctrc = ct.cd_ctrc)
150. 0.036 0.036 ↓ 0.0 0 12

Index Scan using pk_ctrc_imposto_municipal on ctrc_imposto_municipal cim (cost=0.28..0.30 rows=1 width=10) (actual time=0.003..0.003 rows=0 loops=12)

  • Index Cond: (cd_ctrc = ct.cd_ctrc)
151. 1.769 10.692 ↓ 6.1 304 12

HashAggregate (cost=297.03..297.53 rows=50 width=460) (actual time=0.778..0.891 rows=304 loops=12)

  • Group Key: "*SELECT* 1".cd_ctrc, ('DIVERSOS'::text), ('DIVERSOS'::text), ('DIVERSOS'::text), (0), ('-2'::integer), "*SELECT* 1".vl_frete, "*SELECT* 1".vl_tarifa, "*SELECT* 1".vl_desconto, "*SELECT* 1".vl_vale_combustivel, "*SELECT* 1".vl_inss_patronal, "*SELECT* 1".vl_seguro, "*SELECT* 1".vl_pedagio, "*SELECT* 1".vl_outros, "*SELECT* 1".vl_taxa_adm_pgto, "*SELECT* 1".vl_taxa_adm, "*SELECT* 1".vl_adiantamento
152. 0.034 8.923 ↓ 6.1 304 1

Append (cost=135.63..294.91 rows=50 width=460) (actual time=0.611..8.923 rows=304 loops=1)

153. 0.001 0.576 ↓ 0.0 0 1

Subquery Scan on *SELECT* 1 (cost=135.63..135.72 rows=1 width=460) (actual time=0.576..0.576 rows=0 loops=1)

154. 0.001 0.575 ↓ 0.0 0 1

GroupAggregate (cost=135.63..135.71 rows=1 width=460) (actual time=0.575..0.575 rows=0 loops=1)

  • Group Key: c.cd_ctrc_novo, 'DIVERSOS'::text, 'DIVERSOS'::text, 'DIVERSOS'::text, 0, '-2'::integer
155. 0.011 0.574 ↓ 0.0 0 1

Sort (cost=135.63..135.63 rows=1 width=153) (actual time=0.574..0.574 rows=0 loops=1)

  • Sort Key: c.cd_ctrc_novo
  • Sort Method: quicksort Memory: 25kB
156. 0.003 0.563 ↓ 0.0 0 1

Nested Loop (cost=0.86..135.62 rows=1 width=153) (actual time=0.563..0.563 rows=0 loops=1)

157. 0.192 0.534 ↓ 2.0 2 1

Nested Loop (cost=0.43..134.00 rows=1 width=8) (actual time=0.058..0.534 rows=2 loops=1)

158. 0.032 0.032 ↓ 6.2 310 1

CTE Scan on with_ctrc_emitido wce_3 (cost=0.00..1.00 rows=50 width=4) (actual time=0.000..0.032 rows=310 loops=1)

159. 0.310 0.310 ↓ 0.0 0 310

Index Scan using idx_ctrc_cd_ctrc_novo on ctrc c (cost=0.43..2.65 rows=1 width=8) (actual time=0.001..0.001 rows=0 loops=310)

  • Index Cond: ((cd_ctrc_novo = wce_3.cd_ctrc) AND (cd_ctrc_novo IS NOT NULL))
  • Filter: (cd_ctrc_anulacao IS NULL)
160. 0.026 0.026 ↓ 0.0 0 2

Index Scan using pk_carta_frete on carta_frete cf (cost=0.43..1.62 rows=1 width=49) (actual time=0.013..0.013 rows=0 loops=2)

  • Index Cond: (cd_ctrc = c.cd_ctrc)
161. 0.063 8.313 ↓ 6.2 304 1

Subquery Scan on *SELECT* 2 (cost=0.86..158.93 rows=49 width=116) (actual time=0.034..8.313 rows=304 loops=1)

162. 0.308 8.250 ↓ 6.2 304 1

Nested Loop (cost=0.86..158.32 rows=49 width=114) (actual time=0.031..8.250 rows=304 loops=1)

  • Join Filter: (wce_4.cd_ctrc = cf_1.cd_ctrc)
163. 0.143 4.222 ↓ 6.3 310 1

Nested Loop (cost=0.43..133.38 rows=49 width=8) (actual time=0.012..4.222 rows=310 loops=1)

164. 0.049 0.049 ↓ 6.2 310 1

CTE Scan on with_ctrc_emitido wce_4 (cost=0.00..1.00 rows=50 width=4) (actual time=0.000..0.049 rows=310 loops=1)

165. 4.030 4.030 ↑ 1.0 1 310

Index Scan using pk_ctrc on ctrc c_1 (cost=0.43..2.65 rows=1 width=4) (actual time=0.013..0.013 rows=1 loops=310)

  • Index Cond: (cd_ctrc = wce_4.cd_ctrc)
  • Filter: (cd_ctrc_novo IS NULL)
166. 3.720 3.720 ↑ 1.0 1 310

Index Scan using pk_carta_frete on carta_frete cf_1 (cost=0.43..0.49 rows=1 width=99) (actual time=0.012..0.012 rows=1 loops=310)

  • Index Cond: (cd_ctrc = c_1.cd_ctrc)
167. 0.156 0.156 ↑ 1.0 1 12

Index Scan using idx_carta_frete_vale_pedagio_cd_ctrc on carta_frete_vale_pedagio cfv (cost=0.42..0.45 rows=1 width=11) (actual time=0.013..0.013 rows=1 loops=12)

  • Index Cond: (cd_ctrc = ct.cd_ctrc)
168. 0.036 0.036 ↑ 1.0 1 12

Index Scan using pk_vale_pedagio on vale_pedagio vp (cost=0.13..0.15 rows=1 width=14) (actual time=0.003..0.003 rows=1 loops=12)

  • Index Cond: (cd_pessoa = cfv.cd_pessoa_vale_pedagio)
169. 0.144 0.144 ↑ 1.0 1 12

Index Scan using pk_ctrc_comissao on ctrc_comissao cc (cost=0.43..0.47 rows=1 width=45) (actual time=0.012..0.012 rows=1 loops=12)

  • Index Cond: (cd_ctrc = ct.cd_ctrc)
170.          

SubPlan (for Nested Loop Left Join)

171. 0.018 0.018 ↑ 1.0 37 1

Seq Scan on filial (cost=0.00..1.37 rows=37 width=4) (actual time=0.012..0.018 rows=37 loops=1)

172. 0.000 0.000 ↓ 0.0 0

Index Only Scan using pk_usuario_cliente on usuario_cliente ucl (cost=0.28..2.50 rows=1 width=4) (never executed)

  • Index Cond: (cd_pessoa = 151,026)
  • Heap Fetches: 0
173. 0.120 0.120 ↑ 1.0 1 12

Index Scan using pk_ctrc_cprb on ctrc_cprb cprb (cost=0.42..0.44 rows=1 width=10) (actual time=0.010..0.010 rows=1 loops=12)

  • Index Cond: (cd_ctrc = ct.cd_ctrc)
174. 0.144 0.516 ↑ 1.0 1 12

Index Only Scan using pk_agencia_centro_custo on agencia_centro_custo acc (cost=0.14..6.63 rows=1 width=16) (actual time=0.042..0.043 rows=1 loops=12)

  • Index Cond: (cd_agencia = COALESCE(ct.cd_agencia, ct.cd_agencia))
  • Filter: (dt_vigencia = (SubPlan 20))
  • Heap Fetches: 12
175.          

SubPlan (for Index Only Scan)

176. 0.072 0.372 ↑ 1.0 1 12

Aggregate (cost=4.97..4.98 rows=1 width=4) (actual time=0.031..0.031 rows=1 loops=12)

177. 0.300 0.300 ↑ 1.0 1 12

Seq Scan on agencia_centro_custo acc2 (cost=0.00..4.97 rows=1 width=4) (actual time=0.009..0.025 rows=1 loops=12)

  • Filter: ((dt_vigencia <= ct.dt_emissao) AND (cd_agencia = acc.cd_agencia))
  • Rows Removed by Filter: 197
178. 0.168 0.168 ↑ 1.0 1 12

Index Scan using pk_ctrc_imposto_federal_credito on ctrc_imposto_federal_credito ifc (cost=0.43..0.46 rows=1 width=16) (actual time=0.014..0.014 rows=1 loops=12)

  • Index Cond: (cd_ctrc = ct.cd_ctrc)
179. 0.168 0.168 ↑ 1.0 1 12

Index Scan using pk_ctrc_imposto_federal_debito on ctrc_imposto_federal_debito ifd (cost=0.43..0.46 rows=1 width=16) (actual time=0.014..0.014 rows=1 loops=12)

  • Index Cond: (cd_ctrc = ct.cd_ctrc)
180. 0.048 0.048 ↓ 0.0 0 12

Index Scan using pk_ctrc_complemento on ctrc_complemento ccom (cost=0.29..0.31 rows=1 width=16) (actual time=0.004..0.004 rows=0 loops=12)

  • Index Cond: (cd_ctrc = ct.cd_ctrc)
181. 0.036 0.036 ↓ 0.0 0 12

Index Scan using pk_associado on associado ass (cost=0.12..0.15 rows=1 width=16) (actual time=0.003..0.003 rows=0 loops=12)

  • Index Cond: ((cd_pessoa = ct.cd_pessoa_transportadora) AND (dt_inicio <= ct.dt_emissao))
  • Filter: ((dt_termino IS NULL) OR (dt_termino >= ct.dt_emissao))
182. 0.012 0.012 ↓ 0.0 0 12

Index Scan using pk_categoria_associado on categoria_associado cass (cost=0.15..2.37 rows=1 width=36) (actual time=0.001..0.001 rows=0 loops=12)

  • Index Cond: (cd_categoria = ass.cd_categoria)
183. 0.072 0.072 ↑ 1.0 1 12

Index Scan using pk_pessoa on pessoa seg (cost=0.42..0.44 rows=1 width=29) (actual time=0.006..0.006 rows=1 loops=12)

  • Index Cond: (cd_pessoa = ct.cd_pessoa_seguradora)
184. 0.024 0.024 ↓ 0.0 0 12

Index Scan using pk_embarque on embarque e (cost=0.29..0.31 rows=1 width=16) (actual time=0.002..0.002 rows=0 loops=12)

  • Index Cond: (nr_embarque = ct.nr_embarque)
185. 0.012 0.012 ↓ 0.0 0 12

Index Scan using pk_pessoa on pessoa pem (cost=0.42..0.81 rows=1 width=29) (actual time=0.001..0.001 rows=0 loops=12)

  • Index Cond: (cd_pessoa = e.cd_pessoa_motorista)
186. 0.012 0.012 ↓ 0.0 0 12

Index Scan using pk_veiculo on veiculo vem (cost=0.42..1.07 rows=1 width=11) (actual time=0.001..0.001 rows=0 loops=12)

  • Index Cond: (cd_veiculo = e.cd_veiculo)
187. 0.024 0.024 ↑ 1.0 1 12

Index Scan using pk_agencia on agencia aga (cost=0.14..0.16 rows=1 width=17) (actual time=0.002..0.002 rows=1 loops=12)

  • Index Cond: (cd_agencia = cc.cd_agencia_agenciador)
188. 0.024 0.024 ↑ 1.0 1 12

Index Scan using pk_agencia on agencia agg (cost=0.14..0.16 rows=1 width=17) (actual time=0.002..0.002 rows=1 loops=12)

  • Index Cond: (cd_agencia = cc.cd_agencia_gerente)
189. 0.012 0.012 ↑ 1.0 1 12

Index Scan using pk_agencia on agencia agm (cost=0.14..0.16 rows=1 width=17) (actual time=0.001..0.001 rows=1 loops=12)

  • Index Cond: (cd_agencia = cc.cd_agencia_manifestador)
190. 0.012 0.012 ↑ 1.0 1 12

Index Scan using pk_agencia on agencia ags (cost=0.14..0.16 rows=1 width=17) (actual time=0.001..0.001 rows=1 loops=12)

  • Index Cond: (cd_agencia = cc.cd_agencia_supervisor)
191. 0.012 0.012 ↓ 0.0 0 12

Index Scan using pk_administradora_pagamento_eletronico on administradora_pagamento_eletronico ape (cost=0.14..0.22 rows=1 width=15) (actual time=0.001..0.001 rows=0 loops=12)

  • Index Cond: (cd_pessoa = (0))
192. 0.012 0.012 ↓ 0.0 0 12

Index Scan using pk_ctrc on ctrc ctnovo (cost=0.43..0.51 rows=1 width=14) (actual time=0.001..0.001 rows=0 loops=12)

  • Index Cond: (cd_ctrc = ct.cd_ctrc_novo)
193. 0.132 0.132 ↑ 1.0 1 12

Index Scan using pk_ctrc_cte on ctrc_cte cte (cost=0.43..0.51 rows=1 width=49) (actual time=0.011..0.011 rows=1 loops=12)

  • Index Cond: (cd_ctrc = ct.cd_ctrc)
194. 0.012 0.012 ↓ 0.0 0 12

Index Scan using pk_motivo_cancelamento on motivo_cancelamento mc (cost=0.14..0.16 rows=1 width=28) (actual time=0.001..0.001 rows=0 loops=12)

  • Index Cond: (cd_motivo = ct.cd_motivo)
195. 0.012 0.012 ↓ 0.0 0 12

Index Scan using pk_ctrc on ctrc ctcomp (cost=0.43..0.51 rows=1 width=12) (actual time=0.001..0.001 rows=0 loops=12)

  • Index Cond: (cd_ctrc = ct.cd_ctrc_complementado)
196.          

SubPlan (for Result)

197. 0.144 0.144 ↓ 0.0 0 12

Index Scan using pk_ctrc_documento on ctrc_documento (cost=0.42..2.64 rows=1 width=9) (actual time=0.012..0.012 rows=0 loops=12)

  • Index Cond: ((cd_ctrc = ct.cd_ctrc) AND (id_documento = 1))
198. 0.024 0.024 ↓ 0.0 0 12

Index Scan using pk_ctrc_documento on ctrc_documento ctrc_documento_1 (cost=0.42..2.64 rows=1 width=9) (actual time=0.002..0.002 rows=0 loops=12)

  • Index Cond: ((cd_ctrc = ct.cd_ctrc) AND (id_documento = 2))
199. 0.024 0.024 ↓ 0.0 0 12

Index Scan using pk_ctrc_documento on ctrc_documento ctrc_documento_2 (cost=0.42..2.64 rows=1 width=9) (actual time=0.002..0.002 rows=0 loops=12)

  • Index Cond: ((cd_ctrc = ct.cd_ctrc) AND (id_documento = 3))
200. 0.024 0.024 ↓ 0.0 0 12

Index Scan using pk_ctrc_documento on ctrc_documento ctrc_documento_3 (cost=0.42..2.64 rows=1 width=9) (actual time=0.002..0.002 rows=0 loops=12)

  • Index Cond: ((cd_ctrc = ct.cd_ctrc) AND (id_documento = 4))
201. 0.000 0.396 ↑ 1.0 1 12

Limit (cost=5.18..5.18 rows=1 width=34) (actual time=0.033..0.033 rows=1 loops=12)

202. 0.048 0.396 ↑ 1.0 1 12

Sort (cost=5.18..5.18 rows=1 width=34) (actual time=0.033..0.033 rows=1 loops=12)

  • Sort Key: e_.id_tipo_endereco
  • Sort Method: quicksort Memory: 25kB
203. 0.036 0.348 ↑ 1.0 1 12

Nested Loop Left Join (cost=0.71..5.17 rows=1 width=34) (actual time=0.029..0.029 rows=1 loops=12)

204. 0.192 0.192 ↑ 1.0 1 12

Index Scan using idx_endereco_cd_pessoa on endereco e_ (cost=0.42..2.64 rows=1 width=34) (actual time=0.016..0.016 rows=1 loops=12)

  • Index Cond: (cd_pessoa = ptd.cd_pessoa)
205. 0.120 0.120 ↑ 1.0 1 12

Index Scan using pk_bairro on bairro b_ (cost=0.29..2.51 rows=1 width=17) (actual time=0.010..0.010 rows=1 loops=12)

  • Index Cond: (cd_bairro = e_.cd_bairro)
206. 0.024 0.240 ↑ 1.0 1 12

Nested Loop (cost=0.99..5.51 rows=1 width=32) (actual time=0.019..0.020 rows=1 loops=12)

207. 0.012 0.180 ↑ 1.0 1 12

Nested Loop (cost=0.85..5.30 rows=1 width=19) (actual time=0.014..0.015 rows=1 loops=12)

208. 0.024 0.120 ↑ 1.0 1 12

Nested Loop (cost=0.70..5.14 rows=1 width=16) (actual time=0.009..0.010 rows=1 loops=12)

209. 0.036 0.036 ↑ 1.0 1 12

Index Scan using pk_pessoa on pessoa pe_ (cost=0.42..2.64 rows=1 width=4) (actual time=0.003..0.003 rows=1 loops=12)

  • Index Cond: (cd_pessoa = ptd.cd_pessoa)
210. 0.060 0.060 ↑ 1.0 1 12

Index Scan using pk_cidade on cidade c_ (cost=0.28..2.50 rows=1 width=20) (actual time=0.005..0.005 rows=1 loops=12)

  • Index Cond: (cd_cidade = pe_.cd_cidade)
211. 0.048 0.048 ↑ 1.0 1 12

Index Scan using pk_uf on uf u_ (cost=0.14..0.16 rows=1 width=11) (actual time=0.004..0.004 rows=1 loops=12)

  • Index Cond: (cd_uf = c_.cd_uf)
212. 0.036 0.036 ↑ 1.0 1 12

Index Scan using pk_pais on pais p_ (cost=0.14..0.19 rows=1 width=14) (actual time=0.003..0.003 rows=1 loops=12)

  • Index Cond: (cd_pais = u_.cd_pais)
213. 0.012 0.108 ↑ 1.0 1 12

Limit (cost=5.18..5.18 rows=1 width=34) (actual time=0.009..0.009 rows=1 loops=12)

214. 0.012 0.096 ↑ 1.0 1 12

Sort (cost=5.18..5.18 rows=1 width=34) (actual time=0.008..0.008 rows=1 loops=12)

  • Sort Key: e__1.id_tipo_endereco
  • Sort Method: quicksort Memory: 25kB
215. 0.024 0.084 ↑ 1.0 1 12

Nested Loop Left Join (cost=0.71..5.17 rows=1 width=34) (actual time=0.006..0.007 rows=1 loops=12)

216. 0.036 0.036 ↑ 1.0 1 12

Index Scan using idx_endereco_cd_pessoa on endereco e__1 (cost=0.42..2.64 rows=1 width=34) (actual time=0.002..0.003 rows=1 loops=12)

  • Index Cond: (cd_pessoa = ptp.cd_pessoa)
217. 0.024 0.024 ↑ 1.0 1 12

Index Scan using pk_bairro on bairro b__1 (cost=0.29..2.51 rows=1 width=17) (actual time=0.002..0.002 rows=1 loops=12)

  • Index Cond: (cd_bairro = e__1.cd_bairro)
218. 0.024 0.144 ↑ 1.0 1 12

Nested Loop (cost=0.99..5.51 rows=1 width=32) (actual time=0.012..0.012 rows=1 loops=12)

219. 0.024 0.108 ↑ 1.0 1 12

Nested Loop (cost=0.85..5.30 rows=1 width=19) (actual time=0.009..0.009 rows=1 loops=12)

220. 0.012 0.072 ↑ 1.0 1 12

Nested Loop (cost=0.70..5.14 rows=1 width=16) (actual time=0.006..0.006 rows=1 loops=12)

221. 0.036 0.036 ↑ 1.0 1 12

Index Scan using pk_pessoa on pessoa pe__1 (cost=0.42..2.64 rows=1 width=4) (actual time=0.003..0.003 rows=1 loops=12)

  • Index Cond: (cd_pessoa = ptp.cd_pessoa)
222. 0.024 0.024 ↑ 1.0 1 12

Index Scan using pk_cidade on cidade c__1 (cost=0.28..2.50 rows=1 width=20) (actual time=0.002..0.002 rows=1 loops=12)

  • Index Cond: (cd_cidade = pe__1.cd_cidade)
223. 0.012 0.012 ↑ 1.0 1 12

Index Scan using pk_uf on uf u__1 (cost=0.14..0.16 rows=1 width=11) (actual time=0.001..0.001 rows=1 loops=12)

  • Index Cond: (cd_uf = c__1.cd_uf)
224. 0.012 0.012 ↑ 1.0 1 12

Index Scan using pk_pais on pais p__1 (cost=0.14..0.19 rows=1 width=14) (actual time=0.001..0.001 rows=1 loops=12)

  • Index Cond: (cd_pais = u__1.cd_pais)
225. 0.000 0.252 ↑ 1.0 1 12

Limit (cost=7.68..7.68 rows=1 width=38) (actual time=0.021..0.021 rows=1 loops=12)

226. 0.036 0.252 ↑ 2.0 1 12

Sort (cost=7.68..7.68 rows=2 width=38) (actual time=0.021..0.021 rows=1 loops=12)

  • Sort Key: cp.vl_peso DESC
  • Sort Method: quicksort Memory: 25kB
227. 0.024 0.216 ↑ 2.0 1 12

Nested Loop (cost=0.71..7.67 rows=2 width=38) (actual time=0.018..0.018 rows=1 loops=12)

228. 0.144 0.144 ↑ 2.0 1 12

Index Scan using idx_ctrc_produto_cd_ctrc on ctrc_produto cp (cost=0.43..2.67 rows=2 width=20) (actual time=0.012..0.012 rows=1 loops=12)

  • Index Cond: (cd_ctrc = ct.cd_ctrc)
229. 0.048 0.048 ↑ 1.0 1 12

Index Scan using pk_produto_venda on produto_transportado p_2 (cost=0.28..2.49 rows=1 width=27) (actual time=0.004..0.004 rows=1 loops=12)

  • Index Cond: (cd_produto = cp.cd_produto)
230. 0.048 0.120 ↑ 1.0 1 12

Aggregate (cost=5.03..5.04 rows=1 width=32) (actual time=0.010..0.010 rows=1 loops=12)

231. 0.000 0.072 ↓ 0.0 0 12

Nested Loop (cost=0.57..5.02 rows=1 width=22) (actual time=0.006..0.006 rows=0 loops=12)

232. 0.072 0.072 ↓ 0.0 0 12

Index Scan using idx_ctrc_corretor_cd_ctrc on ctrc_corretor ct_crr_ (cost=0.42..2.64 rows=1 width=4) (actual time=0.006..0.006 rows=0 loops=12)

  • Index Cond: (cd_ctrc = ct.cd_ctrc)
233. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_corretor on corretor crr_ (cost=0.14..2.36 rows=1 width=26) (never executed)

  • Index Cond: (cd_pessoa = ct_crr_.cd_pessoa_corretor)
234. 0.000 0.048 ↑ 1.0 1 12

Aggregate (cost=2.52..2.52 rows=1 width=32) (actual time=0.004..0.004 rows=1 loops=12)

235. 0.048 0.048 ↓ 0.0 0 12

Index Scan using idx_carta_frete_diaria_cd_ctrc on carta_frete_diaria (cost=0.29..2.51 rows=1 width=11) (actual time=0.004..0.004 rows=0 loops=12)

  • Index Cond: (cd_ctrc = ct.cd_ctrc)
236. 0.132 0.132 ↓ 0.0 0 12

Index Scan using pk_pessoa_juridica on pessoa_juridica pjt (cost=0.42..2.64 rows=1 width=4) (actual time=0.011..0.011 rows=0 loops=12)

  • Index Cond: (cd_pessoa = ct.cd_pessoa_transportadora_doc)
237. 0.228 0.228 ↑ 3.0 2 12

Index Scan using idx_ctrc_observacao_cd_ctrc on ctrc_observacao co (cost=0.43..2.76 rows=6 width=78) (actual time=0.014..0.019 rows=2 loops=12)

  • Index Cond: (cd_ctrc = ct.cd_ctrc)
238. 0.012 0.180 ↓ 0.0 0 12

Subquery Scan on pf_1 (cost=280.60..280.63 rows=1 width=0) (actual time=0.015..0.015 rows=0 loops=12)

239. 0.000 0.168 ↓ 0.0 0 12

Unique (cost=280.60..280.62 rows=1 width=126) (actual time=0.014..0.014 rows=0 loops=12)

240. 0.048 0.168 ↓ 0.0 0 12

Sort (cost=280.60..280.60 rows=1 width=126) (actual time=0.014..0.014 rows=0 loops=12)

  • Sort Key: (COALESCE(p_3.nm_fantasia, p_3.nm_pessoa)), p_3.cd_cidade, (((ci_1.nm_cidade || ' / '::text) || (uf_1.ds_sigla)::text)), ((COALESCE(pj_1.nr_cnpj, pf_2.nr_cpf))::character varying(14)), (COALESCE(substr((pj_1.nr_cnpj)::text, 1, 8), (pf_2.nr_cpf)::text)), (COALESCE((SubPlan 15), f_2.cd_pessoa_matriz))
  • Sort Method: quicksort Memory: 25kB
241. 0.012 0.120 ↓ 0.0 0 12

Nested Loop (cost=1.69..280.59 rows=1 width=126) (actual time=0.010..0.010 rows=0 loops=12)

242. 0.000 0.108 ↓ 0.0 0 12

Nested Loop (cost=1.54..147.33 rows=1 width=90) (actual time=0.009..0.009 rows=0 loops=12)

243. 0.012 0.108 ↓ 0.0 0 12

Nested Loop (cost=1.26..144.83 rows=1 width=74) (actual time=0.009..0.009 rows=0 loops=12)

244. 0.000 0.096 ↓ 0.0 0 12

Nested Loop (cost=0.84..142.18 rows=1 width=35) (actual time=0.008..0.008 rows=0 loops=12)

  • Join Filter: (f_2.cd_pessoa_matriz = eg_2.cd_pessoa)
245. 0.012 0.096 ↓ 0.0 0 12

Nested Loop Left Join (cost=0.84..140.96 rows=1 width=35) (actual time=0.008..0.008 rows=0 loops=12)

  • Join Filter: (pg_1.cd_empresa = f_2.cd_pessoa_matriz)
246. 0.000 0.084 ↓ 0.0 0 12

Nested Loop Left Join (cost=0.84..139.93 rows=1 width=35) (actual time=0.007..0.007 rows=0 loops=12)

  • Join Filter: (pf_2.cd_pessoa = f_2.cd_pessoa_filial)
  • Filter: (COALESCE((SubPlan 16), f_2.cd_pessoa_matriz) = ct.cd_pessoa_matriz)
247. 0.024 0.084 ↓ 0.0 0 12

Nested Loop Left Join (cost=0.42..4.20 rows=1 width=23) (actual time=0.007..0.007 rows=0 loops=12)

  • Join Filter: (pj_1.cd_pessoa = f_2.cd_pessoa_filial)
248. 0.060 0.060 ↓ 0.0 0 12

Seq Scan on filial f_2 (cost=0.00..1.55 rows=1 width=8) (actual time=0.005..0.005 rows=0 loops=12)

  • Filter: ((cd_pessoa_filial = ct.cd_pessoa_transportadora_doc) AND (id_ativo = 1))
  • Rows Removed by Filter: 37
249. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_pessoa_juridica on pessoa_juridica pj_1 (cost=0.42..2.64 rows=1 width=19) (never executed)

  • Index Cond: (cd_pessoa = ct.cd_pessoa_transportadora_doc)
  • Filter: (nr_cnpj IS NOT NULL)
250. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_pessoa_fisica on pessoa_fisica pf_2 (cost=0.42..2.64 rows=1 width=16) (never executed)

  • Index Cond: (cd_pessoa = ct.cd_pessoa_transportadora_doc)
  • Filter: (nr_cpf IS NOT NULL)
251.          

SubPlan (for Nested Loop Left Join)

252. 0.000 0.000 ↓ 0.0 0

Limit (cost=133.07..133.08 rows=1 width=4) (never executed)

253. 0.000 0.000 ↓ 0.0 0

Unique (cost=133.07..133.08 rows=1 width=4) (never executed)

254. 0.000 0.000 ↓ 0.0 0

Sort (cost=133.07..133.07 rows=1 width=4) (never executed)

  • Sort Key: p_1_2.cd_pessoa
255. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=1.26..133.06 rows=1 width=4) (never executed)

  • Filter: ((substr((pjm_1.nr_cnpj)::text, 1, 12) = (substr((pj_1.nr_cnpj)::text, 1, 8) || '0001'::text)) OR (pfm_1.nr_cpf = pf_2.nr_cpf))
256. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=0.84..115.84 rows=37 width=16) (never executed)

257. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.42..99.05 rows=37 width=4) (never executed)

258. 0.000 0.000 ↓ 0.0 0

Seq Scan on filial f_1_1 (cost=0.00..1.37 rows=37 width=4) (never executed)

259. 0.000 0.000 ↓ 0.0 0

Index Only Scan using pk_pessoa on pessoa p_1_2 (cost=0.42..2.64 rows=1 width=4) (never executed)

  • Index Cond: (cd_pessoa = f_1_1.cd_pessoa_filial)
  • Heap Fetches: 0
260. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_pessoa_fisica on pessoa_fisica pfm_1 (cost=0.42..0.45 rows=1 width=16) (never executed)

  • Index Cond: (cd_pessoa = p_1_2.cd_pessoa)
  • Filter: (nr_cpf IS NOT NULL)
261. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_pessoa_juridica on pessoa_juridica pjm_1 (cost=0.42..0.44 rows=1 width=19) (never executed)

  • Index Cond: (cd_pessoa = p_1_2.cd_pessoa)
  • Filter: (nr_cnpj IS NOT NULL)
262. 0.000 0.000 ↓ 0.0 0

Seq Scan on parametro_geral pg_1 (cost=0.00..1.01 rows=1 width=4) (never executed)

263. 0.000 0.000 ↓ 0.0 0

Seq Scan on empresa_grupo eg_2 (cost=0.00..1.15 rows=6 width=4) (never executed)

  • Filter: (id_ativo = 1)
264. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_pessoa on pessoa p_3 (cost=0.42..2.64 rows=1 width=43) (never executed)

  • Index Cond: (cd_pessoa = ct.cd_pessoa_transportadora_doc)
265. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_cidade on cidade ci_1 (cost=0.28..2.50 rows=1 width=20) (never executed)

  • Index Cond: (cd_cidade = p_3.cd_cidade)
266. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_uf on uf uf_1 (cost=0.14..0.16 rows=1 width=7) (never executed)

  • Index Cond: (cd_uf = ci_1.cd_uf)
267.          

SubPlan (for Nested Loop)

268. 0.000 0.000 ↓ 0.0 0

Limit (cost=133.07..133.08 rows=1 width=4) (never executed)

269. 0.000 0.000 ↓ 0.0 0

Unique (cost=133.07..133.08 rows=1 width=4) (never executed)

270. 0.000 0.000 ↓ 0.0 0

Sort (cost=133.07..133.07 rows=1 width=4) (never executed)

  • Sort Key: p_1_1.cd_pessoa
271. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=1.26..133.06 rows=1 width=4) (never executed)

  • Filter: ((substr((pjm.nr_cnpj)::text, 1, 12) = (substr((pj_1.nr_cnpj)::text, 1, 8) || '0001'::text)) OR (pfm.nr_cpf = pf_2.nr_cpf))
272. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=0.84..115.84 rows=37 width=16) (never executed)

273. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.42..99.05 rows=37 width=4) (never executed)

274. 0.000 0.000 ↓ 0.0 0

Seq Scan on filial f_1 (cost=0.00..1.37 rows=37 width=4) (never executed)

275. 0.000 0.000 ↓ 0.0 0

Index Only Scan using pk_pessoa on pessoa p_1_1 (cost=0.42..2.64 rows=1 width=4) (never executed)

  • Index Cond: (cd_pessoa = f_1.cd_pessoa_filial)
  • Heap Fetches: 0
276. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_pessoa_fisica on pessoa_fisica pfm (cost=0.42..0.45 rows=1 width=16) (never executed)

  • Index Cond: (cd_pessoa = p_1_1.cd_pessoa)
  • Filter: (nr_cpf IS NOT NULL)
277. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_pessoa_juridica on pessoa_juridica pjm (cost=0.42..0.44 rows=1 width=19) (never executed)

  • Index Cond: (cd_pessoa = p_1_1.cd_pessoa)
  • Filter: (nr_cnpj IS NOT NULL)
278. 0.000 0.000 ↓ 0.0 0

Subquery Scan on pf_3 (cost=2,549.73..2,550.27 rows=18 width=8) (never executed)

279. 0.000 0.000 ↓ 0.0 0

Unique (cost=2,549.73..2,550.09 rows=18 width=126) (never executed)

280. 0.000 0.000 ↓ 0.0 0

Sort (cost=2,549.73..2,549.77 rows=18 width=126) (never executed)

  • Sort Key: (COALESCE(p_4.nm_fantasia, p_4.nm_pessoa)), p_4.cd_pessoa, p_4.cd_cidade, (((ci_2.nm_cidade || ' / '::text) || (uf_2.ds_sigla)::text)), ((COALESCE(pj_2.nr_cnpj, pf_4.nr_cpf))::character varying(14)), (COALESCE(substr((pj_2.nr_cnpj)::text, 1, 8), (pf_4.nr_cpf)::text)), (COALESCE((SubPlan 18), f_3.cd_pessoa_matriz))
281. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=3.94..2,549.35 rows=18 width=126) (never executed)

282. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=3.79..150.73 rows=18 width=90) (never executed)

283. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=3.51..145.33 rows=18 width=74) (never executed)

284. 0.000 0.000 ↓ 0.0 0

Hash Left Join (cost=3.09..97.81 rows=18 width=35) (never executed)

  • Hash Cond: (f_3.cd_pessoa_matriz = pg_2.cd_empresa)
285. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=2.06..96.70 rows=18 width=35) (never executed)

286. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=1.64..49.18 rows=18 width=23) (never executed)

287. 0.000 0.000 ↓ 0.0 0

Hash Join (cost=1.22..2.82 rows=18 width=8) (never executed)

  • Hash Cond: (f_3.cd_pessoa_matriz = eg_3.cd_pessoa)
288. 0.000 0.000 ↓ 0.0 0

Seq Scan on filial f_3 (cost=0.00..1.46 rows=37 width=8) (never executed)

  • Filter: (id_ativo = 1)
289. 0.000 0.000 ↓ 0.0 0

Hash (cost=1.15..1.15 rows=6 width=4) (never executed)

290. 0.000 0.000 ↓ 0.0 0

Seq Scan on empresa_grupo eg_3 (cost=0.00..1.15 rows=6 width=4) (never executed)

  • Filter: (id_ativo = 1)
291. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_pessoa_juridica on pessoa_juridica pj_2 (cost=0.42..2.58 rows=1 width=19) (never executed)

  • Index Cond: (cd_pessoa = f_3.cd_pessoa_filial)
  • Filter: (nr_cnpj IS NOT NULL)
292. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_pessoa_fisica on pessoa_fisica pf_4 (cost=0.42..2.64 rows=1 width=16) (never executed)

  • Index Cond: (cd_pessoa = f_3.cd_pessoa_filial)
  • Filter: (nr_cpf IS NOT NULL)
293. 0.000 0.000 ↓ 0.0 0

Hash (cost=1.01..1.01 rows=1 width=4) (never executed)

294. 0.000 0.000 ↓ 0.0 0

Seq Scan on parametro_geral pg_2 (cost=0.00..1.01 rows=1 width=4) (never executed)

295. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_pessoa on pessoa p_4 (cost=0.42..2.64 rows=1 width=43) (never executed)

  • Index Cond: (cd_pessoa = f_3.cd_pessoa_filial)
296. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_cidade on cidade ci_2 (cost=0.28..0.30 rows=1 width=20) (never executed)

  • Index Cond: (cd_cidade = p_4.cd_cidade)
297. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_uf on uf uf_2 (cost=0.14..0.16 rows=1 width=7) (never executed)

  • Index Cond: (cd_uf = ci_2.cd_uf)
298.          

SubPlan (for Nested Loop)

299. 0.000 0.000 ↓ 0.0 0

Limit (cost=133.07..133.08 rows=1 width=4) (never executed)

300. 0.000 0.000 ↓ 0.0 0

Unique (cost=133.07..133.08 rows=1 width=4) (never executed)

301. 0.000 0.000 ↓ 0.0 0

Sort (cost=133.07..133.07 rows=1 width=4) (never executed)

  • Sort Key: p_1_3.cd_pessoa
302. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=1.26..133.06 rows=1 width=4) (never executed)

  • Filter: ((substr((pjm_2.nr_cnpj)::text, 1, 12) = (substr((pj_2.nr_cnpj)::text, 1, 8) || '0001'::text)) OR (pfm_2.nr_cpf = pf_4.nr_cpf))
303. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=0.84..115.84 rows=37 width=16) (never executed)

304. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.42..99.05 rows=37 width=4) (never executed)

305. 0.000 0.000 ↓ 0.0 0

Seq Scan on filial f_1_2 (cost=0.00..1.37 rows=37 width=4) (never executed)

306. 0.000 0.000 ↓ 0.0 0

Index Only Scan using pk_pessoa on pessoa p_1_3 (cost=0.42..2.64 rows=1 width=4) (never executed)

  • Index Cond: (cd_pessoa = f_1_2.cd_pessoa_filial)
  • Heap Fetches: 0
307. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_pessoa_fisica on pessoa_fisica pfm_2 (cost=0.42..0.45 rows=1 width=16) (never executed)

  • Index Cond: (cd_pessoa = p_1_3.cd_pessoa)
  • Filter: (nr_cpf IS NOT NULL)
308. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_pessoa_juridica on pessoa_juridica pjm_2 (cost=0.42..0.44 rows=1 width=19) (never executed)

  • Index Cond: (cd_pessoa = p_1_3.cd_pessoa)
  • Filter: (nr_cnpj IS NOT NULL)
Planning time : 268.619 ms
Execution time : 102.645 ms