explain.depesz.com

PostgreSQL's explain analyze made readable

Result: ybxm : explain_pg10

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

Result (cost=831,396.14..831,665.46 rows=1 width=2,870) (actual time=0.120..0.121 rows=0 loops=1)

2.          

CTE with_ctrc_emitido

3. 0.001 0.021 ↓ 0.0 0 1

Nested Loop Left Join (cost=0.86..5.32 rows=1 width=4) (actual time=0.021..0.021 rows=0 loops=1)

  • Filter: CASE WHEN (cte_1.cd_ctrc IS NOT NULL) THEN (cte_1.id_ambiente = 1) ELSE true END
4. 0.020 0.020 ↓ 0.0 0 1

Index Scan using idx_ctrc_dt_emissao on ctrc ct_1 (cost=0.43..2.66 rows=1 width=4) (actual time=0.020..0.020 rows=0 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))
5. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_ctrc_cte on ctrc_cte cte_1 (cost=0.43..2.65 rows=1 width=6) (never executed)

  • Index Cond: (cd_ctrc = ct_1.cd_ctrc)
6.          

CTE cartafrete

7. 0.000 0.000 ↓ 0.0 0

Unique (cost=7.63..7.72 rows=2 width=460) (never executed)

8. 0.000 0.000 ↓ 0.0 0

Sort (cost=7.63..7.64 rows=2 width=460) (never executed)

  • Sort 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
9. 0.000 0.000 ↓ 0.0 0

Append (cost=4.34..7.62 rows=2 width=460) (never executed)

10. 0.000 0.000 ↓ 0.0 0

Subquery Scan on *SELECT* 1 (cost=4.34..4.43 rows=1 width=460) (never executed)

11. 0.000 0.000 ↓ 0.0 0

GroupAggregate (cost=4.34..4.42 rows=1 width=460) (never executed)

  • Group Key: c.cd_ctrc_novo, 'DIVERSOS'::text, 'DIVERSOS'::text, 'DIVERSOS'::text, 0, '-2'::integer
12. 0.000 0.000 ↓ 0.0 0

Sort (cost=4.34..4.34 rows=1 width=153) (never executed)

  • Sort Key: c.cd_ctrc_novo
13. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.86..4.33 rows=1 width=153) (never executed)

14. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.43..2.68 rows=1 width=8) (never executed)

15. 0.000 0.000 ↓ 0.0 0

CTE Scan on with_ctrc_emitido wce_1 (cost=0.00..0.02 rows=1 width=4) (never executed)

16. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_ctrc_cd_ctrc_novo on ctrc c (cost=0.43..2.65 rows=1 width=8) (never executed)

  • Index Cond: ((cd_ctrc_novo = wce_1.cd_ctrc) AND (cd_ctrc_novo IS NOT NULL))
  • Filter: (cd_ctrc_anulacao IS NULL)
17. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_carta_frete on carta_frete cf_1 (cost=0.43..1.65 rows=1 width=49) (never executed)

  • Index Cond: (cd_ctrc = c.cd_ctrc)
18. 0.000 0.000 ↓ 0.0 0

Subquery Scan on *SELECT* 2 (cost=0.86..3.19 rows=1 width=116) (never executed)

19. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.86..3.18 rows=1 width=114) (never executed)

  • Join Filter: (wce_2.cd_ctrc = cf_2.cd_ctrc)
20. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.43..2.67 rows=1 width=8) (never executed)

21. 0.000 0.000 ↓ 0.0 0

CTE Scan on with_ctrc_emitido wce_2 (cost=0.00..0.02 rows=1 width=4) (never executed)

22. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_ctrc on ctrc c_1 (cost=0.43..2.65 rows=1 width=4) (never executed)

  • Index Cond: (cd_ctrc = wce_2.cd_ctrc)
  • Filter: (cd_ctrc_novo IS NULL)
23. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_carta_frete on carta_frete cf_2 (cost=0.43..0.50 rows=1 width=99) (never executed)

  • Index Cond: (cd_ctrc = c_1.cd_ctrc)
24.          

CTE with_diferenca_frete

25. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.43..2.67 rows=1 width=22) (never executed)

26. 0.000 0.000 ↓ 0.0 0

CTE Scan on with_ctrc_emitido wce_3 (cost=0.00..0.02 rows=1 width=4) (never executed)

27. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_ctrc on ctrc ct_2 (cost=0.43..2.65 rows=1 width=22) (never executed)

  • Index Cond: (cd_ctrc = wce_3.cd_ctrc)
28.          

CTE total_embarque

29. 0.000 0.000 ↓ 0.0 0

GroupAggregate (cost=2.68..2.71 rows=1 width=68) (never executed)

  • Group Key: ct_3.nr_embarque
30. 0.000 0.000 ↓ 0.0 0

Sort (cost=2.68..2.68 rows=1 width=16) (never executed)

  • Sort Key: ct_3.nr_embarque
31. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.43..2.67 rows=1 width=16) (never executed)

32. 0.000 0.000 ↓ 0.0 0

CTE Scan on with_ctrc_emitido wce_4 (cost=0.00..0.02 rows=1 width=4) (never executed)

33. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_ctrc on ctrc ct_3 (cost=0.43..2.65 rows=1 width=20) (never executed)

  • Index Cond: (cd_ctrc = wce_4.cd_ctrc)
34.          

CTE with_ctrc_imagem

35. 0.000 0.000 ↓ 0.0 0

GroupAggregate (cost=730,569.03..781,044.69 rows=2,040,164 width=12) (never executed)

  • Group Key: ci_1.cd_ctrc
36. 0.000 0.000 ↓ 0.0 0

Sort (cost=730,569.03..740,593.70 rows=4,009,870 width=12) (never executed)

  • Sort Key: ci_1.cd_ctrc
37. 0.000 0.000 ↓ 0.0 0

Hash Left Join (cost=1.95..250,645.05 rows=4,009,870 width=12) (never executed)

  • Hash Cond: (cc_1.cd_comprovante = ce.cd_comprovante)
  • Filter: ((ce.id_uso IS NULL) OR (ce.id_uso <> 2))
38. 0.000 0.000 ↓ 0.0 0

Merge Left Join (cost=0.85..218,451.56 rows=5,337,598 width=16) (never executed)

  • Merge Cond: (ci_1.cd_ctrc_imagem = cc_1.cd_ctrc_imagem)
39. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_ctrc_imagem on ctrc_imagem ci_1 (cost=0.43..192,120.47 rows=3,648,807 width=16) (never executed)

40. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_ctrc_comprovante_ctrc_imagem on ctrc_comprovante cc_1 (cost=0.42..25,336.31 rows=5,337,598 width=8) (never executed)

41. 0.000 0.000 ↓ 0.0 0

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

42. 0.000 0.000 ↓ 0.0 0

Seq Scan on comprovante_entrega ce (cost=0.00..1.04 rows=4 width=6) (never executed)

43. 0.044 0.120 ↓ 0.0 0 1

Sort (cost=50,333.04..50,333.04 rows=1 width=2,461) (actual time=0.120..0.120 rows=0 loops=1)

  • Sort Key: pr.nm_pessoa, ct.cd_pessoa_embarque, ct.dt_emissao, ct.nr_ctrc
  • Sort Method: quicksort Memory: 25kB
44. 0.000 0.076 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,873.50..50,333.03 rows=1 width=2,461) (actual time=0.076..0.076 rows=0 loops=1)

45. 0.001 0.076 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,873.07..50,331.17 rows=1 width=1,704) (actual time=0.075..0.076 rows=0 loops=1)

46. 0.000 0.075 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,872.94..50,330.41 rows=1 width=1,684) (actual time=0.075..0.075 rows=0 loops=1)

47. 0.000 0.075 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,872.51..50,328.81 rows=1 width=1,639) (actual time=0.075..0.075 rows=0 loops=1)

48. 0.000 0.075 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,872.08..50,327.21 rows=1 width=1,633) (actual time=0.075..0.075 rows=0 loops=1)

  • Join Filter: (ape.cd_pessoa = cf.cd_pessoa_adm_pgto_eletronico)
49. 0.011 0.075 ↓ 0.0 0 1

Hash Right Join (cost=1,872.08..50,325.98 rows=1 width=1,622) (actual time=0.075..0.075 rows=0 loops=1)

  • Hash Cond: (wcti.cd_ctrc = ct.cd_ctrc)
50. 0.000 0.000 ↓ 0.0 0

CTE Scan on with_ctrc_imagem wcti (cost=0.00..40,803.28 rows=2,040,164 width=4) (never executed)

51. 0.000 0.064 ↓ 0.0 0 1

Hash (cost=1,872.06..1,872.06 rows=1 width=1,622) (actual time=0.064..0.064 rows=0 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 8kB
52. 0.000 0.064 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,810.55..1,872.06 rows=1 width=1,622) (actual time=0.064..0.064 rows=0 loops=1)

53. 0.000 0.064 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,810.41..1,870.90 rows=1 width=1,609) (actual time=0.064..0.064 rows=0 loops=1)

54. 0.001 0.064 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,810.26..1,869.74 rows=1 width=1,596) (actual time=0.064..0.064 rows=0 loops=1)

55. 0.000 0.063 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,810.12..1,868.58 rows=1 width=1,583) (actual time=0.063..0.063 rows=0 loops=1)

56. 0.000 0.063 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,809.97..1,867.41 rows=1 width=1,570) (actual time=0.063..0.063 rows=0 loops=1)

57. 0.000 0.063 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,809.55..1,865.73 rows=1 width=1,567) (actual time=0.063..0.063 rows=0 loops=1)

58. 0.001 0.063 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,809.13..1,864.09 rows=1 width=1,542) (actual time=0.063..0.063 rows=0 loops=1)

59. 0.000 0.062 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,808.84..1,862.67 rows=1 width=1,526) (actual time=0.062..0.062 rows=0 loops=1)

60. 0.000 0.062 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,808.42..1,861.09 rows=1 width=1,505) (actual time=0.062..0.062 rows=0 loops=1)

61. 0.000 0.062 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,808.27..1,856.50 rows=1 width=1,473) (actual time=0.062..0.062 rows=0 loops=1)

62. 0.001 0.062 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,808.14..1,855.80 rows=1 width=1,469) (actual time=0.062..0.062 rows=0 loops=1)

63. 0.000 0.061 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,807.86..1,854.37 rows=1 width=1,457) (actual time=0.061..0.061 rows=0 loops=1)

64. 0.000 0.061 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,807.43..1,852.77 rows=1 width=1,445) (actual time=0.061..0.061 rows=0 loops=1)

65. 0.000 0.061 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,807.00..1,851.18 rows=1 width=1,433) (actual time=0.061..0.061 rows=0 loops=1)

66. 0.000 0.061 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,806.85..1,844.11 rows=1 width=1,433) (actual time=0.061..0.061 rows=0 loops=1)

67. 0.001 0.061 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,806.43..1,842.54 rows=1 width=1,427) (actual time=0.061..0.061 rows=0 loops=1)

  • Filter: ((hashed SubPlan 25) 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 26))
68. 0.000 0.060 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,803.00..1,837.91 rows=1 width=1,405) (actual time=0.060..0.060 rows=0 loops=1)

69. 0.000 0.060 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,802.87..1,837.09 rows=1 width=1,399) (actual time=0.060..0.060 rows=0 loops=1)

70. 0.000 0.060 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,802.44..1,835.50 rows=1 width=1,392) (actual time=0.060..0.060 rows=0 loops=1)

  • Join Filter: (cf.cd_ctrc = ct.cd_ctrc)
71. 0.001 0.060 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,802.44..1,835.44 rows=1 width=932) (actual time=0.060..0.060 rows=0 loops=1)

72. 0.000 0.059 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,802.17..1,834.12 rows=1 width=926) (actual time=0.059..0.059 rows=0 loops=1)

73. 0.000 0.059 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,801.74..1,832.53 rows=1 width=914) (actual time=0.059..0.059 rows=0 loops=1)

74. 0.000 0.059 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,801.59..1,831.36 rows=1 width=901) (actual time=0.059..0.059 rows=0 loops=1)

75. 0.000 0.059 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,801.17..1,829.79 rows=1 width=880) (actual time=0.059..0.059 rows=0 loops=1)

76. 0.001 0.059 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,801.02..1,828.63 rows=1 width=867) (actual time=0.059..0.059 rows=0 loops=1)

77. 0.000 0.058 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,800.59..1,827.03 rows=1 width=855) (actual time=0.058..0.058 rows=0 loops=1)

78. 0.000 0.058 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,800.45..1,826.31 rows=1 width=852) (actual time=0.058..0.058 rows=0 loops=1)

79. 0.000 0.058 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,800.03..1,824.73 rows=1 width=831) (actual time=0.058..0.058 rows=0 loops=1)

80. 0.000 0.058 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,799.61..1,823.15 rows=1 width=806) (actual time=0.058..0.058 rows=0 loops=1)

81. 0.001 0.058 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,799.47..1,822.43 rows=1 width=807) (actual time=0.057..0.058 rows=0 loops=1)

82. 0.000 0.057 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,799.18..1,821.06 rows=1 width=795) (actual time=0.057..0.057 rows=0 loops=1)

83. 0.000 0.057 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,798.76..1,819.48 rows=1 width=766) (actual time=0.057..0.057 rows=0 loops=1)

84. 0.000 0.057 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,798.34..1,817.90 rows=1 width=737) (actual time=0.057..0.057 rows=0 loops=1)

85. 0.001 0.057 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,797.92..1,816.33 rows=1 width=708) (actual time=0.057..0.057 rows=0 loops=1)

86. 0.000 0.056 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,797.49..1,814.74 rows=1 width=683) (actual time=0.056..0.056 rows=0 loops=1)

87. 0.009 0.056 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,797.07..1,813.17 rows=1 width=683) (actual time=0.056..0.056 rows=0 loops=1)

88. 0.001 0.047 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,796.66..1,811.60 rows=1 width=643) (actual time=0.047..0.047 rows=0 loops=1)

  • Join Filter: (te.nr_embarque = ct.nr_embarque)
89. 0.000 0.046 ↓ 0.0 0 1

Nested Loop (cost=1,796.66..1,811.57 rows=1 width=579) (actual time=0.046..0.046 rows=0 loops=1)

90. 0.000 0.046 ↓ 0.0 0 1

Nested Loop (cost=1,796.22..1,809.98 rows=1 width=552) (actual time=0.046..0.046 rows=0 loops=1)

91. 0.000 0.046 ↓ 0.0 0 1

Nested Loop (cost=1,796.08..1,809.26 rows=1 width=553) (actual time=0.046..0.046 rows=0 loops=1)

92. 0.000 0.046 ↓ 0.0 0 1

Nested Loop (cost=1,795.80..1,807.89 rows=1 width=541) (actual time=0.046..0.046 rows=0 loops=1)

93. 0.001 0.046 ↓ 0.0 0 1

Nested Loop (cost=1,795.65..1,807.17 rows=1 width=542) (actual time=0.045..0.046 rows=0 loops=1)

94. 0.000 0.045 ↓ 0.0 0 1

Nested Loop (cost=1,795.37..1,805.79 rows=1 width=530) (actual time=0.045..0.045 rows=0 loops=1)

95. 0.000 0.045 ↓ 0.0 0 1

Nested Loop (cost=1,795.23..1,805.07 rows=1 width=531) (actual time=0.045..0.045 rows=0 loops=1)

96. 0.001 0.045 ↓ 0.0 0 1

Nested Loop (cost=1,794.95..1,803.58 rows=1 width=519) (actual time=0.045..0.045 rows=0 loops=1)

97. 0.000 0.044 ↓ 0.0 0 1

Nested Loop (cost=1,794.80..1,802.86 rows=1 width=516) (actual time=0.044..0.044 rows=0 loops=1)

98. 0.000 0.044 ↓ 0.0 0 1

Nested Loop (cost=1,794.52..1,801.48 rows=1 width=500) (actual time=0.044..0.044 rows=0 loops=1)

99. 0.000 0.044 ↓ 0.0 0 1

Nested Loop (cost=1,794.38..1,800.76 rows=1 width=497) (actual time=0.044..0.044 rows=0 loops=1)

100. 0.001 0.044 ↓ 0.0 0 1

Nested Loop (cost=1,794.10..1,799.39 rows=1 width=481) (actual time=0.044..0.044 rows=0 loops=1)

101. 0.000 0.043 ↓ 0.0 0 1

Nested Loop (cost=1,793.67..1,797.79 rows=1 width=456) (actual time=0.043..0.043 rows=0 loops=1)

102. 0.000 0.043 ↓ 0.0 0 1

Nested Loop (cost=1,793.26..1,796.75 rows=1 width=452) (actual time=0.043..0.043 rows=0 loops=1)

103. 0.000 0.043 ↓ 0.0 0 1

Nested Loop (cost=1,792.83..1,795.17 rows=1 width=423) (actual time=0.043..0.043 rows=0 loops=1)

104. 0.001 0.043 ↓ 0.0 0 1

Nested Loop (cost=1,792.41..1,793.59 rows=1 width=390) (actual time=0.043..0.043 rows=0 loops=1)

105. 0.001 0.042 ↓ 0.0 0 1

Merge Join (cost=1,791.99..1,792.01 rows=1 width=365) (actual time=0.042..0.042 rows=0 loops=1)

  • Merge Cond: (ct.cd_ctrc = wdf.cd_ctrc)
106. 0.008 0.041 ↓ 0.0 0 1

Sort (cost=1,791.96..1,791.96 rows=1 width=315) (actual time=0.041..0.041 rows=0 loops=1)

  • Sort Key: wce.cd_ctrc
  • Sort Method: quicksort Memory: 25kB
107. 0.010 0.033 ↓ 0.0 0 1

Hash Join (cost=1,791.33..1,791.95 rows=1 width=315) (actual time=0.033..0.033 rows=0 loops=1)

  • Hash Cond: (p.cd_pessoa = pgf.cd_pessoa_filial)
108. 0.000 0.000 ↓ 0.0 0

Unique (cost=1,768.61..1,768.97 rows=18 width=126) (never executed)

109. 0.000 0.000 ↓ 0.0 0

Sort (cost=1,768.61..1,768.66 rows=18 width=126) (never executed)

  • 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 27), f.cd_pessoa_matriz))
110. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=2.79..1,768.24 rows=18 width=126) (never executed)

111. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=2.64..170.40 rows=18 width=90) (never executed)

112. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=2.36..165.00 rows=18 width=74) (never executed)

113. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=1.94..117.48 rows=18 width=35) (never executed)

  • Join Filter: (pg.cd_empresa = f.cd_pessoa_matriz)
114. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=1.94..94.91 rows=18 width=35) (never executed)

115. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=1.52..47.39 rows=18 width=23) (never executed)

116. 0.000 0.000 ↓ 0.0 0

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

  • Hash Cond: (f.cd_pessoa_matriz = eg.cd_pessoa)
117. 0.000 0.000 ↓ 0.0 0

Seq Scan on filial f (cost=0.00..1.44 rows=35 width=8) (never executed)

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

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

119. 0.000 0.000 ↓ 0.0 0

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

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

Index Scan using pk_pessoa_juridica on pessoa_juridica pj (cost=0.29..2.48 rows=1 width=19) (never executed)

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

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

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

Materialize (cost=0.00..22.03 rows=2 width=4) (never executed)

123. 0.000 0.000 ↓ 0.0 0

Seq Scan on parametro_geral pg (cost=0.00..22.02 rows=2 width=4) (never executed)

124. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (cd_pessoa = f.cd_pessoa_filial)
125. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (cd_cidade = p.cd_cidade)
126. 0.000 0.000 ↓ 0.0 0

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

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

SubPlan (for Nested Loop)

128. 0.000 0.000 ↓ 0.0 0

Limit (cost=88.58..88.59 rows=1 width=4) (never executed)

129. 0.000 0.000 ↓ 0.0 0

Unique (cost=88.58..88.59 rows=1 width=4) (never executed)

130. 0.000 0.000 ↓ 0.0 0

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

  • Sort Key: p_1_4.cd_pessoa
131. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=1.14..88.57 rows=1 width=4) (never executed)

  • 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))
132. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=0.84..76.65 rows=35 width=16) (never executed)

133. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.42..60.75 rows=35 width=4) (never executed)

134. 0.000 0.000 ↓ 0.0 0

Seq Scan on filial f_1_3 (cost=0.00..1.35 rows=35 width=4) (never executed)

135. 0.000 0.000 ↓ 0.0 0

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

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

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

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

Index Scan using pk_pessoa_juridica on pessoa_juridica pjm_3 (cost=0.29..0.31 rows=1 width=19) (never executed)

  • Index Cond: (cd_pessoa = p_1_4.cd_pessoa)
  • Filter: (nr_cnpj IS NOT NULL)
138. 0.000 0.023 ↓ 0.0 0 1

Hash (cost=22.71..22.71 rows=1 width=287) (actual time=0.023..0.023 rows=0 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 8kB
139. 0.001 0.023 ↓ 0.0 0 1

Nested Loop (cost=17.77..22.71 rows=1 width=287) (actual time=0.023..0.023 rows=0 loops=1)

  • Join Filter: (pgeg.cd_pessoa = p_1.cd_pessoa)
140. 0.000 0.022 ↓ 0.0 0 1

Nested Loop (cost=0.70..5.49 rows=1 width=259) (actual time=0.022..0.022 rows=0 loops=1)

141. 0.000 0.022 ↓ 0.0 0 1

Nested Loop (cost=0.56..3.49 rows=1 width=255) (actual time=0.022..0.022 rows=0 loops=1)

142. 0.000 0.022 ↓ 0.0 0 1

Nested Loop (cost=0.43..2.67 rows=1 width=251) (actual time=0.022..0.022 rows=0 loops=1)

143. 0.022 0.022 ↓ 0.0 0 1

CTE Scan on with_ctrc_emitido wce (cost=0.00..0.02 rows=1 width=4) (actual time=0.022..0.022 rows=0 loops=1)

144. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_ctrc on ctrc ct (cost=0.43..2.65 rows=1 width=247) (never executed)

  • Index Cond: (cd_ctrc = wce.cd_ctrc)
145. 0.000 0.000 ↓ 0.0 0

Index Only Scan using pk_parametro_empresa_grupo on parametro_empresa_grupo pgeg (cost=0.13..0.70 rows=1 width=4) (never executed)

  • Index Cond: (cd_pessoa = ct.cd_pessoa_matriz)
  • Heap Fetches: 0
146. 0.000 0.000 ↓ 0.0 0

Index Only Scan using pk_parametro_filial on parametro_filial pgf (cost=0.14..1.99 rows=1 width=4) (never executed)

  • Index Cond: (cd_pessoa_filial = ct.cd_pessoa_filial)
  • Heap Fetches: 0
147. 0.000 0.000 ↓ 0.0 0

Sort (cost=17.07..17.08 rows=6 width=36) (never executed)

  • Sort Key: (COALESCE(p_1.nm_fantasia, p_1.nm_pessoa))
148. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.42..16.99 rows=6 width=36) (never executed)

149. 0.000 0.000 ↓ 0.0 0

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

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

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

  • Index Cond: (cd_pessoa = eg_1.cd_pessoa)
151. 0.000 0.000 ↓ 0.0 0

Sort (cost=0.03..0.04 rows=1 width=58) (never executed)

  • Sort Key: wdf.cd_ctrc
152. 0.000 0.000 ↓ 0.0 0

CTE Scan on with_diferenca_frete wdf (cost=0.00..0.02 rows=1 width=58) (never executed)

153. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_pessoa on pessoa pu (cost=0.42..1.58 rows=1 width=29) (never executed)

  • Index Cond: (cd_pessoa = ct.cd_pessoa_usuario)
154. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_pessoa on pessoa pr (cost=0.42..1.58 rows=1 width=33) (never executed)

  • Index Cond: (cd_pessoa = ct.cd_pessoa_embarque)
155. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_pessoa on pessoa pd (cost=0.42..1.58 rows=1 width=33) (never executed)

  • Index Cond: (cd_pessoa = ct.cd_pessoa_entrega)
156. 0.000 0.000 ↓ 0.0 0

Index Only Scan using pk_cliente on cliente cl (cost=0.42..1.05 rows=1 width=4) (never executed)

  • Index Cond: (cd_pessoa = ct.cd_pessoa_pagador)
  • Heap Fetches: 0
157. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_pessoa on pessoa pag (cost=0.42..1.58 rows=1 width=33) (never executed)

  • Index Cond: (cd_pessoa = ct.cd_pessoa_pagador)
  • Filter: (nm_pessoa ~* 'amaggi'::text)
158. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (cd_cidade = ct.cd_cidade_origem)
159. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (cd_uf = cio.cd_uf)
160. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (cd_cidade = ct.cd_cidade_destino)
161. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (cd_uf = cid.cd_uf)
162. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (cd_cidade = pag.cd_cidade)
163. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (cd_uf = cpag.cd_uf)
164. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (cd_cidade = pd.cd_cidade)
165. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (cd_uf = cdes.cd_uf)
166. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (cd_cidade = pr.cd_cidade)
167. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (cd_uf = crem.cd_uf)
168. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_pessoa on pessoa pt (cost=0.43..1.59 rows=1 width=29) (never executed)

  • 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)
169. 0.000 0.000 ↓ 0.0 0

CTE Scan on total_embarque te (cost=0.00..0.02 rows=1 width=68) (never executed)

170. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_lote_carregamento on lote_carregamento lc (cost=0.42..1.57 rows=1 width=48) (never executed)

  • Index Cond: (cd_lote = ct.cd_lote)
171. 0.000 0.000 ↓ 0.0 0

Index Only Scan using pk_motorista on motorista m (cost=0.42..1.57 rows=1 width=4) (never executed)

  • Index Cond: (cd_pessoa = ct.cd_pessoa_motorista)
  • Heap Fetches: 0
172. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_pessoa on pessoa pm (cost=0.42..1.58 rows=1 width=29) (never executed)

  • Index Cond: (cd_pessoa = m.cd_pessoa)
173. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_pessoa on pessoa ptp (cost=0.42..1.58 rows=1 width=29) (never executed)

  • Index Cond: (cd_pessoa = ct.cd_pessoa_transportadora)
174. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_pessoa on pessoa ptd (cost=0.42..1.58 rows=1 width=29) (never executed)

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

Index Scan using pk_pessoa on pessoa pc (cost=0.42..1.58 rows=1 width=33) (never executed)

  • Index Cond: (cd_pessoa = ct.cd_pessoa_consignatario)
176. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (cd_cidade = pc.cd_cidade)
177. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (cd_uf = ccon.cd_uf)
178. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_pessoa on pessoa pce (cost=0.42..1.58 rows=1 width=29) (never executed)

  • Index Cond: (cd_pessoa = ct.cd_pessoa_consignatario_embarque)
179. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_veiculo on veiculo v (cost=0.42..1.58 rows=1 width=25) (never executed)

  • Index Cond: (cd_veiculo = ct.cd_veiculo)
180. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_veiculo_marca on veiculo_marca vm (cost=0.14..0.71 rows=1 width=11) (never executed)

  • Index Cond: (cd_marca = v.cd_marca)
181. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_ordem_carregamento on ordem_carregamento oc (cost=0.43..1.59 rows=1 width=16) (never executed)

  • Index Cond: (cd_ordem = ct.cd_ordem)
182. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_agencia on agencia ao (cost=0.14..1.15 rows=1 width=17) (never executed)

  • Index Cond: (cd_agencia = oc.cd_agencia)
183. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_pessoa on pessoa uo (cost=0.42..1.58 rows=1 width=29) (never executed)

  • Index Cond: (cd_pessoa = COALESCE(oc.cd_pessoa_usuario_agenciador, oc.cd_pessoa_usuario))
184. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_agencia on agencia a (cost=0.14..1.15 rows=1 width=17) (never executed)

  • Index Cond: (cd_agencia = ct.cd_agencia)
185. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_ctrc_icms on ctrc_icms cicms (cost=0.43..1.59 rows=1 width=16) (never executed)

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

Index Scan using pk_ctrc_imposto_municipal on ctrc_imposto_municipal cim (cost=0.28..1.32 rows=1 width=10) (never executed)

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

CTE Scan on cartafrete cf (cost=0.00..0.04 rows=2 width=460) (never executed)

188. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_carta_frete_vale_pedagio_cd_ctrc on carta_frete_vale_pedagio cfv (cost=0.42..1.58 rows=1 width=11) (never executed)

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

Index Scan using pk_vale_pedagio on vale_pedagio vp (cost=0.13..0.70 rows=1 width=14) (never executed)

  • Index Cond: (cd_pessoa = cfv.cd_pessoa_vale_pedagio)
190. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_ctrc_comissao on ctrc_comissao cc (cost=0.43..1.59 rows=1 width=45) (never executed)

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

SubPlan (for Nested Loop Left Join)

192. 0.000 0.000 ↓ 0.0 0

Seq Scan on filial (cost=0.00..1.35 rows=35 width=4) (never executed)

193. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (cd_pessoa = 151,026)
  • Heap Fetches: 0
194. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_ctrc_cprb on ctrc_cprb cprb (cost=0.42..1.57 rows=1 width=10) (never executed)

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

Index Only Scan using pk_agencia_centro_custo on agencia_centro_custo acc (cost=0.14..7.06 rows=1 width=16) (never executed)

  • Index Cond: (cd_agencia = COALESCE(ct.cd_agencia, ct.cd_agencia))
  • Filter: (dt_vigencia = (SubPlan 24))
  • Heap Fetches: 0
196.          

SubPlan (for Index Only Scan)

197. 0.000 0.000 ↓ 0.0 0

Aggregate (cost=4.32..4.33 rows=1 width=4) (never executed)

198. 0.000 0.000 ↓ 0.0 0

Index Only Scan using pk_agencia_centro_custo on agencia_centro_custo acc2 (cost=0.14..4.31 rows=1 width=4) (never executed)

  • Index Cond: ((cd_agencia = acc.cd_agencia) AND (dt_vigencia <= ct.dt_emissao))
  • Heap Fetches: 0
199. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_ctrc_imposto_federal_credito on ctrc_imposto_federal_credito ifc (cost=0.43..1.59 rows=1 width=16) (never executed)

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

Index Scan using pk_ctrc_imposto_federal_debito on ctrc_imposto_federal_debito ifd (cost=0.43..1.59 rows=1 width=16) (never executed)

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

Index Scan using pk_ctrc_complemento on ctrc_complemento ccom (cost=0.29..1.43 rows=1 width=16) (never executed)

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

Index Scan using idx_associado_dt_inicio on associado ass (cost=0.12..0.70 rows=1 width=16) (never executed)

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

Index Scan using pk_categoria_associado on categoria_associado cass (cost=0.15..2.37 rows=1 width=36) (never executed)

  • Index Cond: (cd_categoria = ass.cd_categoria)
204. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_pessoa on pessoa seg (cost=0.42..1.58 rows=1 width=29) (never executed)

  • Index Cond: (cd_pessoa = ct.cd_pessoa_seguradora)
205. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_embarque on embarque e (cost=0.29..1.42 rows=1 width=16) (never executed)

  • Index Cond: (nr_embarque = ct.nr_embarque)
206. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_pessoa on pessoa pem (cost=0.42..1.64 rows=1 width=29) (never executed)

  • Index Cond: (cd_pessoa = e.cd_pessoa_motorista)
207. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_veiculo on veiculo vem (cost=0.42..1.68 rows=1 width=11) (never executed)

  • Index Cond: (cd_veiculo = e.cd_veiculo)
208. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_agencia on agencia aga (cost=0.14..1.15 rows=1 width=17) (never executed)

  • Index Cond: (cd_agencia = cc.cd_agencia_agenciador)
209. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_agencia on agencia agg (cost=0.14..1.15 rows=1 width=17) (never executed)

  • Index Cond: (cd_agencia = cc.cd_agencia_gerente)
210. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_agencia on agencia agm (cost=0.14..1.15 rows=1 width=17) (never executed)

  • Index Cond: (cd_agencia = cc.cd_agencia_manifestador)
211. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_agencia on agencia ags (cost=0.14..1.15 rows=1 width=17) (never executed)

  • Index Cond: (cd_agencia = cc.cd_agencia_supervisor)
212. 0.000 0.000 ↓ 0.0 0

Seq Scan on administradora_pagamento_eletronico ape (cost=0.00..1.10 rows=10 width=15) (never executed)

213. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_ctrc on ctrc ctnovo (cost=0.43..1.60 rows=1 width=14) (never executed)

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

Index Scan using pk_ctrc_cte on ctrc_cte cte (cost=0.43..1.61 rows=1 width=49) (never executed)

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

Index Scan using pk_motivo_cancelamento on motivo_cancelamento mc (cost=0.14..0.71 rows=1 width=28) (never executed)

  • Index Cond: (cd_motivo = ct.cd_motivo)
216. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_ctrc on ctrc ctcomp (cost=0.43..1.60 rows=1 width=12) (never executed)

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

SubPlan (for Result)

218. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_ctrc_documento on ctrc_documento (cost=0.42..2.64 rows=1 width=9) (never executed)

  • Index Cond: ((cd_ctrc = ct.cd_ctrc) AND (id_documento = 1))
219. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_ctrc_documento on ctrc_documento ctrc_documento_1 (cost=0.42..2.64 rows=1 width=9) (never executed)

  • Index Cond: ((cd_ctrc = ct.cd_ctrc) AND (id_documento = 2))
220. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_ctrc_documento on ctrc_documento ctrc_documento_2 (cost=0.42..2.64 rows=1 width=9) (never executed)

  • Index Cond: ((cd_ctrc = ct.cd_ctrc) AND (id_documento = 3))
221. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_ctrc_documento on ctrc_documento ctrc_documento_3 (cost=0.42..2.64 rows=1 width=9) (never executed)

  • Index Cond: ((cd_ctrc = ct.cd_ctrc) AND (id_documento = 4))
222. 0.000 0.000 ↓ 0.0 0

Limit (cost=5.18..5.18 rows=1 width=34) (never executed)

223. 0.000 0.000 ↓ 0.0 0

Sort (cost=5.18..5.18 rows=1 width=34) (never executed)

  • Sort Key: e_.id_tipo_endereco
224. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=0.71..5.17 rows=1 width=34) (never executed)

225. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_endereco_cd_pessoa on endereco e_ (cost=0.42..2.64 rows=1 width=34) (never executed)

  • Index Cond: (cd_pessoa = ptd.cd_pessoa)
226. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_bairro on bairro b_ (cost=0.29..2.51 rows=1 width=17) (never executed)

  • Index Cond: (cd_bairro = e_.cd_bairro)
227. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.99..5.51 rows=1 width=32) (never executed)

228. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.85..5.30 rows=1 width=19) (never executed)

229. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.70..5.14 rows=1 width=16) (never executed)

230. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (cd_pessoa = ptd.cd_pessoa)
231. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (cd_cidade = pe_.cd_cidade)
232. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (cd_uf = c_.cd_uf)
233. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_pais on pais p_ (cost=0.14..0.19 rows=1 width=13) (never executed)

  • Index Cond: (cd_pais = u_.cd_pais)
234. 0.000 0.000 ↓ 0.0 0

Limit (cost=5.18..5.18 rows=1 width=34) (never executed)

235. 0.000 0.000 ↓ 0.0 0

Sort (cost=5.18..5.18 rows=1 width=34) (never executed)

  • Sort Key: e__1.id_tipo_endereco
236. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=0.71..5.17 rows=1 width=34) (never executed)

237. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_endereco_cd_pessoa on endereco e__1 (cost=0.42..2.64 rows=1 width=34) (never executed)

  • Index Cond: (cd_pessoa = ptp.cd_pessoa)
238. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_bairro on bairro b__1 (cost=0.29..2.51 rows=1 width=17) (never executed)

  • Index Cond: (cd_bairro = e__1.cd_bairro)
239. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.99..5.51 rows=1 width=32) (never executed)

240. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.85..5.30 rows=1 width=19) (never executed)

241. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.70..5.14 rows=1 width=16) (never executed)

242. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (cd_pessoa = ptp.cd_pessoa)
243. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (cd_cidade = pe__1.cd_cidade)
244. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (cd_uf = c__1.cd_uf)
245. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_pais on pais p__1 (cost=0.14..0.19 rows=1 width=13) (never executed)

  • Index Cond: (cd_pais = u__1.cd_pais)
246. 0.000 0.000 ↓ 0.0 0

Limit (cost=10.20..10.20 rows=1 width=38) (never executed)

247. 0.000 0.000 ↓ 0.0 0

Sort (cost=10.20..10.21 rows=3 width=38) (never executed)

  • Sort Key: cp.vl_peso DESC
248. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.71..10.18 rows=3 width=38) (never executed)

249. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_ctrc_produto_cd_ctrc on ctrc_produto cp (cost=0.43..2.69 rows=3 width=20) (never executed)

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

Index Scan using pk_produto_venda on produto_transportado p_2 (cost=0.28..2.49 rows=1 width=26) (never executed)

  • Index Cond: (cd_produto = cp.cd_produto)
251. 0.000 0.000 ↓ 0.0 0

Aggregate (cost=5.03..5.04 rows=1 width=32) (never executed)

252. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.57..5.02 rows=1 width=22) (never executed)

253. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_ctrc_corretor_cd_ctrc on ctrc_corretor ct_crr_ (cost=0.42..2.64 rows=1 width=4) (never executed)

  • Index Cond: (cd_ctrc = ct.cd_ctrc)
254. 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)
255. 0.000 0.000 ↓ 0.0 0

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

256. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_carta_frete_diaria_cd_ctrc on carta_frete_diaria (cost=0.29..2.51 rows=1 width=11) (never executed)

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

Index Scan using pk_pessoa_juridica on pessoa_juridica pjt (cost=0.29..2.52 rows=1 width=4) (never executed)

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

Index Scan using idx_ctrc_observacao_cd_ctrc on ctrc_observacao co (cost=0.43..2.74 rows=5 width=77) (never executed)

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

Subquery Scan on pf_1 (cost=212.49..212.52 rows=1 width=0) (never executed)

260. 0.000 0.000 ↓ 0.0 0

Unique (cost=212.49..212.51 rows=1 width=126) (never executed)

261. 0.000 0.000 ↓ 0.0 0

Sort (cost=212.49..212.50 rows=1 width=126) (never executed)

  • Sort Key: (COALESCE(p_3.nm_fantasia, p_3.nm_pessoa)), p_3.cd_cidade, (((ci_2.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 19), f_2.cd_pessoa_matriz))
262. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=1.56..212.48 rows=1 width=126) (never executed)

263. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=1.42..123.71 rows=1 width=90) (never executed)

264. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=1.14..121.21 rows=1 width=74) (never executed)

265. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.71..118.56 rows=1 width=35) (never executed)

  • Join Filter: (f_2.cd_pessoa_matriz = eg_2.cd_pessoa)
266. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=0.71..117.34 rows=1 width=35) (never executed)

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

Nested Loop Left Join (cost=0.71..95.29 rows=1 width=35) (never executed)

  • Join Filter: (pf_2.cd_pessoa = f_2.cd_pessoa_filial)
  • Filter: (COALESCE((SubPlan 20), f_2.cd_pessoa_matriz) = ct.cd_pessoa_matriz)
268. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=0.29..4.05 rows=1 width=23) (never executed)

  • Join Filter: (pj_1.cd_pessoa = f_2.cd_pessoa_filial)
269. 0.000 0.000 ↓ 0.0 0

Seq Scan on filial f_2 (cost=0.00..1.52 rows=1 width=8) (never executed)

  • Filter: ((cd_pessoa_filial = ct.cd_pessoa_transportadora_doc) AND (id_ativo = 1))
270. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (cd_pessoa = ct.cd_pessoa_transportadora_doc)
  • Filter: (nr_cnpj IS NOT NULL)
271. 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)
272.          

SubPlan (for Nested Loop Left Join)

273. 0.000 0.000 ↓ 0.0 0

Limit (cost=88.58..88.59 rows=1 width=4) (never executed)

274. 0.000 0.000 ↓ 0.0 0

Unique (cost=88.58..88.59 rows=1 width=4) (never executed)

275. 0.000 0.000 ↓ 0.0 0

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

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

Nested Loop Left Join (cost=1.14..88.57 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))
277. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=0.84..76.65 rows=35 width=16) (never executed)

278. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.42..60.75 rows=35 width=4) (never executed)

279. 0.000 0.000 ↓ 0.0 0

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

280. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (cd_pessoa = f_1_1.cd_pessoa_filial)
  • Heap Fetches: 0
281. 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)
282. 0.000 0.000 ↓ 0.0 0

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

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

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

284. 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)
285. 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)
286. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (cd_cidade = p_3.cd_cidade)
287. 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_2.cd_uf)
288.          

SubPlan (for Nested Loop)

289. 0.000 0.000 ↓ 0.0 0

Limit (cost=88.58..88.59 rows=1 width=4) (never executed)

290. 0.000 0.000 ↓ 0.0 0

Unique (cost=88.58..88.59 rows=1 width=4) (never executed)

291. 0.000 0.000 ↓ 0.0 0

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

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

Nested Loop Left Join (cost=1.14..88.57 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))
293. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=0.84..76.65 rows=35 width=16) (never executed)

294. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.42..60.75 rows=35 width=4) (never executed)

295. 0.000 0.000 ↓ 0.0 0

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

296. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (cd_pessoa = f_1.cd_pessoa_filial)
  • Heap Fetches: 0
297. 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)
298. 0.000 0.000 ↓ 0.0 0

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

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

Subquery Scan on pf_3 (cost=1,768.61..1,769.15 rows=18 width=8) (never executed)

300. 0.000 0.000 ↓ 0.0 0

Unique (cost=1,768.61..1,768.97 rows=18 width=126) (never executed)

301. 0.000 0.000 ↓ 0.0 0

Sort (cost=1,768.61..1,768.66 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_3.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 22), f_3.cd_pessoa_matriz))
302. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=2.79..1,768.24 rows=18 width=126) (never executed)

303. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=2.64..170.40 rows=18 width=90) (never executed)

304. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=2.36..165.00 rows=18 width=74) (never executed)

305. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=1.94..117.48 rows=18 width=35) (never executed)

  • Join Filter: (pg_2.cd_empresa = f_3.cd_pessoa_matriz)
306. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=1.94..94.91 rows=18 width=35) (never executed)

307. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=1.52..47.39 rows=18 width=23) (never executed)

308. 0.000 0.000 ↓ 0.0 0

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

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

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

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

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

311. 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)
312. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (cd_pessoa = f_3.cd_pessoa_filial)
  • Filter: (nr_cnpj IS NOT NULL)
313. 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)
314. 0.000 0.000 ↓ 0.0 0

Materialize (cost=0.00..22.03 rows=2 width=4) (never executed)

315. 0.000 0.000 ↓ 0.0 0

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

316. 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)
317. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (cd_cidade = p_4.cd_cidade)
318. 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_3.cd_uf)
319.          

SubPlan (for Nested Loop)

320. 0.000 0.000 ↓ 0.0 0

Limit (cost=88.58..88.59 rows=1 width=4) (never executed)

321. 0.000 0.000 ↓ 0.0 0

Unique (cost=88.58..88.59 rows=1 width=4) (never executed)

322. 0.000 0.000 ↓ 0.0 0

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

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

Nested Loop Left Join (cost=1.14..88.57 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))
324. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=0.84..76.65 rows=35 width=16) (never executed)

325. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.42..60.75 rows=35 width=4) (never executed)

326. 0.000 0.000 ↓ 0.0 0

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

327. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (cd_pessoa = f_1_2.cd_pessoa_filial)
  • Heap Fetches: 0
328. 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)
329. 0.000 0.000 ↓ 0.0 0

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

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