explain.depesz.com

PostgreSQL's explain analyze made readable

Result: eQsj

Settings
# exclusive inclusive rows x rows loops node
1. 2.961 783,835.205 ↓ 74.0 222 1

Sort (cost=16,800,069.34..16,800,069.35 rows=3 width=1,521) (actual time=783,835.182..783,835.205 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. 0.296 783,832.244 ↓ 74.0 222 1

Append (cost=1,182.60..16,800,069.32 rows=3 width=1,521) (actual time=737,929.917..783,832.244 rows=222 loops=1)

3. 32.519 783,831.545 ↓ 222.0 222 1

Nested Loop (cost=1,182.60..16,797,995.29 rows=1 width=1,241) (actual time=737,929.905..783,831.545 rows=222 loops=1)

4. 2.477 781,778.770 ↓ 222.0 222 1

Nested Loop (cost=1,182.18..16,797,885.67 rows=1 width=716) (actual time=737,874.580..781,778.770 rows=222 loops=1)

5. 364.254 781,773.185 ↓ 222.0 222 1

Nested Loop Left Join (cost=1,181.76..16,797,881.24 rows=1 width=720) (actual time=737,874.495..781,773.185 rows=222 loops=1)

  • Join Filter: (cfod.cd_ctrc = cf.cd_ctrc)
  • Rows Removed by Join Filter: 2,206,763
6. 1.244 779,434.019 ↓ 222.0 222 1

Nested Loop Left Join (cost=965.67..16,797,314.86 rows=1 width=688) (actual time=737,819.074..779,434.019 rows=222 loops=1)

7. 1.327 779,432.553 ↓ 222.0 222 1

Nested Loop Left Join (cost=965.54..16,797,314.71 rows=1 width=679) (actual time=737,819.012..779,432.553 rows=222 loops=1)

8. 1.399 779,429.228 ↓ 222.0 222 1

Nested Loop Left Join (cost=965.11..16,797,306.27 rows=1 width=659) (actual time=737,818.934..779,429.228 rows=222 loops=1)

9. 1.219 779,425.165 ↓ 222.0 222 1

Nested Loop Left Join (cost=964.97..16,797,306.11 rows=1 width=655) (actual time=737,817.232..779,425.165 rows=222 loops=1)

10. 1.376 779,422.836 ↓ 222.0 222 1

Nested Loop Left Join (cost=964.84..16,797,305.95 rows=1 width=641) (actual time=737,817.134..779,422.836 rows=222 loops=1)

11. 1.465 779,419.906 ↓ 222.0 222 1

Nested Loop Left Join (cost=964.70..16,797,305.79 rows=1 width=642) (actual time=737,817.027..779,419.906 rows=222 loops=1)

12. 1.124 779,220.639 ↓ 222.0 222 1

Nested Loop Left Join (cost=964.41..16,797,305.49 rows=1 width=630) (actual time=737,816.845..779,220.639 rows=222 loops=1)

13. 1.062 779,218.405 ↓ 222.0 222 1

Nested Loop Left Join (cost=963.99..16,797,305.05 rows=1 width=602) (actual time=737,816.785..779,218.405 rows=222 loops=1)

14. 1.252 779,164.729 ↓ 222.0 222 1

Nested Loop Left Join (cost=963.71..16,797,304.74 rows=1 width=594) (actual time=737,816.703..779,164.729 rows=222 loops=1)

15. 1.391 779,158.371 ↓ 222.0 222 1

Nested Loop Left Join (cost=963.56..16,797,304.02 rows=1 width=579) (actual time=737,812.781..779,158.371 rows=222 loops=1)

16. 1.456 779,145.214 ↓ 222.0 222 1

Nested Loop Left Join (cost=963.14..16,797,295.58 rows=1 width=555) (actual time=737,812.713..779,145.214 rows=222 loops=1)

17. 259.820 779,129.328 ↓ 222.0 222 1

Nested Loop Left Join (cost=962.87..16,797,295.29 rows=1 width=542) (actual time=737,804.050..779,129.328 rows=222 loops=1)

18. 2.276 778,785.814 ↓ 222.0 222 1

Nested Loop Left Join (cost=953.98..16,797,278.38 rows=1 width=536) (actual time=737,685.485..778,785.814 rows=222 loops=1)

  • Filter: CASE WHEN (cte.cd_ctrc IS NOT NULL) THEN (cte.cd_status = 100) ELSE true END
19. 1.491 778,040.948 ↓ 222.0 222 1

Nested Loop Left Join (cost=953.56..16,797,269.93 rows=1 width=536) (actual time=737,636.630..778,040.948 rows=222 loops=1)

20. 1.166 775,981.739 ↓ 222.0 222 1

Nested Loop Left Join (cost=953.14..16,797,261.49 rows=1 width=514) (actual time=737,603.584..775,981.739 rows=222 loops=1)

21. 1.215 775,979.019 ↓ 222.0 222 1

Nested Loop Left Join (cost=952.72..16,797,253.05 rows=1 width=486) (actual time=737,603.510..775,979.019 rows=222 loops=1)

22. 0.866 775,976.472 ↓ 222.0 222 1

Nested Loop Left Join (cost=952.58..16,797,252.89 rows=1 width=471) (actual time=737,603.396..775,976.472 rows=222 loops=1)

23. 1.170 775,974.052 ↓ 222.0 222 1

Nested Loop (cost=952.30..16,797,248.46 rows=1 width=466) (actual time=737,603.264..775,974.052 rows=222 loops=1)

24. 1.892 775,910.278 ↓ 222.0 222 1

Nested Loop (cost=951.87..16,797,240.38 rows=1 width=462) (actual time=737,556.265..775,910.278 rows=222 loops=1)

25. 1.764 775,831.574 ↓ 222.0 222 1

Nested Loop Left Join (cost=951.45..16,797,239.90 rows=1 width=460) (actual time=737,516.503..775,831.574 rows=222 loops=1)

26. 1,894.301 774,256.718 ↓ 222.0 222 1

Nested Loop (cost=951.02..16,797,239.33 rows=1 width=394) (actual time=737,473.941..774,256.718 rows=222 loops=1)

27. 6,869.234 676,897.185 ↓ 44,196.9 1,988,859 1

Nested Loop (cost=950.59..16,797,215.77 rows=45 width=372) (actual time=17.011..676,897.185 rows=1,988,859 loops=1)

  • Join Filter: (ct.cd_ctrc = cf.cd_ctrc)
28. 4,572.715 656,105.938 ↓ 48,508.8 1,988,859 1

Nested Loop (cost=950.16..16,797,194.39 rows=41 width=306) (actual time=16.885..656,105.938 rows=1,988,859 loops=1)

  • Join Filter: (ct.cd_ctrc = cfpa.cd_ctrc)
29. 5,282.960 595,838.283 ↓ 40,594.0 1,989,105 1

Merge Join (cost=949.74..16,797,169.49 rows=49 width=228) (actual time=16.793..595,838.283 rows=1,989,105 loops=1)

  • Merge Cond: (cfp.cd_ctrc = ct.cd_ctrc)
30. 36,133.678 36,133.678 ↑ 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.051..36,133.678 rows=2,012,786 loops=1)

31. 3,428.108 554,421.645 ↓ 70,162.8 2,034,721 1

Materialize (cost=949.31..16,698,490.64 rows=29 width=200) (actual time=16.724..554,421.645 rows=2,034,721 loops=1)

32. 2,211.115 550,993.537 ↓ 37,776.3 1,095,512 1

Nested Loop (cost=949.31..16,698,490.57 rows=29 width=200) (actual time=16.709..550,993.537 rows=1,095,512 loops=1)

33. 3,125.160 534,540.727 ↓ 37,776.4 1,095,515 1

Nested Loop (cost=948.89..16,698,245.88 rows=29 width=164) (actual time=7.296..534,540.727 rows=1,095,515 loops=1)

34. 3,628.977 521,555.932 ↓ 37,776.4 1,095,515 1

Nested Loop (cost=948.47..16,698,001.20 rows=29 width=140) (actual time=7.242..521,555.932 rows=1,095,515 loops=1)

  • Join Filter: (p_2.cd_pessoa = ct.cd_pessoa_filial)
  • Rows Removed by Join Filter: 10,955,150
35. 149,826.452 515,735.925 ↓ 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=4.149..515,735.925 rows=1,095,515 loops=1)

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

SubPlan (for Index Scan)

37. 0.019 0.019 ↑ 1.0 11 1

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

38. 185,149.471 185,149.471 ↓ 1.0 465 1,095,559

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

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

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

40. 180,759.975 180,759.975 ↓ 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.004..0.165 rows=465 loops=1,095,515)

  • Filter: ((dt_baixa IS NULL) OR (dt_baixa >= ct.dt_emissao))
  • Rows Removed by Filter: 80
41. 2,187.938 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)

42. 0.008 3.092 ↑ 1.0 11 1

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

43. 0.035 0.099 ↑ 1.0 1 1

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

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

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

45. 0.043 0.043 ↑ 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.042..0.043 rows=1 loops=1)

  • Index Cond: (cd_pessoa = 2)
46. 0.016 0.016 ↑ 1.0 1 1

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

  • Filter: ((cd_pessoa = 2) AND (id_ativo = 1))
47. 0.016 2.985 ↑ 1.0 11 1

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

48. 0.079 2.969 ↑ 1.0 11 1

Sort (cost=936.29..936.32 rows=11 width=126) (actual time=2.966..2.969 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 16), f.cd_pessoa_matriz))
  • Sort Method: quicksort Memory: 26kB
49. 0.063 2.890 ↑ 1.0 11 1

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

50. 0.030 0.737 ↑ 1.0 11 1

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

51. 0.032 0.454 ↑ 1.0 11 1

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

52. 0.009 0.257 ↑ 1.0 11 1

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

  • Join Filter: (f.cd_pessoa_matriz = eg_1.cd_pessoa)
53. 0.005 0.005 ↑ 1.0 1 1

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

  • Filter: (id_ativo = 1)
54. 0.013 0.243 ↑ 1.0 11 1

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

  • Join Filter: (pg.cd_empresa = f.cd_pessoa_matriz)
55. 0.020 0.197 ↑ 1.0 11 1

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

56. 0.019 0.100 ↑ 1.0 11 1

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

57. 0.015 0.015 ↑ 1.0 11 1

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

  • Filter: (id_ativo = 1)
58. 0.066 0.066 ↑ 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=0.006..0.006 rows=1 loops=11)

  • Index Cond: (cd_pessoa = f.cd_pessoa_filial)
  • Filter: (nr_cnpj IS NOT NULL)
59. 0.077 0.077 ↓ 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.007..0.007 rows=0 loops=11)

  • Index Cond: (cd_pessoa = f.cd_pessoa_filial)
  • Filter: (nr_cpf IS NOT NULL)
60. 0.018 0.033 ↑ 1.0 1 11

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

61. 0.015 0.015 ↑ 1.0 1 1

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

62. 0.165 0.165 ↑ 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.015..0.015 rows=1 loops=11)

  • Index Cond: (cd_pessoa = f.cd_pessoa_filial)
63. 0.253 0.253 ↑ 1.0 1 11

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

  • Index Cond: (cd_cidade = p_2.cd_cidade)
64. 0.066 0.066 ↑ 1.0 1 11

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

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

SubPlan (for Nested Loop)

66. 0.011 2.024 ↑ 1.0 1 11

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

67. 0.011 2.013 ↑ 1.0 1 11

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

68. 0.099 2.002 ↑ 1.0 1 11

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

  • Sort Key: p_1_1.cd_pessoa
  • Sort Method: quicksort Memory: 25kB
69. 0.209 1.903 ↑ 1.0 1 11

Nested Loop Left Join (cost=1.13..59.11 rows=1 width=4) (actual time=0.024..0.173 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
70. 0.066 1.210 ↑ 1.0 11 11

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

71. 0.132 0.660 ↑ 1.0 11 11

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

72. 0.044 0.044 ↑ 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.004 rows=11 loops=11)

73. 0.484 0.484 ↑ 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.004..0.004 rows=1 loops=121)

  • Index Cond: (cd_pessoa = f_1_1.cd_pessoa_filial)
  • Heap Fetches: 0
74. 0.484 0.484 ↓ 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.004..0.004 rows=0 loops=121)

  • Index Cond: (cd_pessoa = p_1_1.cd_pessoa)
  • Filter: (nr_cpf IS NOT NULL)
75. 0.484 0.484 ↑ 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.004..0.004 rows=1 loops=121)

  • Index Cond: (cd_pessoa = p_1_1.cd_pessoa)
  • Filter: (nr_cnpj IS NOT NULL)
76. 9,859.635 9,859.635 ↑ 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.009..0.009 rows=1 loops=1,095,515)

  • Index Cond: (cd_pessoa = ct.cd_pessoa_pagador)
77. 14,241.695 14,241.695 ↑ 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.013..0.013 rows=1 loops=1,095,515)

  • Index Cond: (cd_pessoa = ct.cd_pessoa_transportadora_doc)
78. 55,694.940 55,694.940 ↑ 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.028..0.028 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))
79. 13,922.013 13,922.013 ↑ 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.007..0.007 rows=1 loops=1,988,859)

  • Index Cond: (cd_ctrc = cfpa.cd_ctrc)
80. 95,465.232 95,465.232 ↓ 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.048..0.048 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
81. 1,573.092 1,573.092 ↑ 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=7.086..7.086 rows=1 loops=222)

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

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

  • Index Cond: (cd_movimento = cfp.cd_movimento)
83. 62.604 62.604 ↑ 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.282..0.282 rows=1 loops=222)

  • Index Cond: (cd_titulo = t.cd_titulo)
84. 1.554 1.554 ↓ 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.007..0.007 rows=0 loops=222)

  • Index Cond: (cd_ctrc = ct.cd_ctrc)
85. 1.332 1.332 ↑ 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.006..0.006 rows=1 loops=222)

  • Index Cond: (cd_tipo_pagamento = td.cd_tipo_pagamento)
86. 1.554 1.554 ↑ 1.0 1 222

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

  • Index Cond: (cd_pessoa = ct.cd_pessoa_transportadora)
87. 2,057.718 2,057.718 ↑ 1.0 1 222

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

  • Index Cond: (cd_veiculo = ct.cd_veiculo)
88. 742.590 742.590 ↑ 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=3.345..3.345 rows=1 loops=222)

  • Index Cond: (cd_ctrc = ct.cd_ctrc)
89. 0.000 83.694 ↑ 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.377..0.377 rows=1 loops=222)

  • Index Cond: (cd_ctrc_produto = (SubPlan 11))
90.          

SubPlan (for Index Scan)

91. 1.110 257.076 ↑ 1.0 1 222

Limit (cost=8.46..8.46 rows=1 width=18) (actual time=1.157..1.158 rows=1 loops=222)

92. 3.330 255.966 ↑ 1.0 1 222

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

  • Sort Key: cp2.vl_peso DESC, cp2.vl_produto DESC, cp2.cd_ctrc_produto
  • Sort Method: quicksort Memory: 25kB
93. 252.636 252.636 ↑ 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=1.137..1.138 rows=1 loops=222)

  • Index Cond: (cd_ctrc = ct.cd_ctrc)
94. 14.430 14.430 ↑ 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.065..0.065 rows=1 loops=222)

  • Index Cond: (cd_produto = cp.cd_produto)
95. 11.766 11.766 ↑ 1.0 1 222

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

  • Index Cond: (cd_pessoa = ct.cd_pessoa_motorista)
96. 5.106 5.106 ↑ 1.0 1 222

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

  • Index Cond: (cd_agencia = ct.cd_agencia)
97. 52.614 52.614 ↓ 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.237..0.237 rows=0 loops=222)

  • Index Cond: (cd_carta_frete_diaria = cfpa.cd_carta_frete_diaria)
98. 1.110 1.110 ↑ 1.0 1 222

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

  • Index Cond: (cd_pessoa = cfp.cd_pessoa)
99. 197.802 197.802 ↑ 1.0 1 222

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

  • Index Cond: (cd_cidade = pcf.cd_cidade)
100. 1.554 1.554 ↑ 1.0 1 222

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

  • Index Cond: (cd_uf = cpcf.cd_uf)
101. 1.110 1.110 ↑ 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.005..0.005 rows=1 loops=222)

  • Index Cond: (cd_tipo_veiculo = v.cd_tipo_veiculo)
102. 2.664 2.664 ↑ 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.012..0.012 rows=1 loops=222)

  • Index Cond: (cd_marca = v.cd_marca)
103. 1.998 1.998 ↑ 1.0 1 222

Index Scan using pk_pessoa on pessoa pu (cost=0.42..8.44 rows=1 width=28) (actual time=0.009..0.009 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)
104. 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)
105. 1,937.198 1,974.912 ↑ 1.0 9,940 222

HashAggregate (cost=216.10..341.20 rows=10,008 width=36) (actual time=0.223..8.896 rows=9,940 loops=222)

  • Group Key: cfod.cd_ctrc
106. 37.714 37.714 ↑ 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=17.905..37.714 rows=10,073 loops=1)

107. 3.108 3.108 ↑ 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.014..0.014 rows=1 loops=222)

  • Index Cond: (cd_pessoa = ct.cd_pessoa_embarque)
  • Heap Fetches: 0
108. 1.332 1.332 ↑ 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.006..0.006 rows=1 loops=222)

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

SubPlan (for Nested Loop)

110. 133.308 133.308 ↑ 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=22.216..22.218 rows=1 loops=6)

  • Index Cond: (cd_ctrc = cf.cd_ctrc)
  • Filter: (id_antecipado = '0'::smallint)
111. 60.188 60.188 ↓ 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=1.468..1.468 rows=0 loops=41)

  • Index Cond: (cd_ctrc = cf.cd_ctrc)
  • Filter: (id_antecipado = '1'::smallint)
  • Rows Removed by Filter: 1
112. 0.120 0.120 ↑ 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.019..0.020 rows=1 loops=6)

  • Index Cond: (cd_ctrc = cf.cd_ctrc)
  • Filter: (id_antecipado = '0'::smallint)
113. 0.246 0.246 ↓ 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.006..0.006 rows=0 loops=41)

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

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

115. 13.320 13.320 ↑ 1.0 1 222

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

  • Index Cond: (cd_titulo = t.cd_titulo)
116. 993.228 993.228 ↓ 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=4.473..4.474 rows=0 loops=222)

  • Index Cond: (cd_pessoa = ct.cd_pessoa_transportadora_doc)
117. 0.666 8.436 ↑ 1.0 1 222

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

118. 1.110 7.770 ↓ 0.0 0 222

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

119. 6.660 6.660 ↓ 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.030..0.030 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
120. 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)
121. 0.444 1.110 ↑ 1.0 1 222

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

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

123. 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
124. 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)
125. 17.094 806.970 ↑ 1.0 1 222

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

126. 1.216 789.876 ↑ 2.0 1 222

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

127. 1.466 6.660 ↑ 2.0 1 222

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

128. 2.664 2.664 ↑ 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.011..0.012 rows=1 loops=222)

  • Index Cond: (cd_movimento = cfp.cd_movimento)
129. 2.530 2.530 ↑ 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.011..0.011 rows=1 loops=230)

  • Index Cond: (cd_titulo = t_3.cd_titulo)
130. 782.000 782.000 ↑ 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=3.400..3.400 rows=1 loops=230)

  • Index Cond: (cd_cheque = td_3.cd_cheque)
  • Filter: (nr_cheque IS NOT NULL)
131. 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)
132. 0.014 0.189 ↓ 0.0 0 1

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

133. 0.008 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)

134. 0.007 0.167 ↓ 0.0 0 1

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

135. 0.007 0.160 ↓ 0.0 0 1

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

136. 0.003 0.153 ↓ 0.0 0 1

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

137. 0.007 0.150 ↓ 0.0 0 1

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

138. 0.006 0.143 ↓ 0.0 0 1

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

139. 0.008 0.137 ↓ 0.0 0 1

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

140. 0.007 0.129 ↓ 0.0 0 1

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

141. 0.004 0.122 ↓ 0.0 0 1

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

142. 0.011 0.118 ↓ 0.0 0 1

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

143. 0.007 0.107 ↓ 0.0 0 1

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

144. 0.008 0.100 ↓ 0.0 0 1

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

145. 0.007 0.092 ↓ 0.0 0 1

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

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

147. 0.007 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)

148. 0.007 0.071 ↓ 0.0 0 1

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

149. 0.007 0.064 ↓ 0.0 0 1

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

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

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

151. 0.010 0.050 ↓ 0.0 0 1

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

152. 0.012 0.040 ↓ 0.0 0 1

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

  • Hash Cond: (cf_1.cd_pessoa_matriz = ve.cd_pessoa)
153. 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.027..0.028 rows=0 loops=1)

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

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

155. 0.000 0.000 ↓ 0.0 0

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

156. 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))
157. 0.000 0.000 ↓ 0.0 0

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

158. 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)
159. 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)
160. 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))
161. 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))
162. 0.000 0.000 ↓ 0.0 0

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

163. 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 18), f_1.cd_pessoa_matriz))
164. 0.000 0.000 ↓ 0.0 0

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

165. 0.000 0.000 ↓ 0.0 0

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

166. 0.000 0.000 ↓ 0.0 0

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

167. 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)
168. 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)
169. 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)
170. 0.000 0.000 ↓ 0.0 0

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

171. 0.000 0.000 ↓ 0.0 0

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

172. 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)
173. 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)
174. 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)
175. 0.000 0.000 ↓ 0.0 0

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

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

177. 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)
178. 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)
179. 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)
180.          

SubPlan (for Nested Loop)

181. 0.000 0.000 ↓ 0.0 0

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

182. 0.000 0.000 ↓ 0.0 0

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

183. 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
184. 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))
185. 0.000 0.000 ↓ 0.0 0

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

186. 0.000 0.000 ↓ 0.0 0

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

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

188. 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
189. 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)
190. 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)
191. 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)
192. 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)
193. 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)
194. 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)
195. 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
196. 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
197. 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)
198. 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))
199. 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)
200. 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)
201. 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)
202. 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)
203. 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)
204. 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)
205. 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)
206. 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)
207.          

SubPlan (for Nested Loop Left Join)

208. 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)
209. 0.012 0.214 ↓ 0.0 0 1

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

210. 0.004 0.202 ↓ 0.0 0 1

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

211. 0.006 0.198 ↓ 0.0 0 1

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

212. 0.010 0.192 ↓ 0.0 0 1

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

213. 0.007 0.182 ↓ 0.0 0 1

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

214. 0.007 0.175 ↓ 0.0 0 1

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

215. 0.006 0.168 ↓ 0.0 0 1

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

216. 0.007 0.162 ↓ 0.0 0 1

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

217. 0.007 0.155 ↓ 0.0 0 1

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

218. 0.005 0.148 ↓ 0.0 0 1

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

219. 0.007 0.143 ↓ 0.0 0 1

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

220. 0.007 0.136 ↓ 0.0 0 1

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

221. 0.004 0.129 ↓ 0.0 0 1

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

222. 0.006 0.125 ↓ 0.0 0 1

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

223. 0.057 0.119 ↓ 0.0 0 1

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

224. 0.007 0.062 ↓ 0.0 0 1

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

225. 0.007 0.055 ↓ 0.0 0 1

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

226. 0.006 0.048 ↓ 0.0 0 1

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

  • Join Filter: (cf_2.cd_pessoa_filial = p_8.cd_pessoa)
227. 0.007 0.042 ↓ 0.0 0 1

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

228. 0.007 0.035 ↓ 0.0 0 1

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

229. 0.014 0.028 ↓ 0.0 0 1

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

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

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

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

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

232. 0.000 0.000 ↓ 0.0 0

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

233. 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))
234. 0.000 0.000 ↓ 0.0 0

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

235. 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)
236. 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)
237. 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))
238. 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))
239. 0.000 0.000 ↓ 0.0 0

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

240. 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 20), f_2.cd_pessoa_matriz))
241. 0.000 0.000 ↓ 0.0 0

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

242. 0.000 0.000 ↓ 0.0 0

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

243. 0.000 0.000 ↓ 0.0 0

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

244. 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)
245. 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)
246. 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)
247. 0.000 0.000 ↓ 0.0 0

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

248. 0.000 0.000 ↓ 0.0 0

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

249. 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)
250. 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)
251. 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)
252. 0.000 0.000 ↓ 0.0 0

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

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

254. 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)
255. 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)
256. 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)
257.          

SubPlan (for Nested Loop)

258. 0.000 0.000 ↓ 0.0 0

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

259. 0.000 0.000 ↓ 0.0 0

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

260. 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
261. 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))
262. 0.000 0.000 ↓ 0.0 0

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

263. 0.000 0.000 ↓ 0.0 0

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

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

265. 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
266. 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)
267. 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)
268. 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)
269. 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)
270. 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)
271. 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)
272. 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
273. 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
274. 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)
275. 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))
276. 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)
277. 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)
278. 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)
279. 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)
280. 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)
281. 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)
282. 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)
283. 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)
284.          

SubPlan (for Nested Loop Left Join)

285. 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 : 447.866 ms
Execution time : 783,848.254 ms