explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 6MRs

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

Subquery Scan on t1 (cost=209,988.38..116,847,562.05 rows=20 width=300) (actual rows= loops=)

2.          

Initplan (for Subquery Scan)

3. 0.000 0.000 ↓ 0.0

Aggregate (cost=82,213.09..82,213.10 rows=1 width=32) (actual rows= loops=)

4. 0.000 0.000 ↓ 0.0

Limit (cost=82,213.08..82,213.08 rows=1 width=38) (actual rows= loops=)

5. 0.000 0.000 ↓ 0.0

Sort (cost=82,213.08..82,214.42 rows=538 width=38) (actual rows= loops=)

  • Sort Key: (max(vr.created_at)) DESC
6. 0.000 0.000 ↓ 0.0

GroupAggregate (cost=82,192.41..82,210.39 rows=538 width=38) (actual rows= loops=)

  • Group Key: vr.nome_arquivo
  • Filter: (count(d_1.ve_seq_doc) > 10)
7. 0.000 0.000 ↓ 0.0

Sort (cost=82,192.41..82,195.56 rows=1,260 width=46) (actual rows= loops=)

  • Sort Key: vr.nome_arquivo
8. 0.000 0.000 ↓ 0.0

Nested Loop (cost=1,079.45..82,127.52 rows=1,260 width=46) (actual rows= loops=)

9. 0.000 0.000 ↓ 0.0

Nested Loop (cost=1,079.01..81,373.75 rows=1,201 width=42) (actual rows= loops=)

10. 0.000 0.000 ↓ 0.0

Nested Loop (cost=1,078.86..81,166.57 rows=1,201 width=44) (actual rows= loops=)

  • Join Filter: (l_1.ve_status = ls.id)
11. 0.000 0.000 ↓ 0.0

Nested Loop (cost=1,078.86..81,003.32 rows=1,201 width=46) (actual rows= loops=)

  • Join Filter: (v_2.rv_ano_licenciamento = (l_1.ve_ano_exercicio)::double precision)
12. 0.000 0.000 ↓ 0.0

Nested Loop (cost=1,078.30..48,940.87 rows=34,552 width=67) (actual rows= loops=)

  • Join Filter: (la.rv_cod_atendimento = v_2.rv_cod_atendimento)
13. 0.000 0.000 ↓ 0.0

Nested Loop (cost=1,077.87..27,310.20 rows=34,552 width=63) (actual rows= loops=)

14. 0.000 0.000 ↓ 0.0

Nested Loop (cost=1,077.43..7,288.57 rows=34,552 width=42) (actual rows= loops=)

15. 0.000 0.000 ↓ 0.0

Hash Join (cost=1,077.00..3,055.91 rows=299 width=42) (actual rows= loops=)

  • Hash Cond: (vr.id = rl.remessa_id)
16. 0.000 0.000 ↓ 0.0

Seq Scan on remessa vr (cost=0.00..1,885.13 rows=538 width=42) (actual rows= loops=)

  • Filter: ((canceled_at IS NULL) AND ((nome_arquivo)::text ~~* '%CRLV%'::text) AND (empresa_id = 8))
17. 0.000 0.000 ↓ 0.0

Hash (cost=712.00..712.00 rows=29,200 width=8) (actual rows= loops=)

18. 0.000 0.000 ↓ 0.0

Seq Scan on remessa_lotes rl (cost=0.00..712.00 rows=29,200 width=8) (actual rows= loops=)

19. 0.000 0.000 ↓ 0.0

Index Scan using idx_rv_lote_atendimento_rv_num_lote2 on rv_lote_atendimento la (cost=0.43..13.00 rows=116 width=8) (actual rows= loops=)

  • Index Cond: (rv_num_lote = rl.numero_lote)
20. 0.000 0.000 ↓ 0.0

Index Scan using rv_atendimento_pkey on rv_atendimento a (cost=0.43..0.57 rows=1 width=21) (actual rows= loops=)

  • Index Cond: (rv_cod_atendimento = la.rv_cod_atendimento)
21. 0.000 0.000 ↓ 0.0

Index Scan using rv_veiculo_atendimento_pkey on rv_veiculo_atendimento v_2 (cost=0.43..0.61 rows=1 width=12) (actual rows= loops=)

  • Index Cond: (rv_cod_atendimento = a.rv_cod_atendimento)
22. 0.000 0.000 ↓ 0.0

Index Scan using ve_licenciamento_pk on ve_licenciamento l_1 (cost=0.56..0.79 rows=9 width=25) (actual rows= loops=)

  • Index Cond: ((ve_chassi)::text = (a.rv_num_chassi)::text)
23. 0.000 0.000 ↓ 0.0

Materialize (cost=0.00..1.14 rows=9 width=2) (actual rows= loops=)

24. 0.000 0.000 ↓ 0.0

Seq Scan on ve_licenciamento_status ls (cost=0.00..1.09 rows=9 width=2) (actual rows= loops=)

25. 0.000 0.000 ↓ 0.0

Index Only Scan using ve_impedimento_dual_pk on ve_impedimento_dual lid (cost=0.14..0.16 rows=1 width=4) (actual rows= loops=)

  • Index Cond: (id = l_1.ve_impedimento)
26. 0.000 0.000 ↓ 0.0

Index Scan using idx_vdoc_num_atendimento_doc4 on ve_documento d_1 (cost=0.44..0.62 rows=1 width=16) (actual rows= loops=)

  • Index Cond: (ve_num_atendimento_doc = (la.rv_cod_atendimento)::double precision)
27. 0.000 0.000 ↓ 0.0

Aggregate (cost=28,495.76..28,495.77 rows=1 width=32) (actual rows= loops=)

28. 0.000 0.000 ↓ 0.0

Limit (cost=28,495.74..28,495.74 rows=1 width=38) (actual rows= loops=)

29. 0.000 0.000 ↓ 0.0

Sort (cost=28,495.74..28,496.53 rows=317 width=38) (actual rows= loops=)

  • Sort Key: (max(vr_1.created_at)) DESC
30. 0.000 0.000 ↓ 0.0

GroupAggregate (cost=28,488.61..28,494.16 rows=317 width=38) (actual rows= loops=)

  • Group Key: vr_1.nome_arquivo
31. 0.000 0.000 ↓ 0.0

Sort (cost=28,488.61..28,489.40 rows=317 width=38) (actual rows= loops=)

  • Sort Key: vr_1.nome_arquivo
32. 0.000 0.000 ↓ 0.0

Nested Loop (cost=1,894.31..28,475.44 rows=317 width=38) (actual rows= loops=)

33. 0.000 0.000 ↓ 0.0

Nested Loop (cost=1,893.87..28,318.98 rows=302 width=42) (actual rows= loops=)

34. 0.000 0.000 ↓ 0.0

Nested Loop (cost=1,893.72..28,266.89 rows=302 width=44) (actual rows= loops=)

  • Join Filter: (l_2.ve_status = ls_1.id)
35. 0.000 0.000 ↓ 0.0

Nested Loop (cost=1,893.72..28,225.01 rows=302 width=46) (actual rows= loops=)

  • Join Filter: (v_3.rv_ano_licenciamento = (l_2.ve_ano_exercicio)::double precision)
36. 0.000 0.000 ↓ 0.0

Nested Loop (cost=1,893.16..20,174.13 rows=8,676 width=67) (actual rows= loops=)

  • Join Filter: (la_1.rv_cod_atendimento = v_3.rv_cod_atendimento)
37. 0.000 0.000 ↓ 0.0

Nested Loop (cost=1,892.73..14,742.67 rows=8,676 width=63) (actual rows= loops=)

38. 0.000 0.000 ↓ 0.0

Nested Loop (cost=1,892.29..6,688.88 rows=8,676 width=42) (actual rows= loops=)

39. 0.000 0.000 ↓ 0.0

Hash Join (cost=1,891.86..2,716.35 rows=299 width=42) (actual rows= loops=)

  • Hash Cond: (rl_1.remessa_id = vr_1.id)
40. 0.000 0.000 ↓ 0.0

Seq Scan on remessa_lotes rl_1 (cost=0.00..712.00 rows=29,200 width=8) (actual rows= loops=)

41. 0.000 0.000 ↓ 0.0

Hash (cost=1,885.13..1,885.13 rows=538 width=42) (actual rows= loops=)

42. 0.000 0.000 ↓ 0.0

Seq Scan on remessa vr_1 (cost=0.00..1,885.13 rows=538 width=42) (actual rows= loops=)

  • Filter: ((canceled_at IS NULL) AND ((nome_arquivo)::text ~~* '%CRLV%'::text) AND (empresa_id = 8))
43. 0.000 0.000 ↓ 0.0

Index Scan using idx_rv_lote_atendimento_rv_num_lote2 on rv_lote_atendimento la_1 (cost=0.43..13.00 rows=29 width=8) (actual rows= loops=)

  • Index Cond: (rv_num_lote = rl_1.numero_lote)
  • Filter: (id_ar IS NOT NULL)
44. 0.000 0.000 ↓ 0.0

Index Scan using rv_atendimento_pkey on rv_atendimento a_1 (cost=0.43..0.92 rows=1 width=21) (actual rows= loops=)

  • Index Cond: (rv_cod_atendimento = la_1.rv_cod_atendimento)
45. 0.000 0.000 ↓ 0.0

Index Scan using rv_veiculo_atendimento_pkey on rv_veiculo_atendimento v_3 (cost=0.43..0.61 rows=1 width=12) (actual rows= loops=)

  • Index Cond: (rv_cod_atendimento = a_1.rv_cod_atendimento)
46. 0.000 0.000 ↓ 0.0

Index Scan using ve_licenciamento_pk on ve_licenciamento l_2 (cost=0.56..0.79 rows=9 width=25) (actual rows= loops=)

  • Index Cond: ((ve_chassi)::text = (a_1.rv_num_chassi)::text)
47. 0.000 0.000 ↓ 0.0

Materialize (cost=0.00..1.14 rows=9 width=2) (actual rows= loops=)

48. 0.000 0.000 ↓ 0.0

Seq Scan on ve_licenciamento_status ls_1 (cost=0.00..1.09 rows=9 width=2) (actual rows= loops=)

49. 0.000 0.000 ↓ 0.0

Index Only Scan using ve_impedimento_dual_pk on ve_impedimento_dual lid_1 (cost=0.14..0.16 rows=1 width=4) (actual rows= loops=)

  • Index Cond: (id = l_2.ve_impedimento)
50. 0.000 0.000 ↓ 0.0

Index Only Scan using idx_vdoc_num_atendimento_doc4 on ve_documento d_2 (cost=0.44..0.51 rows=1 width=8) (actual rows= loops=)

  • Index Cond: (ve_num_atendimento_doc = (la_1.rv_cod_atendimento)::double precision)
51. 0.000 0.000 ↓ 0.0

Aggregate (cost=77,780.62..77,780.64 rows=1 width=32) (actual rows= loops=)

52. 0.000 0.000 ↓ 0.0

Limit (cost=77,780.61..77,780.61 rows=1 width=38) (actual rows= loops=)

53. 0.000 0.000 ↓ 0.0

Sort (cost=77,780.61..77,781.13 rows=210 width=38) (actual rows= loops=)

  • Sort Key: (max(vr_2.created_at)) DESC
54. 0.000 0.000 ↓ 0.0

GroupAggregate (cost=77,775.88..77,779.56 rows=210 width=38) (actual rows= loops=)

  • Group Key: vr_2.nome_arquivo
55. 0.000 0.000 ↓ 0.0

Sort (cost=77,775.88..77,776.41 rows=210 width=38) (actual rows= loops=)

  • Sort Key: vr_2.nome_arquivo
56. 0.000 0.000 ↓ 0.0

Nested Loop (cost=1,079.45..77,767.78 rows=210 width=38) (actual rows= loops=)

57. 0.000 0.000 ↓ 0.0

Nested Loop (cost=1,079.01..77,672.12 rows=200 width=42) (actual rows= loops=)

58. 0.000 0.000 ↓ 0.0

Nested Loop (cost=1,078.86..77,637.62 rows=200 width=44) (actual rows= loops=)

59. 0.000 0.000 ↓ 0.0

Seq Scan on ve_licenciamento_status ls_2 (cost=0.00..1.11 rows=1 width=2) (actual rows= loops=)

  • Filter: (id = 8)
60. 0.000 0.000 ↓ 0.0

Nested Loop (cost=1,078.86..77,634.50 rows=200 width=46) (actual rows= loops=)

  • Join Filter: (v_4.rv_ano_licenciamento = (l_3.ve_ano_exercicio)::double precision)
61. 0.000 0.000 ↓ 0.0

Nested Loop (cost=1,078.30..48,940.87 rows=34,552 width=67) (actual rows= loops=)

  • Join Filter: (la_2.rv_cod_atendimento = v_4.rv_cod_atendimento)
62. 0.000 0.000 ↓ 0.0

Nested Loop (cost=1,077.87..27,310.20 rows=34,552 width=63) (actual rows= loops=)

63. 0.000 0.000 ↓ 0.0

Nested Loop (cost=1,077.43..7,288.57 rows=34,552 width=42) (actual rows= loops=)

64. 0.000 0.000 ↓ 0.0

Hash Join (cost=1,077.00..3,055.91 rows=299 width=42) (actual rows= loops=)

  • Hash Cond: (vr_2.id = rl_2.remessa_id)
65. 0.000 0.000 ↓ 0.0

Seq Scan on remessa vr_2 (cost=0.00..1,885.13 rows=538 width=42) (actual rows= loops=)

  • Filter: ((canceled_at IS NULL) AND ((nome_arquivo)::text ~~* '%CRLV%'::text) AND (empresa_id = 8))
66. 0.000 0.000 ↓ 0.0

Hash (cost=712.00..712.00 rows=29,200 width=8) (actual rows= loops=)

67. 0.000 0.000 ↓ 0.0

Seq Scan on remessa_lotes rl_2 (cost=0.00..712.00 rows=29,200 width=8) (actual rows= loops=)

68. 0.000 0.000 ↓ 0.0

Index Scan using idx_rv_lote_atendimento_rv_num_lote2 on rv_lote_atendimento la_2 (cost=0.43..13.00 rows=116 width=8) (actual rows= loops=)

  • Index Cond: (rv_num_lote = rl_2.numero_lote)
69. 0.000 0.000 ↓ 0.0

Index Scan using rv_atendimento_pkey on rv_atendimento a_2 (cost=0.43..0.57 rows=1 width=21) (actual rows= loops=)

  • Index Cond: (rv_cod_atendimento = la_2.rv_cod_atendimento)
70. 0.000 0.000 ↓ 0.0

Index Scan using rv_veiculo_atendimento_pkey on rv_veiculo_atendimento v_4 (cost=0.43..0.61 rows=1 width=12) (actual rows= loops=)

  • Index Cond: (rv_cod_atendimento = a_2.rv_cod_atendimento)
71. 0.000 0.000 ↓ 0.0

Index Scan using ve_licenciamento_pk on ve_licenciamento l_3 (cost=0.56..0.82 rows=1 width=25) (actual rows= loops=)

  • Index Cond: ((ve_chassi)::text = (a_2.rv_num_chassi)::text)
  • Filter: (ve_status = 8)
72. 0.000 0.000 ↓ 0.0

Index Only Scan using ve_impedimento_dual_pk on ve_impedimento_dual lid_2 (cost=0.14..0.16 rows=1 width=4) (actual rows= loops=)

  • Index Cond: (id = l_3.ve_impedimento)
73. 0.000 0.000 ↓ 0.0

Index Only Scan using idx_vdoc_num_atendimento_doc4 on ve_documento d_3 (cost=0.44..0.47 rows=1 width=8) (actual rows= loops=)

  • Index Cond: (ve_num_atendimento_doc = (la_2.rv_cod_atendimento)::double precision)
74. 0.000 0.000 ↓ 0.0

GroupAggregate (cost=21,498.87..53,878,188.83 rows=20 width=104) (actual rows= loops=)

  • Group Key: t.tipo
75. 0.000 0.000 ↓ 0.0

Sort (cost=21,498.87..21,498.92 rows=20 width=44) (actual rows= loops=)

  • Sort Key: t.tipo
76. 0.000 0.000 ↓ 0.0

Subquery Scan on t (cost=21,497.69..21,498.44 rows=20 width=44) (actual rows= loops=)

77. 0.000 0.000 ↓ 0.0

GroupAggregate (cost=21,497.69..21,498.24 rows=20 width=44) (actual rows= loops=)

  • Group Key: l2.ve_ano_exercicio, (CASE WHEN ((v.ve_cod_munic)::text = ANY ('{01389,1389}'::text[])) THEN 'CAPITAL'::text WHEN (((v.ve_cod_munic)::text <> ALL ('{01389,1389}'::text[])) AND (COALESCE(p.ve_numero_arrend_prop, '0'::dou (...)
78. 0.000 0.000 ↓ 0.0

Sort (cost=21,497.69..21,497.74 rows=20 width=53) (actual rows= loops=)

  • Sort Key: l2.ve_ano_exercicio, (CASE WHEN ((v.ve_cod_munic)::text = ANY ('{01389,1389}'::text[])) THEN 'CAPITAL'::text WHEN (((v.ve_cod_munic)::text <> ALL ('{01389,1389}'::text[])) AND (COALESCE(p.ve_numero_arrend_prop, '0' (...)
79. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=8,154.01..21,497.26 rows=20 width=53) (actual rows= loops=)

80. 0.000 0.000 ↓ 0.0

Nested Loop (cost=8,116.75..19,897.55 rows=20 width=43) (actual rows= loops=)

  • Join Filter: ((l.ve_chassi)::text = (v.ve_chassi)::text)
81. 0.000 0.000 ↓ 0.0

Nested Loop (cost=8,116.32..19,874.44 rows=46 width=38) (actual rows= loops=)

82. 0.000 0.000 ↓ 0.0

HashAggregate (cost=8,115.76..8,133.64 rows=1,788 width=21) (actual rows= loops=)

  • Group Key: l.ve_chassi
83. 0.000 0.000 ↓ 0.0

Index Scan using ve_licenciamento_dt_emissao_idx on ve_licenciamento l (cost=0.43..8,106.81 rows=1,789 width=21) (actual rows= loops=)

  • Index Cond: (dt_emissao IS NULL)
  • Filter: ((ve_ano_exercicio)::double precision > (date_part('year'::text, now()) - '2'::double precision))
84. 0.000 0.000 ↓ 0.0

Index Scan using ve_licenciamento_pk on ve_licenciamento l2 (cost=0.56..6.55 rows=1 width=21) (actual rows= loops=)

  • Index Cond: (((ve_chassi)::text = (l.ve_chassi)::text) AND (ve_ano_exercicio = (max(l.ve_ano_exercicio))))
  • Filter: ((ve_impedimento IS NULL) AND (ve_status IS NULL))
85. 0.000 0.000 ↓ 0.0

Index Scan using ve_veiculo_pkey on ve_veiculo v (cost=0.43..0.49 rows=1 width=22) (actual rows= loops=)

  • Index Cond: ((ve_chassi)::text = (l2.ve_chassi)::text)
86. 0.000 0.000 ↓ 0.0

Index Scan using ve_proprietario_chassi_seq_desc_idx2 on ve_proprietario p (cost=37.27..79.97 rows=1 width=41) (actual rows= loops=)

  • Index Cond: (((ve_chassi)::text = (l.ve_chassi)::text) AND (ve_seq_prop_chassi = (SubPlan 15)))
  • Filter: (ve_seq_prop = (SubPlan 16))
87.          

SubPlan (for Index Scan)

88. 0.000 0.000 ↓ 0.0

Limit (cost=36.69..36.71 rows=1 width=8) (actual rows= loops=)

89. 0.000 0.000 ↓ 0.0

Subquery Scan on p2_9 (cost=36.69..36.83 rows=11 width=8) (actual rows= loops=)

90. 0.000 0.000 ↓ 0.0

Sort (cost=36.69..36.72 rows=11 width=76) (actual rows= loops=)

  • Sort Key: prop2_9.ve_seq_prop_chassi DESC, prop2_9.ve_seq_prop DESC
91. 0.000 0.000 ↓ 0.0

Index Scan using ve_proprietario_chassi_seq_desc_idx2 on ve_proprietario prop2_9 (cost=0.56..36.50 rows=11 width=76) (actual rows= loops=)

  • Index Cond: ((ve_chassi)::text = (l.ve_chassi)::text)
92. 0.000 0.000 ↓ 0.0

Limit (cost=36.69..36.71 rows=1 width=8) (actual rows= loops=)

93. 0.000 0.000 ↓ 0.0

Subquery Scan on p2_8 (cost=36.69..36.83 rows=11 width=8) (actual rows= loops=)

94. 0.000 0.000 ↓ 0.0

Sort (cost=36.69..36.72 rows=11 width=76) (actual rows= loops=)

  • Sort Key: prop2_8.ve_seq_prop_chassi DESC, prop2_8.ve_seq_prop DESC
95. 0.000 0.000 ↓ 0.0

Index Scan using ve_proprietario_chassi_seq_desc_idx2 on ve_proprietario prop2_8 (cost=0.56..36.50 rows=11 width=76) (actual rows= loops=)

  • Index Cond: ((ve_chassi)::text = (l.ve_chassi)::text)
96.          

SubPlan (for GroupAggregate)

97. 0.000 0.000 ↓ 0.0

Aggregate (cost=2,628,608.71..2,628,608.73 rows=1 width=32) (actual rows= loops=)

98. 0.000 0.000 ↓ 0.0

GroupAggregate (cost=2,628,606.50..2,628,608.06 rows=52 width=44) (actual rows= loops=)

  • Group Key: ((l2_1.ve_data_hora)::date), (CASE WHEN ((v_5.ve_cod_munic)::text = ANY ('{01389,1389}'::text[])) THEN 'CAPITAL'::text WHEN (((v_5.ve_cod_munic)::text <> ALL ('{01389,1389}'::text[])) AND (COALESCE(p_2.ve_numero_arrend_prop (...)
99. 0.000 0.000 ↓ 0.0

Sort (cost=2,628,606.50..2,628,606.63 rows=52 width=40) (actual rows= loops=)

  • Sort Key: ((l2_1.ve_data_hora)::date), (CASE WHEN ((v_5.ve_cod_munic)::text = ANY ('{01389,1389}'::text[])) THEN 'CAPITAL'::text WHEN (((v_5.ve_cod_munic)::text <> ALL ('{01389,1389}'::text[])) AND (COALESCE(p_2.ve_numero_arrend (...)
100. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=1,169,323.78..2,628,605.02 rows=52 width=40) (actual rows= loops=)

  • Filter: (CASE WHEN ((v_5.ve_cod_munic)::text = ANY ('{01389,1389}'::text[])) THEN 'CAPITAL'::text WHEN (((v_5.ve_cod_munic)::text <> ALL ('{01389,1389}'::text[])) AND (COALESCE(p_2.ve_numero_arrend_prop, '0'::double precis (...)
101. 0.000 0.000 ↓ 0.0

Hash Join (cost=1,169,286.52..1,850,159.08 rows=10,387 width=34) (actual rows= loops=)

  • Hash Cond: (((l2_1.ve_chassi)::text = (v_5.ve_chassi)::text) AND (l2_1.ve_ano_exercicio = (max(l_4.ve_ano_exercicio))))
102. 0.000 0.000 ↓ 0.0

Seq Scan on ve_licenciamento l2_1 (cost=0.00..546,595.22 rows=5,032,448 width=29) (actual rows= loops=)

  • Filter: ((ve_data_hora)::date >= (date_trunc('year'::text, now()))::date)
103. 0.000 0.000 ↓ 0.0

Hash (cost=1,128,564.82..1,128,564.82 rows=1,711,780 width=43) (actual rows= loops=)

104. 0.000 0.000 ↓ 0.0

Hash Join (cost=223,785.90..1,128,564.82 rows=1,711,780 width=43) (actual rows= loops=)

  • Hash Cond: ((l_4.ve_chassi)::text = (v_5.ve_chassi)::text)
105. 0.000 0.000 ↓ 0.0

GroupAggregate (cost=0.56..813,347.53 rows=1,711,780 width=21) (actual rows= loops=)

  • Group Key: l_4.ve_chassi
106. 0.000 0.000 ↓ 0.0

Index Only Scan using ve_licenciamento_pk on ve_licenciamento l_4 (cost=0.56..771,067.49 rows=5,032,448 width=21) (actual rows= loops=)

  • Filter: ((ve_ano_exercicio)::double precision > (date_part('year'::text, now()) - '2'::double precision))
107. 0.000 0.000 ↓ 0.0

Hash (cost=147,653.26..147,653.26 rows=4,146,726 width=22) (actual rows= loops=)

108. 0.000 0.000 ↓ 0.0

Seq Scan on ve_veiculo v_5 (cost=0.00..147,653.26 rows=4,146,726 width=22) (actual rows= loops=)

109. 0.000 0.000 ↓ 0.0

Index Scan using ve_proprietario_chassi_seq_desc_idx2 on ve_proprietario p_2 (cost=37.27..74.92 rows=1 width=41) (actual rows= loops=)

  • Index Cond: (((ve_chassi)::text = (l_4.ve_chassi)::text) AND (ve_seq_prop_chassi = (SubPlan 5)))
  • Filter: (ve_seq_prop = (SubPlan 6))
110.          

SubPlan (for Index Scan)

111. 0.000 0.000 ↓ 0.0

Limit (cost=36.69..36.71 rows=1 width=8) (actual rows= loops=)

112. 0.000 0.000 ↓ 0.0

Subquery Scan on p2_1 (cost=36.69..36.83 rows=11 width=8) (actual rows= loops=)

113. 0.000 0.000 ↓ 0.0

Sort (cost=36.69..36.72 rows=11 width=76) (actual rows= loops=)

  • Sort Key: prop2_1.ve_seq_prop_chassi DESC, prop2_1.ve_seq_prop DESC
114. 0.000 0.000 ↓ 0.0

Index Scan using ve_proprietario_chassi_seq_desc_idx2 on ve_proprietario prop2_1 (cost=0.56..36.50 rows=11 width=76) (actual rows= loops=)

  • Index Cond: ((ve_chassi)::text = (l_4.ve_chassi)::text)
115. 0.000 0.000 ↓ 0.0

Limit (cost=36.69..36.71 rows=1 width=8) (actual rows= loops=)

116. 0.000 0.000 ↓ 0.0

Subquery Scan on p2 (cost=36.69..36.83 rows=11 width=8) (actual rows= loops=)

117. 0.000 0.000 ↓ 0.0

Sort (cost=36.69..36.72 rows=11 width=76) (actual rows= loops=)

  • Sort Key: prop2.ve_seq_prop_chassi DESC, prop2.ve_seq_prop DESC
118. 0.000 0.000 ↓ 0.0

Index Scan using ve_proprietario_chassi_seq_desc_idx2 on ve_proprietario prop2 (cost=0.56..36.50 rows=11 width=76) (actual rows= loops=)

  • Index Cond: ((ve_chassi)::text = (l_4.ve_chassi)::text)
119. 0.000 0.000 ↓ 0.0

Aggregate (cost=64,225.73..64,225.74 rows=1 width=4) (actual rows= loops=)

120. 0.000 0.000 ↓ 0.0

Sort (cost=64,225.68..64,225.69 rows=3 width=888) (actual rows= loops=)

  • Sort Key: crlvs.ve_data_hora
121. 0.000 0.000 ↓ 0.0

Subquery Scan on crlvs (cost=64,225.60..64,225.66 rows=3 width=888) (actual rows= loops=)

122. 0.000 0.000 ↓ 0.0

HashAggregate (cost=64,225.60..64,225.63 rows=3 width=888) (actual rows= loops=)

  • Group Key: capital.ve_chassi, capital.ve_placa, capital.ve_ano_exercicio, capital.ve_data_hora, capital.ve_extrato, capital.ve_atendimento, capital.ve_cep_arrend_prop, capital.tipo, capital.codigo_status, capital.status, c (...)
123. 0.000 0.000 ↓ 0.0

Append (cost=20,657.33..64,225.51 rows=3 width=888) (actual rows= loops=)

124. 0.000 0.000 ↓ 0.0

Subquery Scan on capital (cost=20,657.33..20,657.49 rows=1 width=176) (actual rows= loops=)

  • Filter: ((capital.codigo_impedimento IS NULL) AND ((capital.tipo)::text = t.tipo) AND (capital.ve_ano_exercicio = t.ve_ano_exercicio))
125. 0.000 0.000 ↓ 0.0

Limit (cost=20,657.33..20,657.35 rows=9 width=176) (actual rows= loops=)

126. 0.000 0.000 ↓ 0.0

Sort (cost=20,657.33..20,657.35 rows=9 width=176) (actual rows= loops=)

  • Sort Key: l2_2.ve_ano_exercicio, l2_2.ve_data_hora
127. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=8,154.01..20,657.19 rows=9 width=176) (actual rows= loops=)

  • Join Filter: (lid_3.id = l2_2.ve_impedimento)
128. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=8,154.01..20,633.65 rows=9 width=96) (actual rows= loops=)

  • Join Filter: (ls_3.id = l2_2.ve_status)
129. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=8,154.01..20,631.32 rows=9 width=68) (actual rows= loops=)

130. 0.000 0.000 ↓ 0.0

Nested Loop (cost=8,116.75..19,911.52 rows=9 width=77) (actual rows= loops=)

  • Join Filter: ((l_5.ve_chassi)::text = (v_6.ve_chassi)::text)
131. 0.000 0.000 ↓ 0.0

Nested Loop (cost=8,116.32..19,874.44 rows=76 width=70) (actual rows= loops=)

132. 0.000 0.000 ↓ 0.0

HashAggregate (cost=8,115.76..8,133.64 rows=1,788 width=21) (actual rows= loops=)

  • Group Key: l_5.ve_chassi
133. 0.000 0.000 ↓ 0.0

Index Scan using ve_licenciamento_dt_emissao_idx on ve_licenciamento l_5 (cost=0.43..8,106.81 rows=1,789 width=21) (actual rows= loops=)

  • Index Cond: (dt_emissao IS NULL)
  • Filter: ((ve_ano_exercicio)::double precision > (date_part('year'::text, now()) - '2'::double precision))
134. 0.000 0.000 ↓ 0.0

Index Scan using ve_licenciamento_pk on ve_licenciamento l2_2 (cost=0.56..6.55 rows=1 width=53) (actual rows= loops=)

  • Index Cond: (((ve_chassi)::text = (l_5.ve_chassi)::text) AND (ve_ano_exercicio = (max(l_5.ve_ano_exercicio))))
135. 0.000 0.000 ↓ 0.0

Index Scan using ve_veiculo_pkey on ve_veiculo v_6 (cost=0.43..0.48 rows=1 width=24) (actual rows= loops=)

  • Index Cond: ((ve_chassi)::text = (l2_2.ve_chassi)::text)
  • Filter: ((ve_cod_munic)::text = ANY ('{01389,1389}'::text[]))
136. 0.000 0.000 ↓ 0.0

Index Scan using ve_proprietario_chassi_seq_desc_idx2 on ve_proprietario p_3 (cost=37.27..79.97 rows=1 width=41) (actual rows= loops=)

  • Index Cond: (((ve_chassi)::text = (l_5.ve_chassi)::text) AND (ve_seq_prop_chassi = (SubPlan 12)))
  • Filter: (ve_seq_prop = (SubPlan 13))
137.          

SubPlan (for Index Scan)

138. 0.000 0.000 ↓ 0.0

Limit (cost=36.69..36.71 rows=1 width=8) (actual rows= loops=)

139. 0.000 0.000 ↓ 0.0

Subquery Scan on p2_7 (cost=36.69..36.83 rows=11 width=8) (actual rows= loops=)

140. 0.000 0.000 ↓ 0.0

Sort (cost=36.69..36.72 rows=11 width=76) (actual rows= loops=)

  • Sort Key: prop2_7.ve_seq_prop_chassi DESC, prop2_7.ve_seq_prop DESC
141. 0.000 0.000 ↓ 0.0

Index Scan using ve_proprietario_chassi_seq_desc_idx2 on ve_proprietario prop2_7 (cost=0.56..36.50 rows=11 width=76) (actual rows= loops=)

  • Index Cond: ((ve_chassi)::text = (l_5.ve_chassi)::text)
142. 0.000 0.000 ↓ 0.0

Limit (cost=36.69..36.71 rows=1 width=8) (actual rows= loops=)

143. 0.000 0.000 ↓ 0.0

Subquery Scan on p2_6 (cost=36.69..36.83 rows=11 width=8) (actual rows= loops=)

144. 0.000 0.000 ↓ 0.0

Sort (cost=36.69..36.72 rows=11 width=76) (actual rows= loops=)

  • Sort Key: prop2_6.ve_seq_prop_chassi DESC, prop2_6.ve_seq_prop DESC
145. 0.000 0.000 ↓ 0.0

Index Scan using ve_proprietario_chassi_seq_desc_idx2 on ve_proprietario prop2_6 (cost=0.56..36.50 rows=11 width=76) (actual rows= loops=)

  • Index Cond: ((ve_chassi)::text = (l_5.ve_chassi)::text)
146. 0.000 0.000 ↓ 0.0

Materialize (cost=0.00..1.14 rows=9 width=30) (actual rows= loops=)

147. 0.000 0.000 ↓ 0.0

Seq Scan on ve_licenciamento_status ls_3 (cost=0.00..1.09 rows=9 width=30) (actual rows= loops=)

148. 0.000 0.000 ↓ 0.0

Materialize (cost=0.00..4.19 rows=146 width=50) (actual rows= loops=)

149. 0.000 0.000 ↓ 0.0

Seq Scan on ve_impedimento_dual lid_3 (cost=0.00..3.46 rows=146 width=50) (actual rows= loops=)

150. 0.000 0.000 ↓ 0.0

Subquery Scan on interior (cost=21,810.00..21,810.40 rows=1 width=176) (actual rows= loops=)

  • Filter: ((interior.codigo_impedimento IS NULL) AND ((interior.tipo)::text = t.tipo) AND (interior.ve_ano_exercicio = t.ve_ano_exercicio))
151. 0.000 0.000 ↓ 0.0

Limit (cost=21,810.00..21,810.06 rows=23 width=176) (actual rows= loops=)

152. 0.000 0.000 ↓ 0.0

Sort (cost=21,810.00..21,810.06 rows=23 width=176) (actual rows= loops=)

  • Sort Key: l2_3.ve_ano_exercicio, l2_3.ve_data_hora
153. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=8,154.01..21,809.48 rows=23 width=176) (actual rows= loops=)

  • Join Filter: (lid_4.id = l2_3.ve_impedimento)
154. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=8,154.01..21,755.29 rows=23 width=96) (actual rows= loops=)

  • Join Filter: (ls_4.id = l2_3.ve_status)
155. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=8,154.01..21,751.07 rows=23 width=68) (actual rows= loops=)

  • Filter: (COALESCE(p_4.ve_numero_arrend_prop, '0'::double precision) <> '0'::double precision)
156. 0.000 0.000 ↓ 0.0

Nested Loop (cost=8,116.75..19,911.52 rows=23 width=77) (actual rows= loops=)

  • Join Filter: ((l_6.ve_chassi)::text = (v_7.ve_chassi)::text)
157. 0.000 0.000 ↓ 0.0

Nested Loop (cost=8,116.32..19,874.44 rows=76 width=70) (actual rows= loops=)

158. 0.000 0.000 ↓ 0.0

HashAggregate (cost=8,115.76..8,133.64 rows=1,788 width=21) (actual rows= loops=)

  • Group Key: l_6.ve_chassi
159. 0.000 0.000 ↓ 0.0

Index Scan using ve_licenciamento_dt_emissao_idx on ve_licenciamento l_6 (cost=0.43..8,106.81 rows=1,789 width=21) (actual rows= loops=)

  • Index Cond: (dt_emissao IS NULL)
  • Filter: ((ve_ano_exercicio)::double precision > (date_part('year'::text, now()) - '2'::double precision))
160. 0.000 0.000 ↓ 0.0

Index Scan using ve_licenciamento_pk on ve_licenciamento l2_3 (cost=0.56..6.55 rows=1 width=53) (actual rows= loops=)

  • Index Cond: (((ve_chassi)::text = (l_6.ve_chassi)::text) AND (ve_ano_exercicio = (max(l_6.ve_ano_exercicio))))
161. 0.000 0.000 ↓ 0.0

Index Scan using ve_veiculo_pkey on ve_veiculo v_7 (cost=0.43..0.48 rows=1 width=24) (actual rows= loops=)

  • Index Cond: ((ve_chassi)::text = (l2_3.ve_chassi)::text)
  • Filter: ((ve_cod_munic)::text <> ALL ('{01389,1389}'::text[]))
162. 0.000 0.000 ↓ 0.0

Index Scan using ve_proprietario_chassi_seq_desc_idx2 on ve_proprietario p_4 (cost=37.27..79.97 rows=1 width=49) (actual rows= loops=)

  • Index Cond: (((ve_chassi)::text = (l_6.ve_chassi)::text) AND (ve_seq_prop_chassi = (SubPlan 10)))
  • Filter: (ve_seq_prop = (SubPlan 11))
163.          

SubPlan (for Index Scan)

164. 0.000 0.000 ↓ 0.0

Limit (cost=36.69..36.71 rows=1 width=8) (actual rows= loops=)

165. 0.000 0.000 ↓ 0.0

Subquery Scan on p2_5 (cost=36.69..36.83 rows=11 width=8) (actual rows= loops=)

166. 0.000 0.000 ↓ 0.0

Sort (cost=36.69..36.72 rows=11 width=76) (actual rows= loops=)

  • Sort Key: prop2_5.ve_seq_prop_chassi DESC, prop2_5.ve_seq_prop DESC
167. 0.000 0.000 ↓ 0.0

Index Scan using ve_proprietario_chassi_seq_desc_idx2 on ve_proprietario prop2_5 (cost=0.56..36.50 rows=11 width=76) (actual rows= loops=)

  • Index Cond: ((ve_chassi)::text = (l_6.ve_chassi)::text)
168. 0.000 0.000 ↓ 0.0

Limit (cost=36.69..36.71 rows=1 width=8) (actual rows= loops=)

169. 0.000 0.000 ↓ 0.0

Subquery Scan on p2_4 (cost=36.69..36.83 rows=11 width=8) (actual rows= loops=)

170. 0.000 0.000 ↓ 0.0

Sort (cost=36.69..36.72 rows=11 width=76) (actual rows= loops=)

  • Sort Key: prop2_4.ve_seq_prop_chassi DESC, prop2_4.ve_seq_prop DESC
171. 0.000 0.000 ↓ 0.0

Index Scan using ve_proprietario_chassi_seq_desc_idx2 on ve_proprietario prop2_4 (cost=0.56..36.50 rows=11 width=76) (actual rows= loops=)

  • Index Cond: ((ve_chassi)::text = (l_6.ve_chassi)::text)
172. 0.000 0.000 ↓ 0.0

Materialize (cost=0.00..1.14 rows=9 width=30) (actual rows= loops=)

173. 0.000 0.000 ↓ 0.0

Seq Scan on ve_licenciamento_status ls_4 (cost=0.00..1.09 rows=9 width=30) (actual rows= loops=)

174. 0.000 0.000 ↓ 0.0

Materialize (cost=0.00..4.19 rows=146 width=50) (actual rows= loops=)

175. 0.000 0.000 ↓ 0.0

Seq Scan on ve_impedimento_dual lid_4 (cost=0.00..3.46 rows=146 width=50) (actual rows= loops=)

176. 0.000 0.000 ↓ 0.0

Subquery Scan on interiorsn (cost=21,757.57..21,757.59 rows=1 width=176) (actual rows= loops=)

  • Filter: ((interiorsn.codigo_impedimento IS NULL) AND ((interiorsn.tipo)::text = t.tipo) AND (interiorsn.ve_ano_exercicio = t.ve_ano_exercicio))
177. 0.000 0.000 ↓ 0.0

Limit (cost=21,757.57..21,757.57 rows=1 width=176) (actual rows= loops=)

178. 0.000 0.000 ↓ 0.0

Sort (cost=21,757.57..21,757.57 rows=1 width=176) (actual rows= loops=)

  • Sort Key: l2_4.ve_ano_exercicio, l2_4.ve_data_hora
179. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=8,154.01..21,757.56 rows=1 width=176) (actual rows= loops=)

  • Join Filter: (lid_5.id = l2_4.ve_impedimento)
180. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=8,154.01..21,752.27 rows=1 width=96) (actual rows= loops=)

  • Join Filter: (ls_5.id = l2_4.ve_status)
181. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=8,154.01..21,751.07 rows=1 width=68) (actual rows= loops=)

  • Filter: (COALESCE(p_5.ve_numero_arrend_prop, '0'::double precision) = '0'::double precision)
182. 0.000 0.000 ↓ 0.0

Nested Loop (cost=8,116.75..19,911.52 rows=23 width=77) (actual rows= loops=)

  • Join Filter: ((l_7.ve_chassi)::text = (v_8.ve_chassi)::text)
183. 0.000 0.000 ↓ 0.0

Nested Loop (cost=8,116.32..19,874.44 rows=76 width=70) (actual rows= loops=)

184. 0.000 0.000 ↓ 0.0

HashAggregate (cost=8,115.76..8,133.64 rows=1,788 width=21) (actual rows= loops=)

  • Group Key: l_7.ve_chassi
185. 0.000 0.000 ↓ 0.0

Index Scan using ve_licenciamento_dt_emissao_idx on ve_licenciamento l_7 (cost=0.43..8,106.81 rows=1,789 width=21) (actual rows= loops=)

  • Index Cond: (dt_emissao IS NULL)
  • Filter: ((ve_ano_exercicio)::double precision > (date_part('year'::text, now()) - '2'::double precision))
186. 0.000 0.000 ↓ 0.0

Index Scan using ve_licenciamento_pk on ve_licenciamento l2_4 (cost=0.56..6.55 rows=1 width=53) (actual rows= loops=)

  • Index Cond: (((ve_chassi)::text = (l_7.ve_chassi)::text) AND (ve_ano_exercicio = (max(l_7.ve_ano_exercicio))))
187. 0.000 0.000 ↓ 0.0

Index Scan using ve_veiculo_pkey on ve_veiculo v_8 (cost=0.43..0.48 rows=1 width=24) (actual rows= loops=)

  • Index Cond: ((ve_chassi)::text = (l2_4.ve_chassi)::text)
  • Filter: ((ve_cod_munic)::text <> ALL ('{01389,1389}'::text[]))
188. 0.000 0.000 ↓ 0.0

Index Scan using ve_proprietario_chassi_seq_desc_idx2 on ve_proprietario p_5 (cost=37.27..79.97 rows=1 width=49) (actual rows= loops=)

  • Index Cond: (((ve_chassi)::text = (l_7.ve_chassi)::text) AND (ve_seq_prop_chassi = (SubPlan 8)))
  • Filter: (ve_seq_prop = (SubPlan 9))
189.          

SubPlan (for Index Scan)

190. 0.000 0.000 ↓ 0.0

Limit (cost=36.69..36.71 rows=1 width=8) (actual rows= loops=)

191. 0.000 0.000 ↓ 0.0

Subquery Scan on p2_3 (cost=36.69..36.83 rows=11 width=8) (actual rows= loops=)

192. 0.000 0.000 ↓ 0.0

Sort (cost=36.69..36.72 rows=11 width=76) (actual rows= loops=)

  • Sort Key: prop2_3.ve_seq_prop_chassi DESC, prop2_3.ve_seq_prop DESC
193. 0.000 0.000 ↓ 0.0

Index Scan using ve_proprietario_chassi_seq_desc_idx2 on ve_proprietario prop2_3 (cost=0.56..36.50 rows=11 width=76) (actual rows= loops=)

  • Index Cond: ((ve_chassi)::text = (l_7.ve_chassi)::text)
194. 0.000 0.000 ↓ 0.0

Limit (cost=36.69..36.71 rows=1 width=8) (actual rows= loops=)

195. 0.000 0.000 ↓ 0.0

Subquery Scan on p2_2 (cost=36.69..36.83 rows=11 width=8) (actual rows= loops=)

196. 0.000 0.000 ↓ 0.0

Sort (cost=36.69..36.72 rows=11 width=76) (actual rows= loops=)

  • Sort Key: prop2_2.ve_seq_prop_chassi DESC, prop2_2.ve_seq_prop DESC
197. 0.000 0.000 ↓ 0.0

Index Scan using ve_proprietario_chassi_seq_desc_idx2 on ve_proprietario prop2_2 (cost=0.56..36.50 rows=11 width=76) (actual rows= loops=)

  • Index Cond: ((ve_chassi)::text = (l_7.ve_chassi)::text)
198. 0.000 0.000 ↓ 0.0

Seq Scan on ve_licenciamento_status ls_5 (cost=0.00..1.09 rows=9 width=30) (actual rows= loops=)

199. 0.000 0.000 ↓ 0.0

Seq Scan on ve_impedimento_dual lid_5 (cost=0.00..3.46 rows=146 width=50) (actual rows= loops=)

200.          

SubPlan (for Subquery Scan)

201. 0.000 0.000 ↓ 0.0

Sort (cost=3,139,044.15..3,139,044.16 rows=1 width=8) (actual rows= loops=)

  • Sort Key: (count(d.ve_seq_doc))
202. 0.000 0.000 ↓ 0.0

Aggregate (cost=3,139,044.13..3,139,044.14 rows=1 width=8) (actual rows= loops=)

203. 0.000 0.000 ↓ 0.0

Hash Join (cost=1,645,888.09..3,139,044.13 rows=1 width=8) (actual rows= loops=)

  • Hash Cond: (d.ve_num_atendimento_doc = (v_1.rv_cod_atendimento)::double precision)
  • Join Filter: (CASE WHEN ((v_1.cod_municipio)::integer = 1389) THEN 'CAPITAL'::text WHEN (((v_1.cod_municipio)::integer <> 1389) AND (COALESCE((p_1.rv_numero)::integer, 0) <> 0)) THEN 'INTERIOR'::text ELSE 'INTERIOR SN'::text END = t1. (...)
204. 0.000 0.000 ↓ 0.0

Hash Join (cost=641,200.77..1,550,184.72 rows=161 width=24) (actual rows= loops=)

  • Hash Cond: (d.ve_num_atendimento_doc = (p_1.rv_cod_atendimento)::double precision)
205. 0.000 0.000 ↓ 0.0

Index Scan using idx_ve_dat_emissao_doc_documento3 on ve_documento d (cost=0.57..7,483.47 rows=263 width=16) (actual rows= loops=)

  • Index Cond: ((ve_dat_emissao_doc)::text = to_char(((('now'::cstring)::date - 1))::timestamp with time zone, 'yyyyMMdd'::text))
  • Filter: ((ve_cod_local_emissao_doc)::text = '2220452'::text)
206. 0.000 0.000 ↓ 0.0

Hash (cost=428,869.53..428,869.53 rows=12,942,053 width=8) (actual rows= loops=)

207. 0.000 0.000 ↓ 0.0

Seq Scan on rv_proprietario p_1 (cost=0.00..428,869.53 rows=12,942,053 width=8) (actual rows= loops=)

208. 0.000 0.000 ↓ 0.0

Hash (cost=779,696.59..779,696.59 rows=12,943,259 width=9) (actual rows= loops=)

209. 0.000 0.000 ↓ 0.0

Seq Scan on rv_veiculo_atendimento v_1 (cost=0.00..779,696.59 rows=12,943,259 width=9) (actual rows= loops=)