explain.depesz.com

PostgreSQL's explain analyze made readable

Result: uWHb

Settings
# exclusive inclusive rows x rows loops node
1. 373.762 44,243.569 ↓ 1.1 108,735 1

Sort (cost=4,680,474.35..4,680,720.25 rows=98,359 width=564) (actual time=44,175.824..44,243.569 rows=108,735 loops=1)

  • Sort Key: nfs.emissao
  • Sort Method: external sort Disk: 16720kB
2. 17.098 43,869.807 ↓ 1.1 108,735 1

Append (cost=2,074.01..4,647,439.55 rows=98,359 width=564) (actual time=25.149..43,869.807 rows=108,735 loops=1)

3. 5.881 183.856 ↑ 144.6 421 1

Hash Join (cost=2,074.01..3,280,496.34 rows=60,867 width=409) (actual time=25.148..183.856 rows=421 loops=1)

  • Hash Cond: (nfs.id_cliente = p.id_pessoa)
4. 1.634 153.034 ↑ 144.6 421 1

Hash Anti Join (cost=1,786.58..11,249.89 rows=60,867 width=103) (actual time=23.453..153.034 rows=421 loops=1)

  • Hash Cond: (nfs.id_nota_fiscal_saida = cupom_nfs.id_nota_fiscal_saida)
5. 15.337 129.927 ↑ 27.5 2,279 1

Hash Join (cost=3.99..8,575.87 rows=62,759 width=103) (actual time=0.063..129.927 rows=2,279 loops=1)

  • Hash Cond: (nfs.id_modelo_documento_fiscal = mdf.id_modelo_documento_fiscal)
6. 114.556 114.556 ↑ 1.0 99,271 1

Index Scan using idx_nota_fiscal_saida_emissao on nota_fiscal_saida nfs (cost=0.42..8,291.70 rows=100,707 width=96) (actual time=0.017..114.556 rows=99,271 loops=1)

  • Index Cond: ((emissao >= '2018-01-01'::date) AND (emissao <= '2019-03-31'::date))
  • Filter: (situacao = 1)
  • Rows Removed by Filter: 8560
7. 0.009 0.034 ↑ 1.0 42 1

Hash (cost=3.04..3.04 rows=43 width=11) (actual time=0.034..0.034 rows=42 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 10kB
8. 0.025 0.025 ↑ 1.0 42 1

Seq Scan on modelo_documento_fiscal mdf (cost=0.00..3.04 rows=43 width=11) (actual time=0.009..0.025 rows=42 loops=1)

  • Filter: (codigo_modelo_documento = ANY ('{01,1B,04,55}'::bpchar[]))
  • Rows Removed by Filter: 27
9. 12.440 21.473 ↑ 1.0 66,204 1

Hash (cost=955.04..955.04 rows=66,204 width=4) (actual time=21.473..21.473 rows=66,204 loops=1)

  • Buckets: 131072 Batches: 1 Memory Usage: 3352kB
10. 9.033 9.033 ↑ 1.0 66,204 1

Seq Scan on cupom_nfs (cost=0.00..955.04 rows=66,204 width=4) (actual time=0.011..9.033 rows=66,204 loops=1)

11. 0.600 1.296 ↑ 1.0 4,730 1

Hash (cost=228.30..228.30 rows=4,730 width=8) (actual time=1.296..1.296 rows=4,730 loops=1)

  • Buckets: 8192 Batches: 1 Memory Usage: 264kB
12. 0.696 0.696 ↑ 1.0 4,730 1

Seq Scan on pessoa p (cost=0.00..228.30 rows=4,730 width=8) (actual time=0.011..0.696 rows=4,730 loops=1)

13.          

SubPlan (forHash Join)

14. 0.000 0.000 ↓ 0.0 0

Result (cost=0.00..0.01 rows=1 width=4) (never executed)

15. 0.000 0.000 ↓ 0.0 0

Seq Scan on parcela_nfs pnfs_8 (cost=0.00..1.26 rows=1 width=0) (never executed)

  • Filter: (id_nota_fiscal_saida = nfs.id_nota_fiscal_saida)
16. 0.036 0.036 ↑ 1.0 21 1

Seq Scan on parcela_nfs pnfs_9 (cost=0.00..1.21 rows=21 width=4) (actual time=0.030..0.036 rows=21 loops=1)

17. 0.000 0.000 ↓ 0.0 0

Seq Scan on parcela_nfs pnfs_10 (cost=0.00..1.31 rows=1 width=0) (never executed)

  • Filter: ((id_nota_fiscal_saida = nfs.id_nota_fiscal_saida) AND (vencimento = nfs.emissao))
18. 0.033 0.033 ↑ 1.0 21 1

Seq Scan on parcela_nfs pnfs_11 (cost=0.00..1.21 rows=21 width=8) (actual time=0.026..0.033 rows=21 loops=1)

19. 1.684 5.052 ↑ 1.0 1 421

Aggregate (cost=8.51..8.52 rows=1 width=32) (actual time=0.012..0.012 rows=1 loops=421)

20. 3.368 3.368 ↑ 1.3 3 421

Index Scan using idx_1101_01 on item_nfs item_nfs_12 (cost=0.42..8.49 rows=4 width=3) (actual time=0.006..0.008 rows=3 loops=421)

  • Index Cond: (id_nota_fiscal_saida = nfs.id_nota_fiscal_saida)
21. 1.263 3.368 ↑ 1.0 1 421

Aggregate (cost=8.51..8.52 rows=1 width=32) (actual time=0.008..0.008 rows=1 loops=421)

22. 2.105 2.105 ↑ 1.3 3 421

Index Scan using idx_1101_01 on item_nfs item_nfs_13 (cost=0.42..8.49 rows=4 width=3) (actual time=0.004..0.005 rows=3 loops=421)

  • Index Cond: (id_nota_fiscal_saida = nfs.id_nota_fiscal_saida)
23. 1.263 3.368 ↑ 1.0 1 421

Aggregate (cost=8.51..8.52 rows=1 width=32) (actual time=0.008..0.008 rows=1 loops=421)

24. 2.105 2.105 ↑ 1.3 3 421

Index Scan using idx_1101_01 on item_nfs item_nfs_14 (cost=0.42..8.49 rows=4 width=3) (actual time=0.004..0.005 rows=3 loops=421)

  • Index Cond: (id_nota_fiscal_saida = nfs.id_nota_fiscal_saida)
25. 1.684 3.789 ↑ 1.0 1 421

Aggregate (cost=8.51..8.52 rows=1 width=32) (actual time=0.008..0.009 rows=1 loops=421)

26. 2.105 2.105 ↑ 1.3 3 421

Index Scan using idx_1101_01 on item_nfs item_nfs_15 (cost=0.42..8.49 rows=4 width=3) (actual time=0.004..0.005 rows=3 loops=421)

  • Index Cond: (id_nota_fiscal_saida = nfs.id_nota_fiscal_saida)
27. 1.684 3.789 ↑ 1.0 1 421

Aggregate (cost=8.51..8.52 rows=1 width=32) (actual time=0.009..0.009 rows=1 loops=421)

28. 2.105 2.105 ↑ 1.3 3 421

Index Scan using idx_1101_01 on item_nfs item_nfs_16 (cost=0.42..8.49 rows=4 width=3) (actual time=0.004..0.005 rows=3 loops=421)

  • Index Cond: (id_nota_fiscal_saida = nfs.id_nota_fiscal_saida)
29. 2.105 4.210 ↑ 1.0 1 421

Aggregate (cost=8.51..8.52 rows=1 width=32) (actual time=0.009..0.010 rows=1 loops=421)

30. 2.105 2.105 ↑ 1.3 3 421

Index Scan using idx_1101_01 on item_nfs item_nfs_17 (cost=0.42..8.49 rows=4 width=3) (actual time=0.004..0.005 rows=3 loops=421)

  • Index Cond: (id_nota_fiscal_saida = nfs.id_nota_fiscal_saida)
31. 0.066 108.214 ↑ 40.5 108 1

Subquery Scan on *SELECT* 2 (cost=3.99..8,624.26 rows=4,370 width=429) (actual time=0.351..108.214 rows=108 loops=1)

32. 1.870 108.148 ↑ 40.5 108 1

Hash Join (cost=3.99..8,580.56 rows=4,370 width=429) (actual time=0.348..108.148 rows=108 loops=1)

  • Hash Cond: (nfs_1.id_modelo_documento_fiscal = mdf_1.id_modelo_documento_fiscal)
33. 106.149 106.149 ↓ 1.2 8,560 1

Index Scan using idx_nota_fiscal_saida_emissao on nota_fiscal_saida nfs_1 (cost=0.42..8,426.35 rows=7,013 width=59) (actual time=0.039..106.149 rows=8,560 loops=1)

  • Index Cond: ((emissao >= '2018-01-01'::date) AND (emissao <= '2019-03-31'::date))
  • Filter: (situacao = ANY ('{2,3,4}'::integer[]))
  • Rows Removed by Filter: 99271
34. 0.032 0.129 ↑ 1.0 42 1

Hash (cost=3.04..3.04 rows=43 width=9) (actual time=0.129..0.129 rows=42 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 10kB
35. 0.097 0.097 ↑ 1.0 42 1

Seq Scan on modelo_documento_fiscal mdf_1 (cost=0.00..3.04 rows=43 width=9) (actual time=0.041..0.097 rows=42 loops=1)

  • Filter: (codigo_modelo_documento = ANY ('{01,1B,04,55}'::bpchar[]))
  • Rows Removed by Filter: 27
36.          

SubPlan (forHash Join)

37. 0.000 0.000 ↓ 0.0 0

Result (cost=0.00..0.01 rows=1 width=4) (never executed)

38. 0.984 301.946 ↑ 1.0 1,858 1

Subquery Scan on *SELECT* 3 (cost=1,534.03..111,787.33 rows=1,892 width=431) (actual time=53.948..301.946 rows=1,858 loops=1)

39. 24.927 300.962 ↑ 1.0 1,858 1

Hash Join (cost=1,534.03..111,768.41 rows=1,892 width=431) (actual time=53.946..300.962 rows=1,858 loops=1)

  • Hash Cond: (nfs_2.id_cliente = p_1.id_pessoa)
40. 1.317 186.316 ↑ 1.0 1,858 1

Hash Join (cost=1,246.61..9,844.47 rows=1,892 width=101) (actual time=49.185..186.316 rows=1,858 loops=1)

  • Hash Cond: (nfs_2.id_modelo_documento_fiscal = mdf_2.id_modelo_documento_fiscal)
41. 22.535 184.886 ↑ 1.6 1,858 1

Hash Join (cost=1,243.03..9,832.44 rows=3,036 width=96) (actual time=49.061..184.886 rows=1,858 loops=1)

  • Hash Cond: (nfs_2.id_nota_fiscal_saida = cupom_nfs_1.id_nota_fiscal_saida)
42. 113.445 113.445 ↑ 1.0 99,271 1

Index Scan using idx_nota_fiscal_saida_emissao on nota_fiscal_saida nfs_2 (cost=0.42..8,291.70 rows=100,707 width=96) (actual time=0.043..113.445 rows=99,271 loops=1)

  • Index Cond: ((emissao >= '2018-01-01'::date) AND (emissao <= '2019-03-31'::date))
  • Filter: (situacao = 1)
  • Rows Removed by Filter: 8560
43. 2.681 48.906 ↓ 1.3 7,129 1

Hash (cost=1,174.80..1,174.80 rows=5,425 width=4) (actual time=48.906..48.906 rows=7,129 loops=1)

  • Buckets: 8192 Batches: 1 Memory Usage: 315kB
44. 30.058 46.225 ↓ 1.3 7,129 1

HashAggregate (cost=1,120.55..1,174.80 rows=5,425 width=4) (actual time=43.635..46.225 rows=7,129 loops=1)

  • Group Key: cupom_nfs_1.id_nota_fiscal_saida
45. 16.167 16.167 ↑ 1.0 66,204 1

Seq Scan on cupom_nfs cupom_nfs_1 (cost=0.00..955.04 rows=66,204 width=4) (actual time=0.026..16.167 rows=66,204 loops=1)

46. 0.035 0.113 ↑ 1.0 42 1

Hash (cost=3.04..3.04 rows=43 width=9) (actual time=0.113..0.113 rows=42 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 10kB
47. 0.078 0.078 ↑ 1.0 42 1

Seq Scan on modelo_documento_fiscal mdf_2 (cost=0.00..3.04 rows=43 width=9) (actual time=0.023..0.078 rows=42 loops=1)

  • Filter: (codigo_modelo_documento = ANY ('{01,1B,04,55}'::bpchar[]))
  • Rows Removed by Filter: 27
48. 2.151 4.214 ↑ 1.0 4,730 1

Hash (cost=228.30..228.30 rows=4,730 width=8) (actual time=4.214..4.214 rows=4,730 loops=1)

  • Buckets: 8192 Batches: 1 Memory Usage: 264kB
49. 2.063 2.063 ↑ 1.0 4,730 1

Seq Scan on pessoa p_1 (cost=0.00..228.30 rows=4,730 width=8) (actual time=0.019..2.063 rows=4,730 loops=1)

50.          

SubPlan (forHash Join)

51. 0.000 0.000 ↓ 0.0 0

Result (cost=0.00..0.01 rows=1 width=4) (never executed)

52. 0.000 0.000 ↓ 0.0 0

Seq Scan on parcela_nfs pnfs_4 (cost=0.00..1.26 rows=1 width=0) (never executed)

  • Filter: (id_nota_fiscal_saida = nfs_2.id_nota_fiscal_saida)
53. 0.037 0.037 ↑ 1.0 21 1

Seq Scan on parcela_nfs pnfs_5 (cost=0.00..1.21 rows=21 width=4) (actual time=0.030..0.037 rows=21 loops=1)

54. 0.000 0.000 ↓ 0.0 0

Seq Scan on parcela_nfs pnfs_6 (cost=0.00..1.31 rows=1 width=0) (never executed)

  • Filter: ((id_nota_fiscal_saida = nfs_2.id_nota_fiscal_saida) AND (vencimento = nfs_2.emissao))
55. 0.000 0.000 ↓ 0.0 0

Seq Scan on parcela_nfs pnfs_7 (cost=0.00..1.21 rows=21 width=8) (never executed)

56. 5.574 16.722 ↑ 1.0 1 1,858

Aggregate (cost=8.51..8.52 rows=1 width=32) (actual time=0.009..0.009 rows=1 loops=1,858)

57. 11.148 11.148 ↑ 2.0 2 1,858

Index Scan using idx_1101_01 on item_nfs item_nfs_6 (cost=0.42..8.49 rows=4 width=3) (actual time=0.005..0.006 rows=2 loops=1,858)

  • Index Cond: (id_nota_fiscal_saida = nfs_2.id_nota_fiscal_saida)
58. 5.574 13.006 ↑ 1.0 1 1,858

Aggregate (cost=8.51..8.52 rows=1 width=32) (actual time=0.007..0.007 rows=1 loops=1,858)

59. 7.432 7.432 ↑ 2.0 2 1,858

Index Scan using idx_1101_01 on item_nfs item_nfs_7 (cost=0.42..8.49 rows=4 width=3) (actual time=0.004..0.004 rows=2 loops=1,858)

  • Index Cond: (id_nota_fiscal_saida = nfs_2.id_nota_fiscal_saida)
60. 5.574 13.006 ↑ 1.0 1 1,858

Aggregate (cost=8.51..8.52 rows=1 width=32) (actual time=0.007..0.007 rows=1 loops=1,858)

61. 7.432 7.432 ↑ 2.0 2 1,858

Index Scan using idx_1101_01 on item_nfs item_nfs_8 (cost=0.42..8.49 rows=4 width=3) (actual time=0.004..0.004 rows=2 loops=1,858)

  • Index Cond: (id_nota_fiscal_saida = nfs_2.id_nota_fiscal_saida)
62. 5.574 13.006 ↑ 1.0 1 1,858

Aggregate (cost=8.51..8.52 rows=1 width=32) (actual time=0.007..0.007 rows=1 loops=1,858)

63. 7.432 7.432 ↑ 2.0 2 1,858

Index Scan using idx_1101_01 on item_nfs item_nfs_9 (cost=0.42..8.49 rows=4 width=3) (actual time=0.004..0.004 rows=2 loops=1,858)

  • Index Cond: (id_nota_fiscal_saida = nfs_2.id_nota_fiscal_saida)
64. 7.432 14.864 ↑ 1.0 1 1,858

Aggregate (cost=8.51..8.52 rows=1 width=32) (actual time=0.008..0.008 rows=1 loops=1,858)

65. 7.432 7.432 ↑ 2.0 2 1,858

Index Scan using idx_1101_01 on item_nfs item_nfs_10 (cost=0.42..8.49 rows=4 width=3) (actual time=0.003..0.004 rows=2 loops=1,858)

  • Index Cond: (id_nota_fiscal_saida = nfs_2.id_nota_fiscal_saida)
66. 7.432 14.864 ↑ 1.0 1 1,858

Aggregate (cost=8.51..8.52 rows=1 width=32) (actual time=0.008..0.008 rows=1 loops=1,858)

67. 7.432 7.432 ↑ 2.0 2 1,858

Index Scan using idx_1101_01 on item_nfs item_nfs_11 (cost=0.42..8.49 rows=4 width=3) (actual time=0.004..0.004 rows=2 loops=1,858)

  • Index Cond: (id_nota_fiscal_saida = nfs_2.id_nota_fiscal_saida)
68. 46.450 5,352.156 ↓ 7.4 96,992 1

Subquery Scan on *SELECT* 4 (cost=290.82..711,443.05 rows=13,070 width=476) (actual time=4.358..5,352.156 rows=96,992 loops=1)

69. 1,219.148 5,305.706 ↓ 7.4 96,992 1

Hash Join (cost=290.82..711,312.35 rows=13,070 width=476) (actual time=4.356..5,305.706 rows=96,992 loops=1)

  • Hash Cond: (nfs_3.id_cliente = p_2.id_pessoa)
70. 69.610 300.113 ↓ 7.4 96,992 1

Hash Join (cost=3.39..9,112.46 rows=13,070 width=92) (actual time=0.147..300.113 rows=96,992 loops=1)

  • Hash Cond: (nfs_3.id_modelo_documento_fiscal = mdf_3.id_modelo_documento_fiscal)
71. 230.428 230.428 ↑ 1.0 99,271 1

Index Scan using idx_nota_fiscal_saida_emissao on nota_fiscal_saida nfs_3 (cost=0.42..8,830.30 rows=100,204 width=87) (actual time=0.050..230.428 rows=99,271 loops=1)

  • Index Cond: ((emissao >= '2018-01-01'::date) AND (emissao <= '2019-03-31'::date))
  • Filter: ((situacao = 1) AND (COALESCE(btrim((chave_acesso_nfe)::text), ''::text) <> ''::text))
  • Rows Removed by Filter: 8560
72. 0.010 0.075 ↑ 1.0 9 1

Hash (cost=2.86..2.86 rows=9 width=9) (actual time=0.075..0.075 rows=9 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
73. 0.065 0.065 ↑ 1.0 9 1

Seq Scan on modelo_documento_fiscal mdf_3 (cost=0.00..2.86 rows=9 width=9) (actual time=0.040..0.065 rows=9 loops=1)

  • Filter: (codigo_modelo_documento = '65'::bpchar)
  • Rows Removed by Filter: 60
74. 1.931 3.734 ↑ 1.0 4,730 1

Hash (cost=228.30..228.30 rows=4,730 width=4) (actual time=3.734..3.734 rows=4,730 loops=1)

  • Buckets: 8192 Batches: 1 Memory Usage: 231kB
75. 1.803 1.803 ↑ 1.0 4,730 1

Seq Scan on pessoa p_2 (cost=0.00..228.30 rows=4,730 width=4) (actual time=0.018..1.803 rows=4,730 loops=1)

76.          

SubPlan (forHash Join)

77. 0.000 0.000 ↓ 0.0 0

Result (cost=0.00..0.01 rows=1 width=4) (never executed)

78. 0.000 0.000 ↓ 0.0 0

Seq Scan on parcela_nfs pnfs (cost=0.00..1.26 rows=1 width=0) (never executed)

  • Filter: (id_nota_fiscal_saida = nfs_3.id_nota_fiscal_saida)
79. 0.023 0.023 ↑ 1.0 21 1

Seq Scan on parcela_nfs pnfs_1 (cost=0.00..1.21 rows=21 width=4) (actual time=0.017..0.023 rows=21 loops=1)

80. 0.000 0.000 ↓ 0.0 0

Seq Scan on parcela_nfs pnfs_2 (cost=0.00..1.31 rows=1 width=0) (never executed)

  • Filter: ((id_nota_fiscal_saida = nfs_3.id_nota_fiscal_saida) AND (vencimento = nfs_3.emissao))
81. 0.000 0.000 ↓ 0.0 0

Seq Scan on parcela_nfs pnfs_3 (cost=0.00..1.21 rows=21 width=8) (never executed)

82. 193.984 678.944 ↑ 1.0 1 96,992

Aggregate (cost=8.51..8.52 rows=1 width=32) (actual time=0.007..0.007 rows=1 loops=96,992)

83. 484.960 484.960 ↑ 2.0 2 96,992

Index Scan using idx_1101_01 on item_nfs (cost=0.42..8.49 rows=4 width=3) (actual time=0.004..0.005 rows=2 loops=96,992)

  • Index Cond: (id_nota_fiscal_saida = nfs_3.id_nota_fiscal_saida)
84. 193.984 581.952 ↑ 1.0 1 96,992

Aggregate (cost=8.51..8.52 rows=1 width=32) (actual time=0.006..0.006 rows=1 loops=96,992)

85. 387.968 387.968 ↑ 2.0 2 96,992

Index Scan using idx_1101_01 on item_nfs item_nfs_1 (cost=0.42..8.49 rows=4 width=3) (actual time=0.003..0.004 rows=2 loops=96,992)

  • Index Cond: (id_nota_fiscal_saida = nfs_3.id_nota_fiscal_saida)
86. 193.984 581.952 ↑ 1.0 1 96,992

Aggregate (cost=8.51..8.52 rows=1 width=32) (actual time=0.006..0.006 rows=1 loops=96,992)

87. 387.968 387.968 ↑ 2.0 2 96,992

Index Scan using idx_1101_01 on item_nfs item_nfs_2 (cost=0.42..8.49 rows=4 width=3) (actual time=0.003..0.004 rows=2 loops=96,992)

  • Index Cond: (id_nota_fiscal_saida = nfs_3.id_nota_fiscal_saida)
88. 193.984 581.952 ↑ 1.0 1 96,992

Aggregate (cost=8.51..8.52 rows=1 width=32) (actual time=0.006..0.006 rows=1 loops=96,992)

89. 387.968 387.968 ↑ 2.0 2 96,992

Index Scan using idx_1101_01 on item_nfs item_nfs_3 (cost=0.42..8.49 rows=4 width=3) (actual time=0.003..0.004 rows=2 loops=96,992)

  • Index Cond: (id_nota_fiscal_saida = nfs_3.id_nota_fiscal_saida)
90. 290.976 678.944 ↑ 1.0 1 96,992

Aggregate (cost=8.51..8.52 rows=1 width=32) (actual time=0.007..0.007 rows=1 loops=96,992)

91. 387.968 387.968 ↑ 2.0 2 96,992

Index Scan using idx_1101_01 on item_nfs item_nfs_4 (cost=0.42..8.49 rows=4 width=3) (actual time=0.003..0.004 rows=2 loops=96,992)

  • Index Cond: (id_nota_fiscal_saida = nfs_3.id_nota_fiscal_saida)
92. 290.976 678.944 ↑ 1.0 1 96,992

Aggregate (cost=8.51..8.52 rows=1 width=32) (actual time=0.007..0.007 rows=1 loops=96,992)

93. 387.968 387.968 ↑ 2.0 2 96,992

Index Scan using idx_1101_01 on item_nfs item_nfs_5 (cost=0.42..8.49 rows=4 width=3) (actual time=0.003..0.004 rows=2 loops=96,992)

  • Index Cond: (id_nota_fiscal_saida = nfs_3.id_nota_fiscal_saida)
94. 0.796 71.363 ↓ 2.2 2,002 1

Subquery Scan on *SELECT* 5 (cost=1,003.40..8,925.24 rows=910 width=429) (actual time=4.571..71.363 rows=2,002 loops=1)

95. 35.962 70.567 ↓ 2.2 2,002 1

Gather (cost=1,003.40..8,916.14 rows=910 width=429) (actual time=4.569..70.567 rows=2,002 loops=1)

  • Workers Planned: 2
  • Workers Launched: 2
96. 0.369 34.605 ↓ 1.8 667 3

Hash Join (cost=3.39..7,797.84 rows=379 width=64) (actual time=0.422..34.605 rows=667 loops=3)

  • Hash Cond: (nfs_4.id_modelo_documento_fiscal = mdf_4.id_modelo_documento_fiscal)
97. 34.132 34.132 ↑ 4.1 703 3

Parallel Index Scan using idx_nota_fiscal_saida_emissao on nota_fiscal_saida nfs_4 (cost=0.42..7,786.76 rows=2,908 width=59) (actual time=0.228..34.132 rows=703 loops=3)

  • Index Cond: ((emissao >= '2018-01-01'::date) AND (emissao <= '2019-03-31'::date))
  • Filter: ((situacao = ANY ('{2,3,4}'::integer[])) AND (COALESCE(btrim((chave_acesso_nfe)::text), ''::text) <> ''::text))
  • Rows Removed by Filter: 35240
98. 0.011 0.104 ↑ 1.0 9 3

Hash (cost=2.86..2.86 rows=9 width=9) (actual time=0.104..0.104 rows=9 loops=3)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
99. 0.093 0.093 ↑ 1.0 9 3

Seq Scan on modelo_documento_fiscal mdf_4 (cost=0.00..2.86 rows=9 width=9) (actual time=0.073..0.093 rows=9 loops=3)

  • Filter: (codigo_modelo_documento = '65'::bpchar)
  • Rows Removed by Filter: 60
100.          

SubPlan (forGather)

101. 0.000 0.000 ↓ 0.0 0

Result (cost=0.00..0.01 rows=1 width=4) (never executed)

102. 3.354 37,835.174 ↑ 2.3 7,354 1

Subquery Scan on *SELECT* 6 (cost=524,248.12..525,554.66 rows=17,250 width=429) (actual time=370.391..37,835.174 rows=7,354 loops=1)

103. 5.789 37,831.820 ↑ 2.3 7,354 1

Hash Join (cost=524,248.12..525,382.16 rows=17,250 width=429) (actual time=370.389..37,831.820 rows=7,354 loops=1)

  • Hash Cond: (sni.id_modelo_documento_fiscal = mdf_5.id_modelo_documento_fiscal)
104.          

CTE sub_numero

105. 10.138 120.001 ↓ 1.5 109,779 1

Append (cost=3.84..9,817.10 rows=71,556 width=8) (actual time=0.151..120.001 rows=109,779 loops=1)

106. 53.594 107.954 ↓ 1.5 107,831 1

Hash Join (cost=3.84..8,325.95 rows=70,252 width=8) (actual time=0.150..107.954 rows=107,831 loops=1)

  • Hash Cond: (nfs_5.id_modelo_documento_fiscal = mdf_6.id_modelo_documento_fiscal)
107. 54.269 54.269 ↓ 1.0 107,831 1

Index Scan using idx_nota_fiscal_saida_emissao on nota_fiscal_saida nfs_5 (cost=0.42..8,022.40 rows=107,720 width=8) (actual time=0.041..54.269 rows=107,831 loops=1)

  • Index Cond: ((emissao >= '2018-01-01'::date) AND (emissao <= '2019-03-31'::date))
108. 0.018 0.091 ↑ 1.0 45 1

Hash (cost=2.86..2.86 rows=45 width=4) (actual time=0.091..0.091 rows=45 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 10kB
109. 0.073 0.073 ↑ 1.0 45 1

Seq Scan on modelo_documento_fiscal mdf_6 (cost=0.00..2.86 rows=45 width=4) (actual time=0.042..0.073 rows=45 loops=1)

  • Filter: (codigo_modelo_documento = ANY ('{55,65}'::bpchar[]))
  • Rows Removed by Filter: 24
110. 0.662 1.771 ↓ 1.5 1,947 1

Hash Join (cost=48.07..739.39 rows=1,295 width=8) (actual time=0.345..1.771 rows=1,947 loops=1)

  • Hash Cond: (nfe.id_modelo_documento_fiscal = mdf_7.id_modelo_documento_fiscal)
111. 0.838 1.041 ↑ 1.0 1,981 1

Bitmap Heap Scan on nota_fiscal_entrada nfe (cost=44.64..730.43 rows=1,986 width=8) (actual time=0.259..1.041 rows=1,981 loops=1)

  • Recheck Cond: ((entrada >= '2018-01-01'::date) AND (entrada <= '2019-03-31'::date))
  • Heap Blocks: exact=289
112. 0.203 0.203 ↑ 1.0 1,984 1

Bitmap Index Scan on idx_0414_01 (cost=0.00..44.14 rows=1,986 width=0) (actual time=0.203..0.203 rows=1,984 loops=1)

  • Index Cond: ((entrada >= '2018-01-01'::date) AND (entrada <= '2019-03-31'::date))
113. 0.016 0.068 ↑ 1.0 45 1

Hash (cost=2.86..2.86 rows=45 width=4) (actual time=0.068..0.068 rows=45 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 10kB
114. 0.052 0.052 ↑ 1.0 45 1

Seq Scan on modelo_documento_fiscal mdf_7 (cost=0.00..2.86 rows=45 width=4) (actual time=0.030..0.052 rows=45 loops=1)

  • Filter: (codigo_modelo_documento = ANY ('{55,65}'::bpchar[]))
  • Rows Removed by Filter: 24
115. 0.007 0.100 ↑ 8.0 1 1

HashAggregate (cost=24.73..24.81 rows=8 width=8) (actual time=0.100..0.100 rows=1 loops=1)

  • Group Key: nfs_6.id_modelo_documento_fiscal
116. 0.021 0.093 ↑ 10.3 12 1

Hash Join (cost=3.84..24.11 rows=124 width=8) (actual time=0.083..0.093 rows=12 loops=1)

  • Hash Cond: (nfs_6.id_modelo_documento_fiscal = mdf_8.id_modelo_documento_fiscal)
117. 0.019 0.019 ↑ 15.8 12 1

Index Scan using idx_nota_fiscal_saida_emissao on nota_fiscal_saida nfs_6 (cost=0.42..20.15 rows=190 width=8) (actual time=0.014..0.019 rows=12 loops=1)

  • Index Cond: (emissao > '2019-03-31'::date)
118. 0.011 0.053 ↑ 1.0 45 1

Hash (cost=2.86..2.86 rows=45 width=4) (actual time=0.053..0.053 rows=45 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 10kB
119. 0.042 0.042 ↑ 1.0 45 1

Seq Scan on modelo_documento_fiscal mdf_8 (cost=0.00..2.86 rows=45 width=4) (actual time=0.019..0.042 rows=45 loops=1)

  • Filter: (codigo_modelo_documento = ANY ('{55,65}'::bpchar[]))
  • Rows Removed by Filter: 24
120. 0.001 0.038 ↓ 0.0 0 1

GroupAggregate (cost=11.37..11.39 rows=1 width=8) (actual time=0.038..0.038 rows=0 loops=1)

  • Group Key: nfe_1.id_modelo_documento_fiscal
121. 0.008 0.037 ↓ 0.0 0 1

Sort (cost=11.37..11.37 rows=1 width=8) (actual time=0.037..0.037 rows=0 loops=1)

  • Sort Key: nfe_1.id_modelo_documento_fiscal
  • Sort Method: quicksort Memory: 25kB
122. 0.004 0.029 ↓ 0.0 0 1

Hash Join (cost=8.31..11.36 rows=1 width=8) (actual time=0.029..0.029 rows=0 loops=1)

  • Hash Cond: (mdf_9.id_modelo_documento_fiscal = nfe_1.id_modelo_documento_fiscal)
123. 0.016 0.016 ↑ 45.0 1 1

Seq Scan on modelo_documento_fiscal mdf_9 (cost=0.00..2.86 rows=45 width=4) (actual time=0.016..0.016 rows=1 loops=1)

  • Filter: (codigo_modelo_documento = ANY ('{55,65}'::bpchar[]))
124. 0.001 0.009 ↓ 0.0 0 1

Hash (cost=8.30..8.30 rows=1 width=8) (actual time=0.009..0.009 rows=0 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 8kB
125. 0.008 0.008 ↓ 0.0 0 1

Index Scan using idx_0414_01 on nota_fiscal_entrada nfe_1 (cost=0.29..8.30 rows=1 width=8) (actual time=0.008..0.008 rows=0 loops=1)

  • Index Cond: (entrada > '2019-03-31'::date)
126.          

CTE sub_extremos

127. 58.696 253.331 ↑ 7.1 28 1

HashAggregate (cost=1,967.79..1,969.79 rows=200 width=12) (actual time=253.322..253.331 rows=28 loops=1)

  • Group Key: sub_numero.id_modelo_documento_fiscal
128. 194.635 194.635 ↓ 1.5 109,779 1

CTE Scan on sub_numero (cost=0.00..1,431.12 rows=71,556 width=8) (actual time=0.152..194.635 rows=109,779 loops=1)

129.          

CTE sub_correta

130. 5,921.577 6,175.016 ↓ 148.6 29,718,856 1

ProjectSet (cost=5.50..1,009.00 rows=200,000 width=16) (actual time=253.364..6,175.016 rows=29,718,856 loops=1)

131. 0.096 253.439 ↑ 7.1 28 1

HashAggregate (cost=5.50..7.50 rows=200 width=12) (actual time=253.360..253.439 rows=28 loops=1)

  • Group Key: se.id_modelo_documento_fiscal, se.menor_numero, se.maior_numero
132. 253.343 253.343 ↑ 7.1 28 1

CTE Scan on sub_extremos se (cost=0.00..4.00 rows=200 width=12) (actual time=253.324..253.343 rows=28 loops=1)

133.          

CTE sub_inutilizacao

134. 29.200 62.926 ↑ 657.8 25,518 1

ProjectSet (cost=912.42..85,136.18 rows=16,786,000 width=16) (actual time=22.880..62.926 rows=25,518 loops=1)

135. 21.846 33.726 ↓ 1.5 25,518 1

HashAggregate (cost=912.42..1,080.28 rows=16,786 width=12) (actual time=22.874..33.726 rows=25,518 loops=1)

  • Group Key: idfe.id_modelo_documento_fiscal, idfe.numero_inicial, idfe.numero_final
136. 8.352 11.880 ↓ 1.5 25,739 1

Hash Join (cost=3.42..786.53 rows=16,786 width=12) (actual time=0.170..11.880 rows=25,739 loops=1)

  • Hash Cond: (idfe.id_modelo_documento_fiscal = mdf_10.id_modelo_documento_fiscal)
137. 3.483 3.483 ↑ 1.0 25,739 1

Seq Scan on inutilizacao_dfe idfe (cost=0.00..711.39 rows=25,739 width=12) (actual time=0.016..3.483 rows=25,739 loops=1)

138. 0.011 0.045 ↑ 1.0 45 1

Hash (cost=2.86..2.86 rows=45 width=4) (actual time=0.045..0.045 rows=45 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 10kB
139. 0.034 0.034 ↑ 1.0 45 1

Seq Scan on modelo_documento_fiscal mdf_10 (cost=0.00..2.86 rows=45 width=4) (actual time=0.013..0.034 rows=45 loops=1)

  • Filter: (codigo_modelo_documento = ANY ('{55,65}'::bpchar[]))
  • Rows Removed by Filter: 24
140.          

CTE sub_numeracao_inutilizada

141. 9,150.660 37,822.288 ↑ 6.8 7,354 1

Hash Join (cost=420,650.00..426,312.50 rows=50,000 width=8) (actual time=370.223..37,822.288 rows=7,354 loops=1)

  • Hash Cond: ((sc.numero = si.numero) AND (sc.id_modelo_documento_fiscal = si.id_modelo_documento_fiscal))
142. 28,554.835 28,554.835 ↓ 148.6 29,718,856 1

CTE Scan on sub_correta sc (cost=0.00..4,000.00 rows=200,000 width=8) (actual time=253.366..28,554.835 rows=29,718,856 loops=1)

143. 9.366 116.793 ↑ 1.6 25,518 1

Hash (cost=420,050.00..420,050.00 rows=40,000 width=8) (actual time=116.793..116.793 rows=25,518 loops=1)

  • Buckets: 65536 Batches: 1 Memory Usage: 1509kB
144. 25.175 107.427 ↑ 1.6 25,518 1

HashAggregate (cost=419,650.00..420,050.00 rows=40,000 width=8) (actual time=98.387..107.427 rows=25,518 loops=1)

  • Group Key: si.numero, si.id_modelo_documento_fiscal
145. 82.252 82.252 ↑ 657.8 25,518 1

CTE Scan on sub_inutilizacao si (cost=0.00..335,720.00 rows=16,786,000 width=8) (actual time=22.886..82.252 rows=25,518 loops=1)

146. 37,825.894 37,825.894 ↑ 6.8 7,354 1

CTE Scan on sub_numeracao_inutilizada sni (cost=0.00..1,000.00 rows=50,000 width=8) (actual time=370.225..37,825.894 rows=7,354 loops=1)

147. 0.050 0.137 ↑ 1.0 69 1

Hash (cost=2.69..2.69 rows=69 width=9) (actual time=0.137..0.137 rows=69 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 11kB
148. 0.087 0.087 ↑ 1.0 69 1

Seq Scan on modelo_documento_fiscal mdf_5 (cost=0.00..2.69 rows=69 width=9) (actual time=0.052..0.087 rows=69 loops=1)

Planning time : 5.115 ms
Execution time : 44,431.582 ms