explain.depesz.com

PostgreSQL's explain analyze made readable

Result: ose5

Settings
# exclusive inclusive rows x rows loops node
1. 2.335 538,130.147 ↓ 74.0 222 1

Sort (cost=16,800,169.42..16,800,169.43 rows=3 width=1,521) (actual time=538,130.124..538,130.147 rows=222 loops=1)

  • Sort Key: (CASE WHEN (cfpa.id_tipo = 5) THEN (cfd.dt_lancamento)::date ELSE cf.dt_emissao END), cf.nr_carta_frete, (CASE cfpa.id_tipo WHEN 0 THEN 'Adiantamento'::text WHEN 1 THEN 'Saldo'::text WHEN 2 THEN 'V. Comb.'::text WHEN 3 THEN 'Diária Viagem'::text WHEN 4 THEN 'Estadia Carregado'::text WHEN 5 THEN 'Diária Motorista'::text ELSE NULL::text END), cfp.dt_recebimento, (COALESCE((cfpa.nr_parcela)::integer, (cfp.nr_parcela)::integer, 1))
  • Sort Method: quicksort Memory: 249kB
2.          

CTE with_carta_frete_outros_descontos

3. 17.793 21.072 ↑ 1.0 10,008 1

HashAggregate (cost=216.10..341.20 rows=10,008 width=36) (actual time=14.810..21.072 rows=10,008 loops=1)

  • Group Key: cfod.cd_ctrc
4. 3.279 3.279 ↑ 1.0 10,073 1

Seq Scan on carta_frete_outros_descontos cfod (cost=0.00..165.73 rows=10,073 width=9) (actual time=0.051..3.279 rows=10,073 loops=1)

5. 0.164 538,127.812 ↓ 74.0 222 1

Append (cost=966.51..16,799,828.20 rows=3 width=1,521) (actual time=511,193.618..538,127.812 rows=222 loops=1)

6. 10.183 538,127.316 ↓ 222.0 222 1

Nested Loop (cost=966.51..16,797,754.18 rows=1 width=1,241) (actual time=511,193.610..538,127.316 rows=222 loops=1)

7. 1.309 538,094.477 ↓ 222.0 222 1

Nested Loop (cost=966.09..16,797,644.56 rows=1 width=716) (actual time=511,192.135..538,094.477 rows=222 loops=1)

8. 368.779 538,091.170 ↓ 222.0 222 1

Nested Loop Left Join (cost=965.67..16,797,640.12 rows=1 width=720) (actual time=511,192.032..538,091.170 rows=222 loops=1)

  • Join Filter: (wcfod.cd_ctrc = cf.cd_ctrc)
  • Rows Removed by Join Filter: 2,221,774
9. 0.584 537,333.669 ↓ 222.0 222 1

Nested Loop Left Join (cost=965.67..16,797,314.86 rows=1 width=688) (actual time=511,163.505..537,333.669 rows=222 loops=1)

10. 0.645 537,332.863 ↓ 222.0 222 1

Nested Loop Left Join (cost=965.54..16,797,314.71 rows=1 width=679) (actual time=511,163.455..537,332.863 rows=222 loops=1)

11. 0.790 537,330.664 ↓ 222.0 222 1

Nested Loop Left Join (cost=965.11..16,797,306.27 rows=1 width=659) (actual time=511,163.395..537,330.664 rows=222 loops=1)

12. 0.825 537,329.208 ↓ 222.0 222 1

Nested Loop Left Join (cost=964.97..16,797,306.11 rows=1 width=655) (actual time=511,163.336..537,329.208 rows=222 loops=1)

13. 0.720 537,327.717 ↓ 222.0 222 1

Nested Loop Left Join (cost=964.84..16,797,305.95 rows=1 width=641) (actual time=511,163.259..537,327.717 rows=222 loops=1)

14. 0.709 537,326.109 ↓ 222.0 222 1

Nested Loop Left Join (cost=964.70..16,797,305.79 rows=1 width=642) (actual time=511,163.190..537,326.109 rows=222 loops=1)

15. 0.621 537,323.402 ↓ 222.0 222 1

Nested Loop Left Join (cost=964.41..16,797,305.49 rows=1 width=630) (actual time=511,163.116..537,323.402 rows=222 loops=1)

16. 0.576 537,321.893 ↓ 222.0 222 1

Nested Loop Left Join (cost=963.99..16,797,305.05 rows=1 width=602) (actual time=511,163.059..537,321.893 rows=222 loops=1)

17. 0.809 537,321.095 ↓ 222.0 222 1

Nested Loop Left Join (cost=963.71..16,797,304.74 rows=1 width=594) (actual time=511,162.999..537,321.095 rows=222 loops=1)

18. 0.845 537,319.620 ↓ 222.0 222 1

Nested Loop Left Join (cost=963.56..16,797,304.02 rows=1 width=579) (actual time=511,162.929..537,319.620 rows=222 loops=1)

19. 0.965 537,317.443 ↓ 222.0 222 1

Nested Loop Left Join (cost=963.14..16,797,295.58 rows=1 width=555) (actual time=511,162.870..537,317.443 rows=222 loops=1)

20. 7.793 537,315.368 ↓ 222.0 222 1

Nested Loop Left Join (cost=962.87..16,797,295.29 rows=1 width=542) (actual time=511,162.791..537,315.368 rows=222 loops=1)

21. 1.188 537,305.577 ↓ 222.0 222 1

Nested Loop Left Join (cost=953.98..16,797,278.38 rows=1 width=536) (actual time=511,162.206..537,305.577 rows=222 loops=1)

  • Filter: CASE WHEN (cte.cd_ctrc IS NOT NULL) THEN (cte.cd_status = 100) ELSE true END
22. 0.921 537,300.837 ↓ 222.0 222 1

Nested Loop Left Join (cost=953.56..16,797,269.93 rows=1 width=536) (actual time=511,162.037..537,300.837 rows=222 loops=1)

23. 0.644 537,294.144 ↓ 222.0 222 1

Nested Loop Left Join (cost=953.14..16,797,261.49 rows=1 width=514) (actual time=511,161.850..537,294.144 rows=222 loops=1)

24. 0.552 537,292.390 ↓ 222.0 222 1

Nested Loop Left Join (cost=952.72..16,797,253.05 rows=1 width=486) (actual time=511,161.797..537,292.390 rows=222 loops=1)

25. 0.528 537,290.950 ↓ 222.0 222 1

Nested Loop Left Join (cost=952.58..16,797,252.89 rows=1 width=471) (actual time=511,161.706..537,290.950 rows=222 loops=1)

26. 0.686 537,289.534 ↓ 222.0 222 1

Nested Loop (cost=952.30..16,797,248.46 rows=1 width=466) (actual time=511,161.613..537,289.534 rows=222 loops=1)

27. 0.959 537,287.294 ↓ 222.0 222 1

Nested Loop (cost=951.87..16,797,240.38 rows=1 width=462) (actual time=511,161.517..537,287.294 rows=222 loops=1)

28. 1.153 537,284.559 ↓ 222.0 222 1

Nested Loop Left Join (cost=951.45..16,797,239.90 rows=1 width=460) (actual time=511,161.415..537,284.559 rows=222 loops=1)

29. 916.906 537,278.966 ↓ 222.0 222 1

Nested Loop (cost=951.02..16,797,239.33 rows=1 width=394) (actual time=511,161.196..537,278.966 rows=222 loops=1)

30. 5,440.696 520,451.188 ↓ 44,196.9 1,988,859 1

Nested Loop (cost=950.59..16,797,215.77 rows=45 width=372) (actual time=143.187..520,451.188 rows=1,988,859 loops=1)

  • Join Filter: (ct.cd_ctrc = cf.cd_ctrc)
31. 5,220.322 505,066.197 ↓ 48,508.8 1,988,859 1

Nested Loop (cost=950.16..16,797,194.39 rows=41 width=306) (actual time=143.135..505,066.197 rows=1,988,859 loops=1)

  • Join Filter: (ct.cd_ctrc = cfpa.cd_ctrc)
32. 4,428.447 489,900.350 ↓ 40,594.0 1,989,105 1

Merge Join (cost=949.74..16,797,169.49 rows=49 width=228) (actual time=143.066..489,900.350 rows=1,989,105 loops=1)

  • Merge Cond: (cfp.cd_ctrc = ct.cd_ctrc)
33. 5,419.207 5,419.207 ↑ 1.0 2,012,786 1

Index Scan using pk_carta_frete_pagamento on carta_frete_pagamento cfp (cost=0.43..93,646.22 rows=2,012,786 width=28) (actual time=0.059..5,419.207 rows=2,012,786 loops=1)

34. 2,727.957 480,052.696 ↓ 70,162.8 2,034,721 1

Materialize (cost=949.31..16,698,490.64 rows=29 width=200) (actual time=142.999..480,052.696 rows=2,034,721 loops=1)

35. 2,626.194 477,324.739 ↓ 37,776.3 1,095,512 1

Nested Loop (cost=949.31..16,698,490.57 rows=29 width=200) (actual time=142.987..477,324.739 rows=1,095,512 loops=1)

36. 3,352.013 467,029.940 ↓ 37,776.4 1,095,515 1

Nested Loop (cost=948.89..16,698,245.88 rows=29 width=164) (actual time=142.926..467,029.940 rows=1,095,515 loops=1)

37. 3,078.625 456,009.322 ↓ 37,776.4 1,095,515 1

Nested Loop (cost=948.47..16,698,001.20 rows=29 width=140) (actual time=142.873..456,009.322 rows=1,095,515 loops=1)

  • Join Filter: (p_2.cd_pessoa = ct.cd_pessoa_filial)
  • Rows Removed by Join Filter: 10,955,150
38. 130,835.126 450,739.667 ↓ 37,776.4 1,095,515 1

Index Scan using pk_ctrc on ctrc ct (cost=2.70..16,697,050.16 rows=29 width=76) (actual time=8.313..450,739.667 rows=1,095,515 loops=1)

  • Filter: ((dt_cancelamento IS NULL) AND (cd_pessoa_matriz = 2) AND (CASE WHEN (hashed SubPlan 13) THEN 1 ELSE CASE WHEN (SubPlan 14) THEN 2 ELSE 3 END END = 3) AND (CASE WHEN (hashed SubPlan 15) THEN 1 ELSE CASE WHEN (SubPlan 16) THEN 2 ELSE 3 END END = 3))
  • Rows Removed by Filter: 93,534
39.          

SubPlan (for Index Scan)

40. 7.686 7.686 ↑ 1.0 11 1

Seq Scan on filial f_3 (cost=0.00..1.11 rows=11 width=4) (actual time=7.684..7.686 rows=11 loops=1)

41. 161,047.173 161,047.173 ↓ 1.0 465 1,095,559

Seq Scan on veiculo_proprio vp (cost=0.00..12.81 rows=446 width=4) (actual time=0.004..0.147 rows=465 loops=1,095,559)

  • Filter: ((dt_baixa IS NULL) OR (dt_baixa >= ct.dt_emissao))
  • Rows Removed by Filter: 80
42. 0.007 0.007 ↑ 1.0 11 1

Seq Scan on filial f_4 (cost=0.00..1.11 rows=11 width=4) (actual time=0.005..0.007 rows=11 loops=1)

43. 158,849.675 158,849.675 ↓ 1.0 465 1,095,515

Seq Scan on veiculo_proprio vp_1 (cost=0.00..12.81 rows=446 width=4) (actual time=0.003..0.145 rows=465 loops=1,095,515)

  • Filter: ((dt_baixa IS NULL) OR (dt_baixa >= ct.dt_emissao))
  • Rows Removed by Filter: 80
44. 2,056.480 2,191.030 ↑ 1.0 11 1,095,515

Materialize (cost=945.77..946.28 rows=11 width=72) (actual time=0.000..0.002 rows=11 loops=1,095,515)

45. 0.007 134.550 ↑ 1.0 11 1

Nested Loop (cost=945.77..946.22 rows=11 width=72) (actual time=134.534..134.550 rows=11 loops=1)

46. 0.035 7.194 ↑ 1.0 1 1

Sort (cost=9.47..9.48 rows=1 width=36) (actual time=7.193..7.194 rows=1 loops=1)

  • Sort Key: (COALESCE(p_1.nm_fantasia, p_1.nm_pessoa))
  • Sort Method: quicksort Memory: 25kB
47. 0.008 7.159 ↑ 1.0 1 1

Nested Loop (cost=0.42..9.46 rows=1 width=36) (actual time=7.156..7.159 rows=1 loops=1)

48. 0.041 0.041 ↑ 1.0 1 1

Index Scan using pk_pessoa on pessoa p_1 (cost=0.42..8.44 rows=1 width=40) (actual time=0.039..0.041 rows=1 loops=1)

  • Index Cond: (cd_pessoa = 2)
49. 7.110 7.110 ↑ 1.0 1 1

Seq Scan on empresa_grupo eg (cost=0.00..1.01 rows=1 width=4) (actual time=7.109..7.110 rows=1 loops=1)

  • Filter: ((cd_pessoa = 2) AND (id_ativo = 1))
50. 0.011 127.349 ↑ 1.0 11 1

Unique (cost=936.29..936.51 rows=11 width=126) (actual time=127.337..127.349 rows=11 loops=1)

51. 0.096 127.338 ↑ 1.0 11 1

Sort (cost=936.29..936.32 rows=11 width=126) (actual time=127.336..127.338 rows=11 loops=1)

  • Sort Key: (COALESCE(p_2.nm_fantasia, p_2.nm_pessoa)), p_2.cd_pessoa, p_2.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 17), f.cd_pessoa_matriz))
  • Sort Method: quicksort Memory: 26kB
52. 0.103 127.242 ↑ 1.0 11 1

Nested Loop (cost=1.55..936.10 rows=11 width=126) (actual time=124.786..127.242 rows=11 loops=1)

53. 0.039 27.314 ↑ 1.0 11 1

Nested Loop (cost=1.41..283.76 rows=11 width=91) (actual time=26.393..27.314 rows=11 loops=1)

54. 0.022 22.875 ↑ 1.0 11 1

Nested Loop (cost=1.13..280.45 rows=11 width=75) (actual time=22.472..22.875 rows=11 loops=1)

55. 0.008 22.578 ↑ 1.0 11 1

Nested Loop (cost=0.71..187.63 rows=11 width=35) (actual time=22.441..22.578 rows=11 loops=1)

  • Join Filter: (f.cd_pessoa_matriz = eg_1.cd_pessoa)
56. 0.008 0.008 ↑ 1.0 1 1

Seq Scan on empresa_grupo eg_1 (cost=0.00..1.01 rows=1 width=4) (actual time=0.007..0.008 rows=1 loops=1)

  • Filter: (id_ativo = 1)
57. 0.014 22.562 ↑ 1.0 11 1

Nested Loop Left Join (cost=0.71..186.48 rows=11 width=35) (actual time=22.432..22.562 rows=11 loops=1)

  • Join Filter: (pg.cd_empresa = f.cd_pessoa_matriz)
58. 0.029 15.420 ↑ 1.0 11 1

Nested Loop Left Join (cost=0.71..185.31 rows=11 width=35) (actual time=15.310..15.420 rows=11 loops=1)

59. 0.027 15.336 ↑ 1.0 11 1

Nested Loop Left Join (cost=0.29..92.52 rows=11 width=23) (actual time=15.271..15.336 rows=11 loops=1)

60. 0.008 0.008 ↑ 1.0 11 1

Seq Scan on filial f (cost=0.00..1.14 rows=11 width=8) (actual time=0.003..0.008 rows=11 loops=1)

  • Filter: (id_ativo = 1)
61. 15.301 15.301 ↑ 1.0 1 11

Index Scan using pk_pessoa_juridica on pessoa_juridica pj (cost=0.29..8.31 rows=1 width=19) (actual time=1.391..1.391 rows=1 loops=11)

  • Index Cond: (cd_pessoa = f.cd_pessoa_filial)
  • Filter: (nr_cnpj IS NOT NULL)
62. 0.055 0.055 ↓ 0.0 0 11

Index Scan using pk_pessoa_fisica on pessoa_fisica pf (cost=0.42..8.44 rows=1 width=16) (actual time=0.005..0.005 rows=0 loops=11)

  • Index Cond: (cd_pessoa = f.cd_pessoa_filial)
  • Filter: (nr_cpf IS NOT NULL)
63. 0.019 7.128 ↑ 1.0 1 11

Materialize (cost=0.00..1.01 rows=1 width=4) (actual time=0.647..0.648 rows=1 loops=11)

64. 7.109 7.109 ↑ 1.0 1 1

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

65. 0.275 0.275 ↑ 1.0 1 11

Index Scan using pk_pessoa on pessoa p_2 (cost=0.42..8.44 rows=1 width=44) (actual time=0.025..0.025 rows=1 loops=11)

  • Index Cond: (cd_pessoa = f.cd_pessoa_filial)
66. 4.400 4.400 ↑ 1.0 1 11

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

  • Index Cond: (cd_cidade = p_2.cd_cidade)
67. 0.110 0.110 ↑ 1.0 1 11

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

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

SubPlan (for Nested Loop)

69. 0.011 99.715 ↑ 1.0 1 11

Limit (cost=59.12..59.12 rows=1 width=4) (actual time=9.064..9.065 rows=1 loops=11)

70. 0.022 99.704 ↑ 1.0 1 11

Unique (cost=59.12..59.12 rows=1 width=4) (actual time=9.064..9.064 rows=1 loops=11)

71. 0.121 99.682 ↑ 1.0 1 11

Sort (cost=59.12..59.12 rows=1 width=4) (actual time=9.062..9.062 rows=1 loops=11)

  • Sort Key: p_1_1.cd_pessoa
  • Sort Method: quicksort Memory: 25kB
72. 0.198 99.561 ↑ 1.0 1 11

Nested Loop Left Join (cost=1.13..59.11 rows=1 width=4) (actual time=0.025..9.051 rows=1 loops=11)

  • Filter: ((substr((pjm.nr_cnpj)::text, 1, 12) = (substr((pj.nr_cnpj)::text, 1, 8) || '0001'::text)) OR (pfm.nr_cpf = pf.nr_cpf))
  • Rows Removed by Filter: 10
73. 0.121 41.283 ↑ 1.0 11 11

Nested Loop Left Join (cost=0.84..55.30 rows=11 width=16) (actual time=0.017..3.753 rows=11 loops=11)

74. 0.088 4.620 ↑ 1.0 11 11

Nested Loop (cost=0.42..49.92 rows=11 width=4) (actual time=0.011..0.420 rows=11 loops=11)

75. 0.055 0.055 ↑ 1.0 11 11

Seq Scan on filial f_1_1 (cost=0.00..1.11 rows=11 width=4) (actual time=0.002..0.005 rows=11 loops=11)

76. 4.477 4.477 ↑ 1.0 1 121

Index Only Scan using pk_pessoa on pessoa p_1_1 (cost=0.42..4.44 rows=1 width=4) (actual time=0.037..0.037 rows=1 loops=121)

  • Index Cond: (cd_pessoa = f_1_1.cd_pessoa_filial)
  • Heap Fetches: 0
77. 36.542 36.542 ↓ 0.0 0 121

Index Scan using pk_pessoa_fisica on pessoa_fisica pfm (cost=0.42..0.49 rows=1 width=16) (actual time=0.302..0.302 rows=0 loops=121)

  • Index Cond: (cd_pessoa = p_1_1.cd_pessoa)
  • Filter: (nr_cpf IS NOT NULL)
78. 58.080 58.080 ↑ 1.0 1 121

Index Scan using pk_pessoa_juridica on pessoa_juridica pjm (cost=0.29..0.32 rows=1 width=19) (actual time=0.480..0.480 rows=1 loops=121)

  • Index Cond: (cd_pessoa = p_1_1.cd_pessoa)
  • Filter: (nr_cnpj IS NOT NULL)
79. 7,668.605 7,668.605 ↑ 1.0 1 1,095,515

Index Scan using pk_pessoa on pessoa pp (cost=0.42..8.44 rows=1 width=28) (actual time=0.007..0.007 rows=1 loops=1,095,515)

  • Index Cond: (cd_pessoa = ct.cd_pessoa_pagador)
80. 7,668.605 7,668.605 ↑ 1.0 1 1,095,515

Index Scan using pk_pessoa on pessoa pd (cost=0.42..8.44 rows=1 width=40) (actual time=0.007..0.007 rows=1 loops=1,095,515)

  • Index Cond: (cd_pessoa = ct.cd_pessoa_transportadora_doc)
81. 9,945.525 9,945.525 ↑ 1.0 1 1,989,105

Index Scan using pk_carta_frete_parcelamento on carta_frete_parcelamento cfpa (cost=0.43..0.50 rows=1 width=82) (actual time=0.005..0.005 rows=1 loops=1,989,105)

  • Index Cond: ((cd_ctrc = cfp.cd_ctrc) AND (id_tipo = cfp.id_tipo) AND (nr_parcela = cfp.nr_parcela))
82. 9,944.295 9,944.295 ↑ 1.0 1 1,988,859

Index Scan using pk_carta_frete on carta_frete cf (cost=0.43..0.51 rows=1 width=70) (actual time=0.005..0.005 rows=1 loops=1,988,859)

  • Index Cond: (cd_ctrc = cfpa.cd_ctrc)
83. 15,910.872 15,910.872 ↓ 0.0 0 1,988,859

Index Scan using idx_titulo_cd_movimento on titulo t (cost=0.43..0.51 rows=1 width=22) (actual time=0.008..0.008 rows=0 loops=1,988,859)

  • Index Cond: (cd_movimento = cfp.cd_movimento)
  • Filter: ((dt_quitacao >= '2020-05-01'::date) AND (dt_quitacao <= '2020-05-01'::date))
  • Rows Removed by Filter: 1
84. 4.440 4.440 ↑ 1.0 1 222

Index Scan using idx_vw_carta_frete_comprovante on vw_carta_frete_comprovante vwcfc (cost=0.43..0.57 rows=1 width=74) (actual time=0.020..0.020 rows=1 loops=222)

  • Index Cond: ((cd_ctrc = cfpa.cd_ctrc) AND (id_tipo = cfpa.id_tipo) AND (nr_parcela = cfpa.nr_parcela))
85. 1.776 1.776 ↑ 1.0 1 222

Index Scan using pk_movimento on movimento m (cost=0.43..0.47 rows=1 width=10) (actual time=0.008..0.008 rows=1 loops=222)

  • Index Cond: (cd_movimento = cfp.cd_movimento)
86. 1.554 1.554 ↑ 1.0 1 222

Index Scan using pk_titulo_debito on titulo_debito td (cost=0.42..8.08 rows=1 width=8) (actual time=0.007..0.007 rows=1 loops=222)

  • Index Cond: (cd_titulo = t.cd_titulo)
87. 0.888 0.888 ↓ 0.0 0 222

Index Scan using pk_ctrc_complemento on ctrc_complemento cc (cost=0.28..4.44 rows=1 width=9) (actual time=0.004..0.004 rows=0 loops=222)

  • Index Cond: (cd_ctrc = ct.cd_ctrc)
88. 0.888 0.888 ↑ 1.0 1 222

Index Scan using pk_tipo_pagamento on tipo_pagamento tp (cost=0.14..0.16 rows=1 width=23) (actual time=0.004..0.004 rows=1 loops=222)

  • Index Cond: (cd_tipo_pagamento = td.cd_tipo_pagamento)
89. 1.110 1.110 ↑ 1.0 1 222

Index Scan using pk_pessoa on pessoa p (cost=0.42..8.44 rows=1 width=28) (actual time=0.005..0.005 rows=1 loops=222)

  • Index Cond: (cd_pessoa = ct.cd_pessoa_transportadora)
90. 5.772 5.772 ↑ 1.0 1 222

Index Scan using pk_veiculo on veiculo v (cost=0.42..8.44 rows=1 width=30) (actual time=0.026..0.026 rows=1 loops=222)

  • Index Cond: (cd_veiculo = ct.cd_veiculo)
91. 3.552 3.552 ↑ 1.0 1 222

Index Scan using pk_ctrc_cte on ctrc_cte cte (cost=0.42..8.44 rows=1 width=8) (actual time=0.016..0.016 rows=1 loops=222)

  • Index Cond: (cd_ctrc = ct.cd_ctrc)
92. 0.000 1.998 ↑ 1.0 1 222

Index Scan using pk_ctrc_produto on ctrc_produto cp (cost=8.89..16.91 rows=1 width=14) (actual time=0.009..0.009 rows=1 loops=222)

  • Index Cond: (cd_ctrc_produto = (SubPlan 12))
93.          

SubPlan (for Index Scan)

94. 0.888 6.438 ↑ 1.0 1 222

Limit (cost=8.46..8.46 rows=1 width=18) (actual time=0.028..0.029 rows=1 loops=222)

95. 2.220 5.550 ↑ 1.0 1 222

Sort (cost=8.46..8.46 rows=1 width=18) (actual time=0.025..0.025 rows=1 loops=222)

  • Sort Key: cp2.vl_peso DESC, cp2.vl_produto DESC, cp2.cd_ctrc_produto
  • Sort Method: quicksort Memory: 25kB
96. 3.330 3.330 ↑ 1.0 1 222

Index Scan using idx_ctrc_produto_cd_ctrc on ctrc_produto cp2 (cost=0.43..8.45 rows=1 width=18) (actual time=0.014..0.015 rows=1 loops=222)

  • Index Cond: (cd_ctrc = ct.cd_ctrc)
97. 1.110 1.110 ↑ 1.0 1 222

Index Scan using pk_produto_venda on produto_transportado pt (cost=0.27..0.29 rows=1 width=21) (actual time=0.005..0.005 rows=1 loops=222)

  • Index Cond: (cd_produto = cp.cd_produto)
98. 1.332 1.332 ↑ 1.0 1 222

Index Scan using pk_pessoa on pessoa pm (cost=0.42..8.44 rows=1 width=28) (actual time=0.006..0.006 rows=1 loops=222)

  • Index Cond: (cd_pessoa = ct.cd_pessoa_motorista)
99. 0.666 0.666 ↑ 1.0 1 222

Index Scan using pk_agencia on agencia ag (cost=0.14..0.71 rows=1 width=19) (actual time=0.003..0.003 rows=1 loops=222)

  • Index Cond: (cd_agencia = ct.cd_agencia)
100. 0.222 0.222 ↓ 0.0 0 222

Index Scan using pk_carta_frete_diaria on carta_frete_diaria cfd (cost=0.29..0.31 rows=1 width=16) (actual time=0.001..0.001 rows=0 loops=222)

  • Index Cond: (cd_carta_frete_diaria = cfpa.cd_carta_frete_diaria)
101. 0.888 0.888 ↑ 1.0 1 222

Index Scan using pk_pessoa on pessoa pcf (cost=0.42..0.44 rows=1 width=32) (actual time=0.004..0.004 rows=1 loops=222)

  • Index Cond: (cd_pessoa = cfp.cd_pessoa)
102. 1.998 1.998 ↑ 1.0 1 222

Index Scan using pk_cidade on cidade cpcf (cost=0.28..0.30 rows=1 width=20) (actual time=0.009..0.009 rows=1 loops=222)

  • Index Cond: (cd_cidade = pcf.cd_cidade)
103. 0.888 0.888 ↑ 1.0 1 222

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

  • Index Cond: (cd_uf = cpcf.cd_uf)
104. 0.666 0.666 ↑ 1.0 1 222

Index Scan using pk_tipo_veiculo on tipo_veiculo tv (cost=0.14..0.16 rows=1 width=18) (actual time=0.003..0.003 rows=1 loops=222)

  • Index Cond: (cd_tipo_veiculo = v.cd_tipo_veiculo)
105. 0.666 0.666 ↑ 1.0 1 222

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

  • Index Cond: (cd_marca = v.cd_marca)
106. 1.554 1.554 ↑ 1.0 1 222

Index Scan using pk_pessoa on pessoa pu (cost=0.42..8.44 rows=1 width=28) (actual time=0.007..0.007 rows=1 loops=222)

  • Index Cond: (cd_pessoa = CASE WHEN (cfpa.id_tipo = 5) THEN cfd.cd_pessoa_usuario ELSE ct.cd_pessoa_usuario END)
107. 0.222 0.222 ↓ 0.0 0 222

Index Scan using pk_administradora_pagamento_eletronico on administradora_pagamento_eletronico adm (cost=0.13..0.15 rows=1 width=13) (actual time=0.001..0.001 rows=0 loops=222)

  • Index Cond: (cd_pessoa = cf.cd_pessoa_adm_pgto_eletronico)
108. 388.722 388.722 ↑ 1.0 10,008 222

CTE Scan on with_carta_frete_outros_descontos wcfod (cost=0.00..200.16 rows=10,008 width=36) (actual time=0.068..1.751 rows=10,008 loops=222)

109. 1.998 1.998 ↑ 1.0 1 222

Index Only Scan using pk_pessoa on pessoa pem (cost=0.42..4.44 rows=1 width=4) (actual time=0.009..0.009 rows=1 loops=222)

  • Index Cond: (cd_pessoa = ct.cd_pessoa_embarque)
  • Heap Fetches: 0
110. 0.888 0.888 ↑ 1.0 1 222

Index Only Scan using pk_pessoa on pessoa pen (cost=0.42..4.44 rows=1 width=4) (actual time=0.004..0.004 rows=1 loops=222)

  • Index Cond: (cd_pessoa = ct.cd_pessoa_entrega)
  • Heap Fetches: 0
111.          

SubPlan (for Nested Loop)

112. 0.294 0.294 ↑ 1.0 1 6

Index Scan using idx_carta_frete_vale_pedagio_cd_ctrc on carta_frete_vale_pedagio cfvp (cost=0.42..8.44 rows=1 width=3) (actual time=0.048..0.049 rows=1 loops=6)

  • Index Cond: (cd_ctrc = cf.cd_ctrc)
  • Filter: (id_antecipado = '0'::smallint)
113. 0.533 0.533 ↓ 0.0 0 41

Index Scan using idx_carta_frete_vale_pedagio_cd_ctrc on carta_frete_vale_pedagio cfvp_1 (cost=0.42..8.44 rows=1 width=3) (actual time=0.013..0.013 rows=0 loops=41)

  • Index Cond: (cd_ctrc = cf.cd_ctrc)
  • Filter: (id_antecipado = '1'::smallint)
  • Rows Removed by Filter: 1
114. 0.090 0.090 ↑ 1.0 1 6

Index Scan using idx_carta_frete_vale_pedagio_cd_ctrc on carta_frete_vale_pedagio cfvp_2 (cost=0.42..8.44 rows=1 width=3) (actual time=0.014..0.015 rows=1 loops=6)

  • Index Cond: (cd_ctrc = cf.cd_ctrc)
  • Filter: (id_antecipado = '0'::smallint)
115. 0.205 0.205 ↓ 0.0 0 41

Index Scan using idx_carta_frete_vale_pedagio_cd_ctrc on carta_frete_vale_pedagio cfvp_3 (cost=0.42..8.44 rows=1 width=3) (actual time=0.005..0.005 rows=0 loops=41)

  • Index Cond: (cd_ctrc = cf.cd_ctrc)
  • Filter: (id_antecipado = '1'::smallint)
  • Rows Removed by Filter: 1
116. 1.110 3.108 ↑ 1.0 1 222

Aggregate (cost=8.45..8.46 rows=1 width=32) (actual time=0.014..0.014 rows=1 loops=222)

117. 1.998 1.998 ↑ 1.0 1 222

Index Scan using pk_titulo on titulo (cost=0.43..8.45 rows=1 width=19) (actual time=0.008..0.009 rows=1 loops=222)

  • Index Cond: (cd_titulo = t.cd_titulo)
118. 4.218 4.218 ↓ 0.0 0 222

Index Scan using pk_pessoa_juridica on pessoa_juridica pjt (cost=0.29..8.31 rows=1 width=32) (actual time=0.019..0.019 rows=0 loops=222)

  • Index Cond: (cd_pessoa = ct.cd_pessoa_transportadora_doc)
119. 0.444 2.220 ↑ 1.0 1 222

Aggregate (cost=9.55..9.56 rows=1 width=32) (actual time=0.010..0.010 rows=1 loops=222)

120. 0.888 1.776 ↓ 0.0 0 222

Nested Loop (cost=0.42..9.55 rows=1 width=6) (actual time=0.008..0.008 rows=0 loops=222)

121. 0.888 0.888 ↓ 0.0 0 222

Seq Scan on carta_frete_parcelamento_documento_eletronico cfpde (cost=0.00..1.10 rows=1 width=4) (actual time=0.004..0.004 rows=0 loops=222)

  • Filter: ((cd_ctrc = cfpa.cd_ctrc) AND (id_tipo = cfpa.id_tipo) AND (nr_parcela = cfpa.nr_parcela))
  • Rows Removed by Filter: 6
122. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_documento_eletronico on documento_eletronico de (cost=0.42..8.44 rows=1 width=10) (never executed)

  • Index Cond: (cd_documento_eletronico = cfpde.cd_documento_eletronico)
123. 0.222 0.888 ↑ 1.0 1 222

Aggregate (cost=9.56..9.57 rows=1 width=32) (actual time=0.004..0.004 rows=1 loops=222)

124. 0.222 0.666 ↓ 0.0 0 222

Nested Loop (cost=0.42..9.55 rows=1 width=45) (actual time=0.003..0.003 rows=0 loops=222)

125. 0.444 0.444 ↓ 0.0 0 222

Seq Scan on carta_frete_parcelamento_documento_eletronico cfpde_1 (cost=0.00..1.10 rows=1 width=4) (actual time=0.002..0.002 rows=0 loops=222)

  • Filter: ((cd_ctrc = cfpa.cd_ctrc) AND (id_tipo = cfpa.id_tipo) AND (nr_parcela = cfpa.nr_parcela))
  • Rows Removed by Filter: 6
126. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_documento_eletronico on documento_eletronico de_1 (cost=0.42..8.44 rows=1 width=49) (never executed)

  • Index Cond: (cd_documento_eletronico = cfpde_1.cd_documento_eletronico)
127. 2.886 9.990 ↑ 1.0 1 222

Aggregate (cost=26.85..26.86 rows=1 width=32) (actual time=0.044..0.045 rows=1 loops=222)

128. 0.792 7.104 ↑ 2.0 1 222

Nested Loop (cost=1.28..26.84 rows=2 width=8) (actual time=0.030..0.032 rows=1 loops=222)

129. 0.848 3.552 ↑ 2.0 1 222

Nested Loop (cost=0.85..25.86 rows=2 width=4) (actual time=0.015..0.016 rows=1 loops=222)

130. 1.554 1.554 ↑ 2.0 1 222

Index Scan using idx_titulo_cd_movimento on titulo t_3 (cost=0.43..8.98 rows=2 width=4) (actual time=0.006..0.007 rows=1 loops=222)

  • Index Cond: (cd_movimento = cfp.cd_movimento)
131. 1.150 1.150 ↑ 1.0 1 230

Index Scan using pk_titulo_debito on titulo_debito td_3 (cost=0.42..8.44 rows=1 width=8) (actual time=0.005..0.005 rows=1 loops=230)

  • Index Cond: (cd_titulo = t_3.cd_titulo)
132. 2.760 2.760 ↑ 1.0 1 230

Index Scan using pk_cheque_emitido on cheque_emitido ch (cost=0.42..0.49 rows=1 width=12) (actual time=0.012..0.012 rows=1 loops=230)

  • Index Cond: (cd_cheque = td_3.cd_cheque)
  • Filter: (nr_cheque IS NOT NULL)
133. 0.222 0.222 ↓ 0.0 0 222

Index Scan using pk_pessoa on pessoa pe (cost=0.42..8.44 rows=1 width=24) (actual time=0.001..0.001 rows=0 loops=222)

  • Index Cond: (cd_pessoa = cfpa.cd_pessoa_usuario_liberacao)
134. 0.017 0.192 ↓ 0.0 0 1

Subquery Scan on *SELECT* 2 (cost=951.29..1,037.00 rows=1 width=1,381) (actual time=0.191..0.192 rows=0 loops=1)

135. 0.007 0.175 ↓ 0.0 0 1

Nested Loop Left Join (cost=951.29..1,036.99 rows=1 width=1,351) (actual time=0.175..0.175 rows=0 loops=1)

136. 0.006 0.168 ↓ 0.0 0 1

Nested Loop Left Join (cost=950.87..1,020.56 rows=1 width=389) (actual time=0.168..0.168 rows=0 loops=1)

137. 0.007 0.162 ↓ 0.0 0 1

Nested Loop Left Join (cost=950.73..1,020.40 rows=1 width=390) (actual time=0.162..0.162 rows=0 loops=1)

138. 0.007 0.155 ↓ 0.0 0 1

Nested Loop Left Join (cost=950.44..1,020.10 rows=1 width=378) (actual time=0.154..0.155 rows=0 loops=1)

139. 0.007 0.148 ↓ 0.0 0 1

Nested Loop Left Join (cost=950.30..1,019.94 rows=1 width=363) (actual time=0.148..0.148 rows=0 loops=1)

140. 0.009 0.141 ↓ 0.0 0 1

Nested Loop Left Join (cost=950.16..1,019.78 rows=1 width=359) (actual time=0.141..0.141 rows=0 loops=1)

141. 0.007 0.132 ↓ 0.0 0 1

Nested Loop Left Join (cost=950.03..1,019.63 rows=1 width=345) (actual time=0.132..0.132 rows=0 loops=1)

142. 0.007 0.125 ↓ 0.0 0 1

Nested Loop (cost=949.61..1,011.46 rows=1 width=323) (actual time=0.125..0.125 rows=0 loops=1)

143. 0.007 0.118 ↓ 0.0 0 1

Nested Loop (cost=949.18..1,003.38 rows=1 width=323) (actual time=0.118..0.118 rows=0 loops=1)

144. 0.007 0.111 ↓ 0.0 0 1

Nested Loop (cost=948.75..1,002.82 rows=1 width=313) (actual time=0.111..0.111 rows=0 loops=1)

145. 0.006 0.104 ↓ 0.0 0 1

Nested Loop (cost=948.33..994.38 rows=1 width=303) (actual time=0.104..0.104 rows=0 loops=1)

146. 0.007 0.098 ↓ 0.0 0 1

Nested Loop (cost=947.91..990.29 rows=1 width=307) (actual time=0.098..0.098 rows=0 loops=1)

147. 0.006 0.091 ↓ 0.0 0 1

Nested Loop Left Join (cost=947.49..986.20 rows=1 width=311) (actual time=0.091..0.091 rows=0 loops=1)

148. 0.007 0.085 ↓ 0.0 0 1

Nested Loop Left Join (cost=947.07..978.15 rows=1 width=279) (actual time=0.085..0.085 rows=0 loops=1)

149. 0.009 0.078 ↓ 0.0 0 1

Nested Loop (cost=946.65..970.10 rows=1 width=255) (actual time=0.078..0.078 rows=0 loops=1)

150. 0.007 0.069 ↓ 0.0 0 1

Nested Loop (cost=946.23..962.06 rows=1 width=231) (actual time=0.069..0.069 rows=0 loops=1)

151. 0.006 0.062 ↓ 0.0 0 1

Nested Loop (cost=946.08..961.74 rows=1 width=216) (actual time=0.062..0.062 rows=0 loops=1)

  • Join Filter: (cf_1.cd_pessoa_filial = p_5.cd_pessoa)
152. 0.007 0.056 ↓ 0.0 0 1

Nested Loop (cost=9.79..24.98 rows=1 width=184) (actual time=0.056..0.056 rows=0 loops=1)

153. 0.006 0.049 ↓ 0.0 0 1

Nested Loop Left Join (cost=9.64..24.37 rows=1 width=166) (actual time=0.049..0.049 rows=0 loops=1)

154. 0.015 0.043 ↓ 0.0 0 1

Hash Join (cost=9.49..23.76 rows=1 width=138) (actual time=0.042..0.043 rows=0 loops=1)

  • Hash Cond: (cf_1.cd_pessoa_matriz = ve.cd_pessoa)
155. 0.028 0.028 ↓ 0.0 0 1

Seq Scan on contrato_frete cf_1 (cost=0.00..13.88 rows=103 width=106) (actual time=0.028..0.028 rows=0 loops=1)

  • Filter: (vl_adiantamento > '0'::numeric)
156. 0.000 0.000 ↓ 0.0 0

Hash (cost=9.48..9.48 rows=1 width=36) (never executed)

157. 0.000 0.000 ↓ 0.0 0

Subquery Scan on ve (cost=9.46..9.48 rows=1 width=36) (never executed)

158. 0.000 0.000 ↓ 0.0 0

Sort (cost=9.46..9.47 rows=1 width=36) (never executed)

  • Sort Key: (COALESCE(p_4.nm_fantasia, p_4.nm_pessoa))
159. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.42..9.45 rows=1 width=36) (never executed)

160. 0.000 0.000 ↓ 0.0 0

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

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

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

  • Index Cond: (cd_pessoa = eg_2.cd_pessoa)
162. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_contrato_frete_parcelamento on contrato_frete_parcelamento cfpa_1 (cost=0.15..0.60 rows=1 width=32) (never executed)

  • Index Cond: ((cd_contrato = cf_1.cd_contrato) AND (id_tipo = 0))
163. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_contrato_frete_pagamento on contrato_frete_pagamento cfp_1 (cost=0.15..0.60 rows=1 width=26) (never executed)

  • Index Cond: ((cd_contrato = cf_1.cd_contrato) AND (id_tipo = 0))
164. 0.000 0.000 ↓ 0.0 0

Unique (cost=936.29..936.51 rows=11 width=126) (never executed)

165. 0.000 0.000 ↓ 0.0 0

Sort (cost=936.29..936.32 rows=11 width=126) (never executed)

  • Sort Key: (COALESCE(p_5.nm_fantasia, p_5.nm_pessoa)), p_5.cd_pessoa, p_5.cd_cidade, (((ci_1.nm_cidade || ' / '::text) || (uf_1.ds_sigla)::text)), ((COALESCE(pj_1.nr_cnpj, pf_1.nr_cpf))::character varying(14)), (COALESCE(substr((pj_1.nr_cnpj)::text, 1, 8), (pf_1.nr_cpf)::text)), (COALESCE((SubPlan 19), f_1.cd_pessoa_matriz))
166. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=1.55..936.10 rows=11 width=126) (never executed)

167. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=1.41..283.76 rows=11 width=91) (never executed)

168. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=1.13..280.45 rows=11 width=75) (never executed)

169. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.71..187.63 rows=11 width=35) (never executed)

  • Join Filter: (f_1.cd_pessoa_matriz = eg_3.cd_pessoa)
170. 0.000 0.000 ↓ 0.0 0

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

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

Nested Loop Left Join (cost=0.71..186.48 rows=11 width=35) (never executed)

  • Join Filter: (pg_1.cd_empresa = f_1.cd_pessoa_matriz)
172. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=0.71..185.31 rows=11 width=35) (never executed)

173. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=0.29..92.52 rows=11 width=23) (never executed)

174. 0.000 0.000 ↓ 0.0 0

Seq Scan on filial f_1 (cost=0.00..1.14 rows=11 width=8) (never executed)

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

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

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

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

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

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

178. 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)

179. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_pessoa on pessoa p_5 (cost=0.42..8.44 rows=1 width=44) (never executed)

  • Index Cond: (cd_pessoa = f_1.cd_pessoa_filial)
180. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (cd_cidade = p_5.cd_cidade)
181. 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)
182.          

SubPlan (for Nested Loop)

183. 0.000 0.000 ↓ 0.0 0

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

184. 0.000 0.000 ↓ 0.0 0

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

185. 0.000 0.000 ↓ 0.0 0

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

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

Nested Loop Left Join (cost=1.13..59.11 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_1.nr_cpf))
187. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=0.84..55.30 rows=11 width=16) (never executed)

188. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.42..49.92 rows=11 width=4) (never executed)

189. 0.000 0.000 ↓ 0.0 0

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

190. 0.000 0.000 ↓ 0.0 0

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

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

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

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

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

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

Index Scan using pk_agencia on agencia ag_1 (cost=0.14..0.32 rows=1 width=19) (never executed)

  • Index Cond: (cd_agencia = cf_1.cd_agencia)
194. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_pessoa on pessoa pu_1 (cost=0.42..8.05 rows=1 width=28) (never executed)

  • Index Cond: (cd_pessoa = cf_1.cd_pessoa_usuario)
195. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_pessoa on pessoa pm_1 (cost=0.42..8.05 rows=1 width=28) (never executed)

  • Index Cond: (cd_pessoa = cf_1.cd_pessoa_motorista)
196. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (cd_pessoa = cf_1.cd_pessoa_transportadora)
197. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (cd_pessoa = cf_1.cd_pessoa_embarque)
  • Heap Fetches: 0
198. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (cd_pessoa = cf_1.cd_pessoa_entrega)
  • Heap Fetches: 0
199. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_movimento on movimento m_1 (cost=0.43..8.45 rows=1 width=10) (never executed)

  • Index Cond: (cd_movimento = cfp_1.cd_movimento)
200. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_titulo_cd_movimento on titulo t_1 (cost=0.43..0.55 rows=1 width=22) (never executed)

  • Index Cond: (cd_movimento = m_1.cd_movimento)
  • Filter: ((dt_quitacao >= '2020-05-01'::date) AND (dt_quitacao <= '2020-05-01'::date))
201. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_titulo_debito on titulo_debito td_1 (cost=0.42..8.08 rows=1 width=8) (never executed)

  • Index Cond: (cd_titulo = t_1.cd_titulo)
202. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_veiculo on veiculo v_1 (cost=0.42..8.17 rows=1 width=30) (never executed)

  • Index Cond: (cd_veiculo = cf_1.cd_veiculo)
203. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_tipo_veiculo on tipo_veiculo tv_1 (cost=0.14..0.16 rows=1 width=18) (never executed)

  • Index Cond: (cd_tipo_veiculo = v_1.cd_tipo_veiculo)
204. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_veiculo_marca on veiculo_marca vm_1 (cost=0.14..0.16 rows=1 width=12) (never executed)

  • Index Cond: (cd_marca = v_1.cd_marca)
205. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_tipo_pagamento on tipo_pagamento tp_1 (cost=0.14..0.16 rows=1 width=23) (never executed)

  • Index Cond: (cd_tipo_pagamento = td_1.cd_tipo_pagamento)
206. 0.000 0.000 ↓ 0.0 0

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

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

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

  • Index Cond: (cd_uf = c.cd_uf)
208. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_pessoa on pessoa pd_1 (cost=0.42..8.05 rows=1 width=40) (never executed)

  • Index Cond: (cd_pessoa = cf_1.cd_pessoa_transportadora_doc)
209.          

SubPlan (for Nested Loop Left Join)

210. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_pessoa_juridica on pessoa_juridica pjt_1 (cost=0.29..8.31 rows=1 width=32) (never executed)

  • Index Cond: (cd_pessoa = cf_1.cd_pessoa_transportadora_doc)
211. 0.008 0.140 ↓ 0.0 0 1

Subquery Scan on *SELECT* 3 (cost=951.29..1,036.99 rows=1 width=1,381) (actual time=0.140..0.140 rows=0 loops=1)

212. 0.006 0.132 ↓ 0.0 0 1

Nested Loop Left Join (cost=951.29..1,036.98 rows=1 width=1,351) (actual time=0.132..0.132 rows=0 loops=1)

213. 0.007 0.126 ↓ 0.0 0 1

Nested Loop Left Join (cost=950.87..1,020.56 rows=1 width=389) (actual time=0.126..0.126 rows=0 loops=1)

214. 0.007 0.119 ↓ 0.0 0 1

Nested Loop Left Join (cost=950.73..1,020.40 rows=1 width=390) (actual time=0.119..0.119 rows=0 loops=1)

215. 0.006 0.112 ↓ 0.0 0 1

Nested Loop Left Join (cost=950.44..1,020.10 rows=1 width=378) (actual time=0.112..0.112 rows=0 loops=1)

216. 0.006 0.106 ↓ 0.0 0 1

Nested Loop Left Join (cost=950.30..1,019.94 rows=1 width=363) (actual time=0.106..0.106 rows=0 loops=1)

217. 0.007 0.100 ↓ 0.0 0 1

Nested Loop Left Join (cost=950.16..1,019.78 rows=1 width=359) (actual time=0.100..0.100 rows=0 loops=1)

218. 0.006 0.093 ↓ 0.0 0 1

Nested Loop Left Join (cost=950.03..1,019.63 rows=1 width=345) (actual time=0.093..0.093 rows=0 loops=1)

219. 0.009 0.087 ↓ 0.0 0 1

Nested Loop (cost=949.61..1,011.46 rows=1 width=323) (actual time=0.087..0.087 rows=0 loops=1)

220. 0.007 0.078 ↓ 0.0 0 1

Nested Loop (cost=949.18..1,003.38 rows=1 width=323) (actual time=0.078..0.078 rows=0 loops=1)

221. 0.006 0.071 ↓ 0.0 0 1

Nested Loop (cost=948.75..1,002.82 rows=1 width=313) (actual time=0.071..0.071 rows=0 loops=1)

222. 0.006 0.065 ↓ 0.0 0 1

Nested Loop (cost=948.33..994.38 rows=1 width=303) (actual time=0.065..0.065 rows=0 loops=1)

223. 0.006 0.059 ↓ 0.0 0 1

Nested Loop (cost=947.91..990.29 rows=1 width=307) (actual time=0.059..0.059 rows=0 loops=1)

224. 0.007 0.053 ↓ 0.0 0 1

Nested Loop Left Join (cost=947.49..986.20 rows=1 width=311) (actual time=0.053..0.053 rows=0 loops=1)

225. 0.007 0.046 ↓ 0.0 0 1

Nested Loop Left Join (cost=947.07..978.15 rows=1 width=279) (actual time=0.046..0.046 rows=0 loops=1)

226. 0.007 0.039 ↓ 0.0 0 1

Nested Loop (cost=946.65..970.10 rows=1 width=255) (actual time=0.039..0.039 rows=0 loops=1)

227. 0.007 0.032 ↓ 0.0 0 1

Nested Loop (cost=946.23..962.06 rows=1 width=231) (actual time=0.032..0.032 rows=0 loops=1)

228. 0.007 0.025 ↓ 0.0 0 1

Nested Loop (cost=946.08..961.74 rows=1 width=216) (actual time=0.025..0.025 rows=0 loops=1)

  • Join Filter: (cf_2.cd_pessoa_filial = p_8.cd_pessoa)
229. 0.004 0.018 ↓ 0.0 0 1

Nested Loop (cost=9.79..24.98 rows=1 width=184) (actual time=0.018..0.018 rows=0 loops=1)

230. 0.004 0.014 ↓ 0.0 0 1

Nested Loop Left Join (cost=9.64..24.37 rows=1 width=166) (actual time=0.014..0.014 rows=0 loops=1)

231. 0.007 0.010 ↓ 0.0 0 1

Hash Join (cost=9.49..23.76 rows=1 width=138) (actual time=0.010..0.010 rows=0 loops=1)

  • Hash Cond: (cf_2.cd_pessoa_matriz = ve_1.cd_pessoa)
232. 0.003 0.003 ↓ 0.0 0 1

Seq Scan on contrato_frete cf_2 (cost=0.00..13.88 rows=103 width=106) (actual time=0.002..0.003 rows=0 loops=1)

  • Filter: (vl_saldo > '0'::numeric)
233. 0.000 0.000 ↓ 0.0 0

Hash (cost=9.48..9.48 rows=1 width=36) (never executed)

234. 0.000 0.000 ↓ 0.0 0

Subquery Scan on ve_1 (cost=9.46..9.48 rows=1 width=36) (never executed)

235. 0.000 0.000 ↓ 0.0 0

Sort (cost=9.46..9.47 rows=1 width=36) (never executed)

  • Sort Key: (COALESCE(p_7.nm_fantasia, p_7.nm_pessoa))
236. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.42..9.45 rows=1 width=36) (never executed)

237. 0.000 0.000 ↓ 0.0 0

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

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

Index Scan using pk_pessoa on pessoa p_7 (cost=0.42..8.44 rows=1 width=40) (never executed)

  • Index Cond: (cd_pessoa = eg_4.cd_pessoa)
239. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_contrato_frete_parcelamento on contrato_frete_parcelamento cfpa_2 (cost=0.15..0.60 rows=1 width=32) (never executed)

  • Index Cond: ((cd_contrato = cf_2.cd_contrato) AND (id_tipo = 1))
240. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_contrato_frete_pagamento on contrato_frete_pagamento cfp_2 (cost=0.15..0.60 rows=1 width=26) (never executed)

  • Index Cond: ((cd_contrato = cf_2.cd_contrato) AND (id_tipo = 1))
241. 0.000 0.000 ↓ 0.0 0

Unique (cost=936.29..936.51 rows=11 width=126) (never executed)

242. 0.000 0.000 ↓ 0.0 0

Sort (cost=936.29..936.32 rows=11 width=126) (never executed)

  • Sort Key: (COALESCE(p_8.nm_fantasia, p_8.nm_pessoa)), p_8.cd_pessoa, p_8.cd_cidade, (((ci_2.nm_cidade || ' / '::text) || (uf_2.ds_sigla)::text)), ((COALESCE(pj_2.nr_cnpj, pf_2.nr_cpf))::character varying(14)), (COALESCE(substr((pj_2.nr_cnpj)::text, 1, 8), (pf_2.nr_cpf)::text)), (COALESCE((SubPlan 21), f_2.cd_pessoa_matriz))
243. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=1.55..936.10 rows=11 width=126) (never executed)

244. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=1.41..283.76 rows=11 width=91) (never executed)

245. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=1.13..280.45 rows=11 width=75) (never executed)

246. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.71..187.63 rows=11 width=35) (never executed)

  • Join Filter: (f_2.cd_pessoa_matriz = eg_5.cd_pessoa)
247. 0.000 0.000 ↓ 0.0 0

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

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

Nested Loop Left Join (cost=0.71..186.48 rows=11 width=35) (never executed)

  • Join Filter: (pg_2.cd_empresa = f_2.cd_pessoa_matriz)
249. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=0.71..185.31 rows=11 width=35) (never executed)

250. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=0.29..92.52 rows=11 width=23) (never executed)

251. 0.000 0.000 ↓ 0.0 0

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

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

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

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

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

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

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

255. 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)

256. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_pessoa on pessoa p_8 (cost=0.42..8.44 rows=1 width=44) (never executed)

  • Index Cond: (cd_pessoa = f_2.cd_pessoa_filial)
257. 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_8.cd_cidade)
258. 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)
259.          

SubPlan (for Nested Loop)

260. 0.000 0.000 ↓ 0.0 0

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

261. 0.000 0.000 ↓ 0.0 0

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

262. 0.000 0.000 ↓ 0.0 0

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

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

Nested Loop Left Join (cost=1.13..59.11 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_2.nr_cpf))
264. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=0.84..55.30 rows=11 width=16) (never executed)

265. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.42..49.92 rows=11 width=4) (never executed)

266. 0.000 0.000 ↓ 0.0 0

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

267. 0.000 0.000 ↓ 0.0 0

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

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

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

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

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

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

Index Scan using pk_agencia on agencia ag_2 (cost=0.14..0.32 rows=1 width=19) (never executed)

  • Index Cond: (cd_agencia = cf_2.cd_agencia)
271. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_pessoa on pessoa pu_2 (cost=0.42..8.05 rows=1 width=28) (never executed)

  • Index Cond: (cd_pessoa = cf_2.cd_pessoa_usuario)
272. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_pessoa on pessoa pm_2 (cost=0.42..8.05 rows=1 width=28) (never executed)

  • Index Cond: (cd_pessoa = cf_2.cd_pessoa_motorista)
273. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_pessoa on pessoa p_6 (cost=0.42..8.05 rows=1 width=32) (never executed)

  • Index Cond: (cd_pessoa = cf_2.cd_pessoa_transportadora)
274. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (cd_pessoa = cf_2.cd_pessoa_embarque)
  • Heap Fetches: 0
275. 0.000 0.000 ↓ 0.0 0

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

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

Index Scan using pk_movimento on movimento m_2 (cost=0.43..8.45 rows=1 width=10) (never executed)

  • Index Cond: (cd_movimento = cfp_2.cd_movimento)
277. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_titulo_cd_movimento on titulo t_2 (cost=0.43..0.55 rows=1 width=22) (never executed)

  • Index Cond: (cd_movimento = m_2.cd_movimento)
  • Filter: ((dt_quitacao >= '2020-05-01'::date) AND (dt_quitacao <= '2020-05-01'::date))
278. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_titulo_debito on titulo_debito td_2 (cost=0.42..8.08 rows=1 width=8) (never executed)

  • Index Cond: (cd_titulo = t_2.cd_titulo)
279. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_veiculo on veiculo v_2 (cost=0.42..8.17 rows=1 width=30) (never executed)

  • Index Cond: (cd_veiculo = cf_2.cd_veiculo)
280. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_tipo_veiculo on tipo_veiculo tv_2 (cost=0.14..0.16 rows=1 width=18) (never executed)

  • Index Cond: (cd_tipo_veiculo = v_2.cd_tipo_veiculo)
281. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_veiculo_marca on veiculo_marca vm_2 (cost=0.14..0.16 rows=1 width=12) (never executed)

  • Index Cond: (cd_marca = v_2.cd_marca)
282. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_tipo_pagamento on tipo_pagamento tp_2 (cost=0.14..0.16 rows=1 width=23) (never executed)

  • Index Cond: (cd_tipo_pagamento = td_2.cd_tipo_pagamento)
283. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (cd_cidade = p_6.cd_cidade)
284. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (cd_uf = c_1.cd_uf)
285. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_pessoa on pessoa pd_2 (cost=0.42..8.05 rows=1 width=40) (never executed)

  • Index Cond: (cd_pessoa = cf_2.cd_pessoa_transportadora_doc)
286.          

SubPlan (for Nested Loop Left Join)

287. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_pessoa_juridica on pessoa_juridica pjt_2 (cost=0.29..8.31 rows=1 width=32) (never executed)

  • Index Cond: (cd_pessoa = cf_2.cd_pessoa_transportadora_doc)
Planning time : 2,006.629 ms
Execution time : 538,153.074 ms