explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 70r6

Settings
# exclusive inclusive rows x rows loops node
1. 0.466 41,055.440 ↑ 3.6 76 1

Sort (cost=5,706,232.44..5,706,233.13 rows=275 width=296) (actual time=41,055.344..41,055.440 rows=76 loops=1)

  • Sort Key: ('Evolucao Protecao'::text), (((1))::bigint), ('Protecao'::text), ""*SELECT* 1"".agrupador, ((""*SELECT* 1"".participacaometa)::numeric)
  • Sort Method: quicksort Memory: 36kB
2.          

CTE saldofin_deptos_ignorar

3. 2.147 2.147 ↓ 21.0 503 1

Seq Scan on departamento d (cost=0.00..132.94 rows=24 width=4) (actual time=0.016..2.147 rows=503 loops=1)

  • Filter: (substr((classificacao)::text, 1, 3) = '110'::text)
  • Rows Removed by Filter: 4,293
4.          

CTE grupocomissao

5. 0.051 1.111 ↑ 1.0 9 1

Hash Left Join (cost=15.07..35.81 rows=9 width=91) (actual time=1.050..1.111 rows=9 loops=1)

  • Hash Cond: (scg.idservico = (s.idservico)::smallint)
6. 0.044 0.415 ↑ 1.0 9 1

Hash Left Join (cost=2.61..23.33 rows=9 width=59) (actual time=0.370..0.415 rows=9 loops=1)

  • Hash Cond: (scg.idgrupo = sgc.idgrupo)
7. 0.069 0.333 ↑ 1.0 9 1

Hash Left Join (cost=1.52..22.19 rows=9 width=42) (actual time=0.302..0.333 rows=9 loops=1)

  • Hash Cond: (scg.idgruposervico = gs.idgruposervico)
8. 0.193 0.193 ↑ 1.0 9 1

Seq Scan on ccg_servico_comissao_grupo scg (cost=0.00..20.65 rows=9 width=24) (actual time=0.180..0.193 rows=9 loops=1)

  • Filter: (anomes = 201,909)
  • Rows Removed by Filter: 1,083
9. 0.034 0.071 ↑ 1.0 23 1

Hash (cost=1.23..1.23 rows=23 width=22) (actual time=0.070..0.071 rows=23 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 10kB
10. 0.037 0.037 ↑ 1.0 23 1

Seq Scan on ccg_grupo_servico gs (cost=0.00..1.23 rows=23 width=22) (actual time=0.016..0.037 rows=23 loops=1)

11. 0.014 0.038 ↑ 1.0 4 1

Hash (cost=1.04..1.04 rows=4 width=21) (actual time=0.037..0.038 rows=4 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
12. 0.024 0.024 ↑ 1.0 4 1

Seq Scan on ccg_servico_grupo_comissao sgc (cost=0.00..1.04 rows=4 width=21) (actual time=0.019..0.024 rows=4 loops=1)

13. 0.308 0.645 ↑ 1.0 287 1

Hash (cost=8.87..8.87 rows=287 width=34) (actual time=0.645..0.645 rows=287 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 27kB
14. 0.337 0.337 ↑ 1.0 287 1

Seq Scan on servico s (cost=0.00..8.87 rows=287 width=34) (actual time=0.020..0.337 rows=287 loops=1)

15.          

CTE verbaextra

16. 0.005 0.005 ↑ 1.0 1 1

Result (cost=0.00..0.01 rows=1 width=32) (actual time=0.003..0.005 rows=1 loops=1)

17.          

CTE aproveitamento

18. 6.690 10.854 ↑ 1.0 3,701 1

Hash Left Join (cost=0.29..76.49 rows=3,701 width=26) (actual time=1.246..10.854 rows=3,701 loops=1)

  • Hash Cond: (s_1.ididentificador = gc.ididentificador)
19. 2.995 2.995 ↑ 1.0 3,701 1

Seq Scan on ccg_servico_aproveitamento s_1 (cost=0.00..62.01 rows=3,701 width=22) (actual time=0.015..2.995 rows=3,701 loops=1)

20. 0.026 1.169 ↑ 1.0 9 1

Hash (cost=0.18..0.18 rows=9 width=8) (actual time=1.168..1.169 rows=9 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
21. 1.143 1.143 ↑ 1.0 9 1

CTE Scan on grupocomissao gc (cost=0.00..0.18 rows=9 width=8) (actual time=1.061..1.143 rows=9 loops=1)

22.          

CTE vendedor

23. 0.005 0.005 ↑ 1.0 1 1

Result (cost=0.00..0.01 rows=1 width=32) (actual time=0.003..0.005 rows=1 loops=1)

24.          

CTE consorcio

25. 0.038 0.439 ↑ 1.6 5 1

GroupAggregate (cost=16.61..16.77 rows=8 width=39) (actual time=0.413..0.439 rows=5 loops=1)

  • Group Key: s_2.tiposervico
26. 0.041 0.401 ↑ 1.1 7 1

Sort (cost=16.61..16.63 rows=8 width=39) (actual time=0.393..0.401 rows=7 loops=1)

  • Sort Key: s_2.tiposervico
  • Sort Method: quicksort Memory: 25kB
27. 0.052 0.360 ↑ 1.1 7 1

HashAggregate (cost=16.33..16.41 rows=8 width=39) (actual time=0.331..0.360 rows=7 loops=1)

  • Group Key: s_2.tiposervico, (sum((s_2.valor)::numeric))
28. 0.017 0.308 ↑ 1.1 7 1

Append (cost=15.04..16.29 rows=8 width=39) (actual time=0.199..0.308 rows=7 loops=1)

29. 0.028 0.210 ↑ 1.5 2 1

GroupAggregate (cost=15.04..15.10 rows=3 width=35) (actual time=0.197..0.210 rows=2 loops=1)

  • Group Key: s_2.tiposervico
30. 0.030 0.182 ↓ 1.5 6 1

Sort (cost=15.04..15.05 rows=4 width=9) (actual time=0.174..0.182 rows=6 loops=1)

  • Sort Key: s_2.tiposervico
  • Sort Method: quicksort Memory: 25kB
31. 0.091 0.152 ↓ 1.5 6 1

Bitmap Heap Scan on gzvendasparanatec s_2 (cost=3.36..15.00 rows=4 width=9) (actual time=0.086..0.152 rows=6 loops=1)

  • Recheck Cond: ((idfilial = 10,002) AND (datamovimento >= ('20190901'::cstring)::date) AND (datamovimento <= (date((('20190901'::cstring)::date + '1 mon'::interval)) - 1)))
  • Heap Blocks: exact=9
32. 0.061 0.061 ↓ 2.5 10 1

Bitmap Index Scan on idx_gzvendasparanatec_filialmovimento (cost=0.00..3.36 rows=4 width=0) (actual time=0.060..0.061 rows=10 loops=1)

  • Index Cond: ((idfilial = 10,002) AND (datamovimento >= ('20190901'::cstring)::date) AND (datamovimento <= (date((('20190901'::cstring)::date + '1 mon'::interval)) - 1)))
33. 0.020 0.081 ↑ 1.0 5 1

Subquery Scan on "*SELECT* 2" (cost=0.00..1.11 rows=5 width=35) (actual time=0.058..0.081 rows=5 loops=1)

34. 0.061 0.061 ↑ 1.0 5 1

Seq Scan on gztipoconsorcio (cost=0.00..1.05 rows=5 width=7) (actual time=0.053..0.061 rows=5 loops=1)

35.          

CTE grupoconsorcio

36. 0.128 10.894 ↑ 1.0 5 1

Hash Right Join (cost=2.85..2,085.12 rows=5 width=330) (actual time=4.734..10.894 rows=5 loops=1)

  • Hash Cond: (gc_1.idgruposervico = tc.idgruposervico)
37. 0.026 0.026 ↑ 1.0 9 1

CTE Scan on grupocomissao gc_1 (cost=0.00..0.18 rows=9 width=194) (actual time=0.013..0.026 rows=9 loops=1)

38. 0.020 3.081 ↑ 1.0 5 1

Hash (cost=2.79..2.79 rows=5 width=100) (actual time=3.079..3.081 rows=5 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
39. 0.077 3.061 ↑ 1.0 5 1

HashAggregate (cost=1.36..2.74 rows=5 width=100) (actual time=0.577..3.061 rows=5 loops=1)

  • Group Key: tc.idgruposervico
40.          

Initplan (for HashAggregate)

41. 0.004 0.004 ↑ 1.0 1 1

CTE Scan on vendedor (cost=0.00..0.02 rows=1 width=32) (actual time=0.002..0.004 rows=1 loops=1)

42. 0.039 0.529 ↑ 1.6 5 1

Hash Left Join (cost=1.11..1.30 rows=8 width=36) (actual time=0.475..0.529 rows=5 loops=1)

  • Hash Cond: ((vs.tiposervico)::text = (tc.idtipoconsorcio)::text)
43. 0.458 0.458 ↑ 1.6 5 1

CTE Scan on consorcio vs (cost=0.00..0.16 rows=8 width=39) (actual time=0.418..0.458 rows=5 loops=1)

44. 0.014 0.032 ↑ 1.0 5 1

Hash (cost=1.05..1.05 rows=5 width=7) (actual time=0.031..0.032 rows=5 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
45. 0.018 0.018 ↑ 1.0 5 1

Seq Scan on gztipoconsorcio tc (cost=0.00..1.05 rows=5 width=7) (actual time=0.010..0.018 rows=5 loops=1)

46.          

SubPlan (for HashAggregate)

47. 2.451 2.451 ↑ 1.0 1 1

Result (cost=0.00..0.26 rows=1 width=32) (actual time=2.449..2.451 rows=1 loops=1)

48.          

SubPlan (for Hash Right Join)

49. 2.580 2.580 ↑ 19.0 1 5

CTE Scan on aproveitamento (cost=0.00..83.27 rows=19 width=32) (actual time=0.511..0.516 rows=1 loops=5)

  • Filter: (ididentificador = gc_1.ididentificador)
  • Rows Removed by Filter: 3,700
50. 2.535 2.535 ↑ 19.0 1 5

CTE Scan on aproveitamento aproveitamento_1 (cost=0.00..83.27 rows=19 width=32) (actual time=0.502..0.507 rows=1 loops=5)

  • Filter: (ididentificador = gc_1.ididentificador)
  • Rows Removed by Filter: 3,700
51. 0.512 0.512 ↑ 19.0 1 1

CTE Scan on aproveitamento aproveitamento_2 (cost=0.00..83.27 rows=19 width=32) (actual time=0.504..0.512 rows=1 loops=1)

  • Filter: (ididentificador = gc_1.ididentificador)
  • Rows Removed by Filter: 3,700
52. 2.032 2.032 ↑ 19.0 1 4

CTE Scan on aproveitamento aproveitamento_3 (cost=0.00..83.27 rows=19 width=32) (actual time=0.504..0.508 rows=1 loops=4)

  • Filter: (ididentificador = gc_1.ididentificador)
  • Rows Removed by Filter: 3,700
53. 0.000 0.000 ↓ 0.0 0

CTE Scan on aproveitamento aproveitamento_4 (cost=0.00..83.27 rows=19 width=32) (never executed)

  • Filter: (ididentificador = gc_1.ididentificador)
54.          

CTE vendedoresdaloja

55. 0.038 0.054 ↑ 1.0 1 1

Aggregate (cost=0.25..0.26 rows=1 width=196) (actual time=0.051..0.054 rows=1 loops=1)

56.          

Initplan (for Aggregate)

57. 0.004 0.004 ↑ 1.0 1 1

Result (cost=0.00..0.01 rows=1 width=32) (actual time=0.002..0.004 rows=1 loops=1)

58. 0.004 0.004 ↑ 1.0 1 1

CTE Scan on vendedor vendedor_1 (cost=0.00..0.02 rows=1 width=32) (actual time=0.002..0.004 rows=1 loops=1)

59. 0.008 0.008 ↑ 1.0 5 1

CTE Scan on grupoconsorcio (cost=0.00..0.10 rows=5 width=72) (actual time=0.001..0.008 rows=5 loops=1)

60.          

CTE consorciomaisbonus

61. 0.055 11.501 ↑ 1.0 10 1

HashAggregate (cost=6.24..6.34 rows=10 width=212) (actual time=11.487..11.501 rows=10 loops=1)

  • Group Key: ""*SELECT* 1_2"".grupo, ""*SELECT* 1_2"".variavel, ((""*SELECT* 1_2"".ordem)::bigint), ""*SELECT* 1_2"".idgruposervico, ""*SELECT* 1_2"".meta, ""*SELECT* 1_2"".qtd, ""*SELECT* 1_2"".vendas, ((""*SELECT* 1_2"".faixacomissao)::numeric), ""*SELECT* 1_2"".comissao, ""*SELECT* 1_2"".pontos
62. 0.024 11.446 ↑ 1.0 10 1

Append (cost=0.44..5.99 rows=10 width=212) (actual time=11.085..11.446 rows=10 loops=1)

63. 0.046 11.090 ↑ 1.0 7 1

HashAggregate (cost=0.44..0.53 rows=7 width=212) (actual time=11.081..11.090 rows=7 loops=1)

  • Group Key: ""*SELECT* 1_2"".grupo, ""*SELECT* 1_2"".variavel, ""*SELECT* 1_2"".ordem, ""*SELECT* 1_2"".idgruposervico, ""*SELECT* 1_2"".meta, ""*SELECT* 1_2"".qtd, ""*SELECT* 1_2"".vendas, ((""*SELECT* 1_2"".faixacomissao)::numeric), ""*SELECT* 1_2"".comissao, ""*SELECT* 1_2"".pontos
64. 0.018 11.044 ↑ 1.0 7 1

Append (cost=0.00..0.26 rows=7 width=208) (actual time=4.750..11.044 rows=7 loops=1)

65. 0.018 10.931 ↑ 1.0 5 1

Subquery Scan on "*SELECT* 1_2" (cost=0.00..0.15 rows=5 width=330) (actual time=4.746..10.931 rows=5 loops=1)

66. 10.913 10.913 ↑ 1.0 5 1

CTE Scan on grupoconsorcio grupoconsorcio_2 (cost=0.00..0.10 rows=5 width=330) (actual time=4.740..10.913 rows=5 loops=1)

67. 0.011 0.077 ↑ 1.0 1 1

Subquery Scan on "*SELECT* 2_1" (cost=0.00..0.04 rows=1 width=208) (actual time=0.070..0.077 rows=1 loops=1)

68. 0.066 0.066 ↑ 1.0 1 1

CTE Scan on vendedoresdaloja (cost=0.00..0.03 rows=1 width=152) (actual time=0.063..0.066 rows=1 loops=1)

69. 0.009 0.018 ↑ 1.0 1 1

Subquery Scan on "*SELECT* 3_2" (cost=0.00..0.04 rows=1 width=208) (actual time=0.013..0.018 rows=1 loops=1)

70. 0.009 0.009 ↑ 1.0 1 1

CTE Scan on vendedoresdaloja vendedoresdaloja_1 (cost=0.00..0.02 rows=1 width=152) (actual time=0.007..0.009 rows=1 loops=1)

71. 0.014 0.332 ↑ 1.0 3 1

Subquery Scan on "*SELECT* 4_3" (cost=5.24..5.42 rows=3 width=212) (actual time=0.304..0.332 rows=3 loops=1)

72. 0.129 0.318 ↑ 1.0 3 1

WindowAgg (cost=5.24..5.36 rows=3 width=132) (actual time=0.297..0.318 rows=3 loops=1)

73.          

Initplan (for WindowAgg)

74. 0.014 0.022 ↑ 1.0 1 1

Aggregate (cost=0.11..0.12 rows=1 width=4) (actual time=0.021..0.022 rows=1 loops=1)

75. 0.008 0.008 ↑ 1.0 5 1

CTE Scan on grupoconsorcio grupoconsorcio_1 (cost=0.00..0.10 rows=5 width=4) (actual time=0.002..0.008 rows=5 loops=1)

76. 0.021 0.167 ↑ 1.0 3 1

Sort (cost=5.11..5.12 rows=3 width=53) (actual time=0.163..0.167 rows=3 loops=1)

  • Sort Key: gcb.ibonusservico
  • Sort Method: quicksort Memory: 25kB
77. 0.020 0.146 ↑ 1.0 3 1

Nested Loop Left Join (cost=0.12..5.09 rows=3 width=53) (actual time=0.125..0.146 rows=3 loops=1)

  • Join Filter: (((sum(gc_2.vendas)) >= gcb.valorinicial) AND ((sum(gc_2.vendas)) <= gcb.valorfinal))
  • Rows Removed by Join Filter: 2
78. 0.090 0.090 ↑ 1.0 3 1

Seq Scan on ccg_gerente_servico_bonus gcb (cost=0.00..4.90 rows=3 width=21) (actual time=0.083..0.090 rows=3 loops=1)

  • Filter: (anomes = 201,909)
  • Rows Removed by Filter: 229
79. 0.011 0.036 ↑ 1.0 1 3

Materialize (cost=0.12..0.14 rows=1 width=32) (actual time=0.010..0.012 rows=1 loops=3)

80. 0.018 0.025 ↑ 1.0 1 1

Aggregate (cost=0.12..0.12 rows=1 width=32) (actual time=0.023..0.025 rows=1 loops=1)

81. 0.007 0.007 ↑ 1.0 5 1

CTE Scan on grupoconsorcio gc_2 (cost=0.00..0.10 rows=5 width=32) (actual time=0.001..0.007 rows=5 loops=1)

82.          

CTE realizado

83. 1.204 401.114 ↓ 22.7 318 1

Hash Join (cost=6,755.61..16,523.75 rows=14 width=337) (actual time=193.324..401.114 rows=318 loops=1)

  • Hash Cond: (((substr((d_1.classificacao)::text, 1, 3)) = (gcl.linhas)::text) AND (((to_char((ib.datamovimento)::timestamp with time zone, 'yyyymm'::text))::integer) = gcl.anomes))
84. 23.819 397.358 ↑ 2.2 318 1

GroupAggregate (cost=6,718.45..16,435.41 rows=704 width=333) (actual time=190.744..397.358 rows=318 loops=1)

  • Group Key: ((to_char((ib.datamovimento)::timestamp with time zone, 'yyyymm'::text))::integer), ((to_char((ib.datamovimento)::timestamp with time zone, 'dd'::text))::integer), (substr((d_1.classificacao)::text, 1, 3)), gf.uf, pg.idsituacaoproduto
85. 6.246 64.965 ↓ 2.0 1,422 1

Sort (cost=6,718.45..6,720.21 rows=704 width=108) (actual time=63.329..64.965 rows=1,422 loops=1)

  • Sort Key: ((to_char((ib.datamovimento)::timestamp with time zone, 'yyyymm'::text))::integer), ((to_char((ib.datamovimento)::timestamp with time zone, 'dd'::text))::integer), (substr((d_1.classificacao)::text, 1, 3)), gf.uf, pg.idsituacaoproduto
  • Sort Method: quicksort Memory: 248kB
86. 10.097 58.719 ↓ 2.0 1,422 1

Nested Loop Left Join (cost=5.00..6,685.15 rows=704 width=108) (actual time=0.343..58.719 rows=1,422 loops=1)

  • Join Filter: ((gf.idfilial)::integer = (ib.idfilial)::integer)
87. 3.803 45.778 ↓ 4.0 1,422 1

Nested Loop Left Join (cost=1.71..6,652.27 rows=352 width=76) (actual time=0.237..45.778 rows=1,422 loops=1)

88. 3.747 36.287 ↓ 4.0 1,422 1

Nested Loop Left Join (cost=1.43..6,546.22 rows=352 width=73) (actual time=0.215..36.287 rows=1,422 loops=1)

89. 5.952 22.586 ↓ 4.0 1,422 1

Nested Loop Left Join (cost=1.01..4,511.94 rows=352 width=79) (actual time=0.177..22.586 rows=1,422 loops=1)

90. 8.102 8.102 ↓ 4.0 1,422 1

Index Scan using idx_itembase_idfilial_datamovimento_idoperacaoproduto on itembase ib (cost=0.59..2,455.94 rows=352 width=75) (actual time=0.139..8.102 rows=1,422 loops=1)

  • Index Cond: (((idfilial)::integer = 10,002) AND ((datamovimento)::date >= ('20190901'::cstring)::date) AND ((datamovimento)::date <= (date((('20190901'::cstring)::date + '1 mon'::interval)) - 1)) AND ((idoperacaoproduto)::integer = ANY ('{102010,101040}'::integer[])))
  • Filter: ((idvendedor)::integer <> 6781)
91. 8.532 8.532 ↑ 1.0 1 1,422

Index Scan using pk_produto on produto p (cost=0.42..5.84 rows=1 width=8) (actual time=0.006..0.006 rows=1 loops=1,422)

  • Index Cond: ((idproduto)::integer = (ib.idproduto)::integer)
92. 9.954 9.954 ↑ 1.0 1 1,422

Index Scan using ix_fk_produtograde_produto on produtograde pg (cost=0.42..5.77 rows=1 width=10) (actual time=0.007..0.007 rows=1 loops=1,422)

  • Index Cond: ((idproduto)::integer = (ib.idproduto)::integer)
  • Filter: (((idgradex)::smallint = (ib.idgradex)::smallint) AND ((idgradey)::smallint = (ib.idgradey)::smallint))
  • Rows Removed by Filter: 0
93. 5.688 5.688 ↑ 1.0 1 1,422

Index Scan using pk_departamento on departamento d_1 (cost=0.28..0.30 rows=1 width=11) (actual time=0.004..0.004 rows=1 loops=1,422)

  • Index Cond: ((iddepartamento)::integer = (p.iddepartamento)::integer)
94. 2.776 2.844 ↑ 2.0 1 1,422

Materialize (cost=3.29..6.49 rows=2 width=7) (actual time=0.001..0.002 rows=1 loops=1,422)

95. 0.016 0.068 ↑ 2.0 1 1

Bitmap Heap Scan on gzgrupofilial gf (cost=3.29..6.48 rows=2 width=7) (actual time=0.066..0.068 rows=1 loops=1)

  • Recheck Cond: ((idfilial)::integer = 10,002)
  • Heap Blocks: exact=1
96. 0.052 0.052 ↑ 2.0 1 1

Bitmap Index Scan on idx_gzgrupofilial_filial (cost=0.00..3.29 rows=2 width=0) (actual time=0.051..0.052 rows=1 loops=1)

  • Index Cond: ((idfilial)::integer = 10,002)
97.          

SubPlan (for GroupAggregate)

98. 55.458 308.574 ↑ 1.0 1 1,422

Nested Loop Left Join (cost=1.00..13.58 rows=1 width=32) (actual time=0.214..0.217 rows=1 loops=1,422)

  • Join Filter: (((n.idfilial)::integer = na.idfilial) AND ((n.idregistronota)::integer = na.idregistronota))
99. 227.520 227.520 ↑ 1.0 1 1,422

Index Scan using pk_nota on nota n (cost=0.56..6.58 rows=1 width=13) (actual time=0.158..0.160 rows=1 loops=1,422)

  • Index Cond: (((idfilial)::integer = (ib.idfilial)::integer) AND ((idregistronota)::integer = (ib.idregistronota)::integer))
100. 25.596 25.596 ↑ 1.0 1 1,422

Index Scan using pk_notaauxiliar on notaauxiliar na (cost=0.44..6.46 rows=1 width=14) (actual time=0.018..0.018 rows=1 loops=1,422)

  • Index Cond: ((idfilial = (ib.idfilial)::integer) AND (idregistronota = (ib.idregistronota)::integer))
101. 1.247 2.552 ↓ 1.4 1,104 1

Hash (cost=25.32..25.32 rows=789 width=12) (actual time=2.551..2.552 rows=1,104 loops=1)

  • Buckets: 2,048 (originally 1024) Batches: 1 (originally 1) Memory Usage: 64kB
102. 1.305 1.305 ↓ 1.4 1,104 1

Seq Scan on ccg_gerente_grupo_comissao_linha gcl (cost=0.00..25.32 rows=789 width=12) (actual time=0.055..1.305 rows=1,104 loops=1)

  • Filter: (idgrupo = ANY ('{1,2,3,4,5,6}'::integer[]))
103.          

CTE metarecebimento

104. 13.434 13.434 ↑ 3.6 280 1

Function Scan on dblink bla (cost=0.00..10.00 rows=1,000 width=36) (actual time=13.185..13.434 rows=280 loops=1)

105.          

CTE venda

106. 0.000 0.000 ↓ 0.0 0

Aggregate (cost=2,462.19..2,462.20 rows=1 width=32) (never executed)

107. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_itembase_idfilial_datamovimento_idoperacaoproduto on itembase ib_1 (cost=1.08..2,454.52 rows=767 width=10) (never executed)

  • Index Cond: (((idfilial)::integer = 10,002) AND ((datamovimento)::date >= gazin.primeiro_dia_mes(('20190901'::cstring)::date)) AND ((datamovimento)::date <= gazin.ultimo_dia_mes(('20190901'::cstring)::date)) AND ((idoperacaoproduto)::integer = ANY ('{102010,101040}'::integer[])))
108.          

CTE excecao

109. 0.200 0.200 ↑ 1.0 1 1

Index Only Scan using gerente_excessao_metas_mensal_pkey on gerente_excessao_metas_mensal ge (cost=0.29..6.31 rows=1 width=12) (actual time=0.195..0.200 rows=1 loops=1)

  • Index Cond: ((anomes = 201,909) AND (idfilial = 10,002))
  • Heap Fetches: 1
110.          

CTE projecao

111. 0.003 0.003 ↓ 0.0 0 1

Result (cost=59.28..59.28 rows=0 width=224) (actual time=0.003..0.003 rows=0 loops=1)

  • One-Time Filter: false
112.          

Initplan (for Result)

113. 0.000 0.000 ↓ 0.0 0

CTE Scan on excecao (cost=0.00..0.03 rows=1 width=0) (never executed)

  • Filter: ((idfilial = 10,002) AND (anomes = 201,909) AND (idmeta = 12))
114. 0.000 0.000 ↓ 0.0 0

Bitmap Heap Scan on ccg_gerente_faixa_salario f (cost=46.96..54.26 rows=3 width=5) (never executed)

  • Recheck Cond: (($33 >= (dofaturamento)::numeric) AND ($34 <= (atefaturamento)::numeric) AND (anomes = 201,909))
115.          

Initplan (for Bitmap Heap Scan)

116. 0.000 0.000 ↓ 0.0 0

CTE Scan on venda (cost=0.00..0.02 rows=1 width=32) (never executed)

117. 0.000 0.000 ↓ 0.0 0

CTE Scan on venda venda_1 (cost=0.00..0.02 rows=1 width=32) (never executed)

118. 0.000 0.000 ↓ 0.0 0

Bitmap Index Scan on pk_ccg_gerente_faixa_salario (cost=0.00..46.92 rows=3 width=0) (never executed)

  • Index Cond: (($33 >= (dofaturamento)::numeric) AND ($34 <= (atefaturamento)::numeric) AND (anomes = 201,909))
119. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm (cost=0.00..5.00 rows=1 width=32) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 12) AND (idtipometa = 0))
120.          

CTE metavenda

121. 2.835 2.835 ↑ 1.0 1 1

Result (cost=0.00..0.26 rows=1 width=32) (actual time=2.833..2.835 rows=1 loops=1)

122.          

CTE metaparanatec

123. 0.009 0.009 ↑ 1.0 1 1

CTE Scan on metavenda (cost=0.00..0.03 rows=1 width=32) (actual time=0.007..0.009 rows=1 loops=1)

124.          

CTE faturamentoparanatec

125. 0.761 43.604 ↑ 80.0 1 1

GroupAggregate (cost=6,067.31..6,069.91 rows=80 width=68) (actual time=43.602..43.604 rows=1 loops=1)

  • Group Key: its.idfilial, mt.meta
126. 1.210 42.843 ↓ 5.5 437 1

Sort (cost=6,067.31..6,067.51 rows=80 width=46) (actual time=42.400..42.843 rows=437 loops=1)

  • Sort Key: mt.meta
  • Sort Method: quicksort Memory: 59kB
127. 1.803 41.633 ↓ 5.5 437 1

Nested Loop Left Join (cost=11.42..6,064.78 rows=80 width=46) (actual time=0.433..41.633 rows=437 loops=1)

128. 1.502 38.956 ↓ 5.5 437 1

Hash Join (cost=11.42..6,063.17 rows=80 width=14) (actual time=0.416..38.956 rows=437 loops=1)

  • Hash Cond: ((its.idservico)::smallint = (s_3.idservico)::smallint)
  • Join Filter: (((s_3.idgruposervico)::smallint <> 1) OR ((its.idprocessomestre)::smallint <> ALL ('{9657,9658,9659,9678,9679,9685,9695,9696,9689}'::integer[])))
129. 37.197 37.197 ↓ 1.9 826 1

Index Scan using idx_itemservico_datamovimentofilial on itemservico its (cost=0.46..6,051.02 rows=431 width=18) (actual time=0.135..37.197 rows=826 loops=1)

  • Index Cond: (((datamovimento)::date >= ('20190901'::cstring)::date) AND ((datamovimento)::date <= (date((('20190901'::cstring)::date + '1 mon'::interval)) - 1)) AND ((idfilial)::integer = 10,002))
  • Filter: ((idoperacaoservico)::integer = ANY ('{201020,201025,202010,202020}'::integer[]))
  • Rows Removed by Filter: 83
130. 0.069 0.257 ↑ 1.0 53 1

Hash (cost=10.30..10.30 rows=53 width=4) (actual time=0.256..0.257 rows=53 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 10kB
131. 0.188 0.188 ↑ 1.0 53 1

Seq Scan on servico s_3 (cost=0.00..10.30 rows=53 width=4) (actual time=0.031..0.188 rows=53 loops=1)

  • Filter: ((idgruposervico)::smallint = ANY ('{1,2,3,14}'::integer[]))
  • Rows Removed by Filter: 234
132. 0.874 0.874 ↑ 1.0 1 437

CTE Scan on metaparanatec mt (cost=0.00..0.02 rows=1 width=32) (actual time=0.001..0.002 rows=1 loops=437)

133.          

CTE metalinha

134. 0.054 0.348 ↑ 1.2 6 1

Hash Left Join (cost=12.17..31.99 rows=7 width=80) (actual time=0.267..0.348 rows=6 loops=1)

  • Hash Cond: (gcp.idgrupo = gc_3.idgrupo)
135. 0.100 0.245 ↑ 1.2 6 1

Bitmap Heap Scan on ccg_gerente_grupo_comissao_participacao gcp (cost=11.01..30.75 rows=7 width=9) (actual time=0.184..0.245 rows=6 loops=1)

  • Recheck Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909))
  • Filter: (idgrupo = ANY ('{1,2,3,4,5,6}'::integer[]))
  • Heap Blocks: exact=3
136. 0.145 0.145 ↑ 1.2 6 1

Bitmap Index Scan on pk_ccg_gerente_grupo_comissao_participacao (cost=0.00..11.01 rows=7 width=0) (actual time=0.144..0.145 rows=6 loops=1)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909))
137. 0.020 0.049 ↑ 1.0 7 1

Hash (cost=1.07..1.07 rows=7 width=16) (actual time=0.048..0.049 rows=7 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
138. 0.029 0.029 ↑ 1.0 7 1

Seq Scan on ccg_gerentes_grupo_comissao gc_3 (cost=0.00..1.07 rows=7 width=16) (actual time=0.021..0.029 rows=7 loops=1)

139.          

CTE metadia

140. 0.065 0.124 ↑ 1.0 4 1

Bitmap Heap Scan on ccg_gerentes_meta_dias md (cost=3.30..6.41 rows=4 width=83) (actual time=0.112..0.124 rows=4 loops=1)

  • Recheck Cond: (anomes = 201,909)
  • Heap Blocks: exact=1
141. 0.059 0.059 ↓ 1.2 5 1

Bitmap Index Scan on ccg_gerentes_meta_dias_pkey (cost=0.00..3.30 rows=4 width=0) (actual time=0.058..0.059 rows=5 loops=1)

  • Index Cond: (anomes = 201,909)
142.          

CTE vencido

143. 0.000 0.000 ↓ 0.0 0

Aggregate (cost=131,005.52..131,005.54 rows=1 width=96) (never executed)

144. 0.000 0.000 ↓ 0.0 0

Hash Join (cost=128,075.94..130,824.22 rows=18,129 width=33) (never executed)

  • Hash Cond: ((tp.idprocessotitulo)::smallint = c.idprocesso)
145. 0.000 0.000 ↓ 0.0 0

HashAggregate (cost=128,070.08..130,283.48 rows=42,160 width=47) (never executed)

  • Group Key: tp.idfilial, tp.idprocessotitulo, (((date((('20190901'::cstring)::date + '1 mon'::interval)) - 1) - (tp.datavencimento)::date) >= 0), trunc(((((date((('20190901'::cstring)::date + '1 mon'::interval)) - 1) - (tp.datavencimento)::date) / 30))::double precision)
146. 0.000 0.000 ↓ 0.0 0

Bitmap Heap Scan on tituloparcela tp (cost=4,599.39..127,437.68 rows=42,160 width=24) (never executed)

  • Recheck Cond: ((((date((('20190901'::cstring)::date + '1 mon'::interval)) - 1) < (databaixa)::date) AND ((idfilial)::integer = 10,002) AND ((idtipotitulo)::smallint = 1)) OR ((databaixa IS NULL) AND ((idfilial)::integer = 10,002) AND ((idtipotitulo)::smallint = 1)))
  • Filter: ((((date((('20190901'::cstring)::date + '1 mon'::interval)) - 1) < (databaixa)::date) OR (databaixa IS NULL)) AND ((date((('20190901'::cstring)::date + '1 mon'::interval)) - 1) >= (datainicial)::date))
147. 0.000 0.000 ↓ 0.0 0

BitmapOr (cost=4,599.39..4,599.39 rows=42,201 width=0) (never executed)

148. 0.000 0.000 ↓ 0.0 0

Bitmap Index Scan on ""idx_TituloParcela_DataBaixa2"" (cost=0.00..3,490.06 rows=307 width=0) (never executed)

  • Index Cond: (((date((('20190901'::cstring)::date + '1 mon'::interval)) - 1) < (databaixa)::date) AND ((idfilial)::integer = 10,002) AND ((idtipotitulo)::smallint = 1))
149. 0.000 0.000 ↓ 0.0 0

Bitmap Index Scan on ""idx_TituloParcela_DataBaixa2"" (cost=0.00..1,088.25 rows=41,894 width=0) (never executed)

  • Index Cond: ((databaixa IS NULL) AND ((idfilial)::integer = 10,002) AND ((idtipotitulo)::smallint = 1))
150. 0.000 0.000 ↓ 0.0 0

Hash (cost=4.79..4.79 rows=86 width=4) (never executed)

151. 0.000 0.000 ↓ 0.0 0

Index Only Scan using ccg_gerente_processos_fiado_pkey on ccg_gerente_processos_fiado c (cost=0.29..4.79 rows=86 width=4) (never executed)

  • Index Cond: (anomes = 201,909)
  • Heap Fetches: 0
152.          

CTE perdas

153. 0.000 0.000 ↓ 0.0 0

GroupAggregate (cost=35,136.44..35,137.57 rows=41 width=68) (never executed)

  • Group Key: tp_1.idfilial, (to_char((tp_1.databaixa)::timestamp with time zone, 'yyyymm'::text))
154. 0.000 0.000 ↓ 0.0 0

Sort (cost=35,136.44..35,136.54 rows=41 width=42) (never executed)

  • Sort Key: (to_char((tp_1.databaixa)::timestamp with time zone, 'yyyymm'::text))
155. 0.000 0.000 ↓ 0.0 0

Hash Join (cost=26.88..35,135.34 rows=41 width=42) (never executed)

  • Hash Cond: ((tp_1.idprocessobaixa)::smallint = (pro.idprocesso)::smallint)
156. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_tituloparcela_datainicial_databaixa on tituloparcela tp_1 (cost=0.59..35,082.87 rows=9,886 width=16) (never executed)

  • Index Cond: (((idtipotitulo)::smallint = 1) AND ((idfilial)::integer = 10,002) AND ((databaixa)::date >= ('20190901'::cstring)::date) AND ((databaixa)::date <= (date((('20190901'::cstring)::date + '1 mon'::interval)) - 1)))
157. 0.000 0.000 ↓ 0.0 0

Hash (cost=26.11..26.11 rows=14 width=2) (never executed)

158. 0.000 0.000 ↓ 0.0 0

Bitmap Heap Scan on processo pro (cost=3.39..26.11 rows=14 width=2) (never executed)

  • Recheck Cond: ((idoperacao)::integer = 302,040)
  • Filter: ((idprocesso)::smallint <> 3099)
159. 0.000 0.000 ↓ 0.0 0

Bitmap Index Scan on ix_fk_processo_operacao (cost=0.00..3.38 rows=14 width=0) (never executed)

  • Index Cond: ((idoperacao)::integer = 302,040)
160.          

CTE recperda

161. 0.047 434.993 ↑ 9.0 1 1

GroupAggregate (cost=39,817.34..39,817.59 rows=9 width=68) (actual time=434.990..434.993 rows=1 loops=1)

  • Group Key: p_1.idfilial, (to_char((p_1.databaixa)::timestamp with time zone, 'yyyymm'::text))
162. 0.106 434.946 ↓ 2.1 19 1

Sort (cost=39,817.34..39,817.37 rows=9 width=42) (actual time=434.926..434.946 rows=19 loops=1)

  • Sort Key: (to_char((p_1.databaixa)::timestamp with time zone, 'yyyymm'::text))
  • Sort Method: quicksort Memory: 26kB
163. 28.721 434.840 ↓ 2.1 19 1

Nested Loop (cost=72.69..39,817.20 rows=9 width=42) (actual time=102.139..434.840 rows=19 loops=1)

164. 31.737 300.147 ↓ 12.5 8,831 1

Hash Join (cost=72.13..35,180.39 rows=708 width=20) (actual time=102.056..300.147 rows=8,831 loops=1)

  • Hash Cond: ((p_1.idprocessobaixa)::smallint = (r.idprocesso)::smallint)
165. 266.722 266.722 ↓ 1.0 10,349 1

Index Scan using idx_tituloparcela_datainicial_databaixa on tituloparcela p_1 (cost=0.59..35,082.87 rows=9,886 width=22) (actual time=64.095..266.722 rows=10,349 loops=1)

  • Index Cond: (((idtipotitulo)::smallint = 1) AND ((idfilial)::integer = 10,002) AND ((databaixa)::date >= ('20190901'::cstring)::date) AND ((databaixa)::date <= (date((('20190901'::cstring)::date + '1 mon'::interval)) - 1)))
166. 0.456 1.688 ↑ 1.0 241 1

Hash (cost=68.52..68.52 rows=241 width=2) (actual time=1.686..1.688 rows=241 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 17kB
167. 1.091 1.232 ↑ 1.0 241 1

Bitmap Heap Scan on processo r (cost=25.40..68.52 rows=241 width=2) (actual time=0.197..1.232 rows=241 loops=1)

  • Recheck Cond: ((idoperacao)::integer = ANY ('{302010,302011,302012,302013,302014,302050,302062,302065,302020}'::integer[]))
  • Heap Blocks: exact=37
168. 0.141 0.141 ↑ 1.0 241 1

Bitmap Index Scan on ix_fk_processo_operacao (cost=0.00..25.34 rows=241 width=0) (actual time=0.141..0.141 rows=241 loops=1)

  • Index Cond: ((idoperacao)::integer = ANY ('{302010,302011,302012,302013,302014,302050,302062,302065,302020}'::integer[]))
169. 105.972 105.972 ↓ 0.0 0 8,831

Index Scan using pk_titulo on titulo t (cost=0.57..6.55 rows=1 width=10) (actual time=0.012..0.012 rows=0 loops=8,831)

  • Index Cond: (((idtipotitulo)::smallint = 1) AND ((idfilial)::integer = 10,002) AND ((idtitulo)::integer = (p_1.idtitulo)::integer))
  • Filter: ((idtipocarteira)::smallint = 7)
  • Rows Removed by Filter: 1
170.          

CTE produtos

171. 388.533 3,368.421 ↓ 1.6 61,169 1

HashAggregate (cost=66,447.83..67,858.09 rows=37,607 width=16) (actual time=3,103.599..3,368.421 rows=61,169 loops=1)

  • Group Key: pgsf.idfilial, pgsf.idproduto, pgsf.idgradex, pgsf.idgradey
172. 172.127 2,979.888 ↓ 1.6 61,169 1

Hash Join (cost=51,043.68..66,071.76 rows=37,607 width=12) (actual time=1,145.515..2,979.888 rows=61,169 loops=1)

  • Hash Cond: ((p_2.iddepartamento)::integer = (d_2.iddepartamento)::integer)
173. 503.976 2,793.980 ↓ 1.9 83,814 1

Hash Join (cost=50,859.73..65,771.69 rows=44,196 width=16) (actual time=1,131.674..2,793.980 rows=83,814 loops=1)

  • Hash Cond: (((pd.idproduto)::integer = (pgsf.idproduto)::integer) AND ((pd.idgradex)::smallint = (pgsf.idgradex)::smallint) AND ((pd.idgradey)::smallint = (pgsf.idgradey)::smallint))
174. 703.073 1,816.247 ↓ 2.0 253,141 1

Hash Join (cost=9,035.61..22,938.19 rows=128,167 width=16) (actual time=657.371..1,816.247 rows=253,141 loops=1)

  • Hash Cond: ((pd.idproduto)::integer = (p_2.idproduto)::integer)
175. 456.238 456.238 ↓ 1.0 256,352 1

Seq Scan on produtograde pd (cost=0.00..13,229.69 rows=256,334 width=8) (actual time=0.024..456.238 rows=256,352 loops=1)

  • Filter: ((idtipoproduto)::smallint = ANY ('{1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,98,99}'::integer[]))
176. 289.135 656.936 ↓ 2.0 179,419 1

Hash (cost=7,898.59..7,898.59 rows=90,962 width=8) (actual time=656.935..656.936 rows=179,419 loops=1)

  • Buckets: 262,144 (originally 131072) Batches: 1 (originally 1) Memory Usage: 9,057kB
177. 364.342 367.801 ↓ 2.0 179,419 1

Seq Scan on produto p_2 (cost=0.54..7,898.59 rows=90,962 width=8) (actual time=4.390..367.801 rows=179,419 loops=1)

  • Filter: (NOT (hashed SubPlan 39))
  • Rows Removed by Filter: 2,521
178.          

SubPlan (for Seq Scan)

179. 3.459 3.459 ↓ 21.0 503 1

CTE Scan on saldofin_deptos_ignorar (cost=0.00..0.48 rows=24 width=4) (actual time=0.019..3.459 rows=503 loops=1)

180. 143.901 473.757 ↑ 1.0 86,397 1

Hash (cost=40,277.26..40,277.26 rows=88,392 width=12) (actual time=473.756..473.757 rows=86,397 loops=1)

  • Buckets: 131,072 Batches: 1 Memory Usage: 4,737kB
181. 329.856 329.856 ↑ 1.0 86,397 1

Index Only Scan using pk_produtogradefilial on produtogradefilial pgsf (cost=0.56..40,277.26 rows=88,392 width=12) (actual time=0.212..329.856 rows=86,397 loops=1)

  • Index Cond: (idfilial = 10,002)
  • Heap Fetches: 13,390
182. 5.699 13.781 ↓ 1.0 4,082 1

Hash (cost=132.94..132.94 rows=4,081 width=4) (actual time=13.780..13.781 rows=4,082 loops=1)

  • Buckets: 4,096 Batches: 1 Memory Usage: 176kB
183. 8.082 8.082 ↓ 1.0 4,082 1

Seq Scan on departamento d_2 (cost=0.00..132.94 rows=4,081 width=4) (actual time=0.023..8.082 rows=4,082 loops=1)

  • Filter: (((classificacao)::text >= '1'::text) AND ((classificacao)::text <= '2109999999'::text))
  • Rows Removed by Filter: 714
184.          

CTE saldofin

185. 15.823 12,110.461 ↑ 1.0 1 1

Aggregate (cost=745,420.57..745,420.58 rows=1 width=32) (actual time=12,110.459..12,110.461 rows=1 loops=1)

186. 3,682.577 11,818.054 ↑ 41.7 898 1

CTE Scan on produtos tb_2 (cost=0.00..250,086.55 rows=37,419 width=16) (actual time=3,137.421..11,818.054 rows=898 loops=1)

  • Filter: (COALESCE((SubPlan 43), '0'::numeric) <> '0'::numeric)
  • Rows Removed by Filter: 60,271
187.          

SubPlan (for CTE Scan)

188. 305.845 8,135.477 ↑ 1.0 1 61,169

Aggregate (cost=6.62..6.63 rows=1 width=32) (actual time=0.132..0.133 rows=1 loops=61,169)

189. 183.507 7,829.632 ↓ 0.0 0 61,169

Result (cost=0.57..6.60 rows=1 width=30) (actual time=0.036..0.128 rows=0 loops=61,169)

190. 611.690 7,646.125 ↓ 0.0 0 61,169

Unique (cost=0.57..6.60 rows=1 width=30) (actual time=0.033..0.125 rows=0 loops=61,169)

191. 7,034.435 7,034.435 ↓ 4.0 4 61,169

Index Scan using idx_itembase_saldoanterior_desc on itembase ib_4 (cost=0.57..6.60 rows=1 width=30) (actual time=0.030..0.115 rows=4 loops=61,169)

  • Index Cond: (((idproduto)::integer = (tb_2.idproduto)::integer) AND ((idgradex)::smallint = (tb_2.idgradex)::smallint) AND ((idgradey)::smallint = (tb_2.idgradey)::smallint) AND ((idfilial)::integer = (tb_2.idfilial)::integer) AND ((datamovimento)::date <= tb_2.posicao))
  • Filter: ((idoperacaoproduto)::integer > 0)
  • Rows Removed by Filter: 1
192.          

SubPlan (for Aggregate)

193. 8.980 228.990 ↑ 1.0 1 898

Aggregate (cost=6.62..6.63 rows=1 width=32) (actual time=0.254..0.255 rows=1 loops=898)

194. 9.878 220.010 ↓ 2.0 2 898

Result (cost=0.57..6.60 rows=1 width=30) (actual time=0.027..0.245 rows=2 loops=898)

195. 70.942 210.132 ↓ 2.0 2 898

Unique (cost=0.57..6.60 rows=1 width=30) (actual time=0.022..0.234 rows=2 loops=898)

196. 139.190 139.190 ↓ 47.0 47 898

Index Scan using idx_itembase_saldoanterior_desc on itembase ib_2 (cost=0.57..6.60 rows=1 width=30) (actual time=0.017..0.155 rows=47 loops=898)

  • Index Cond: (((idproduto)::integer = (tb_2.idproduto)::integer) AND ((idgradex)::smallint = (tb_2.idgradex)::smallint) AND ((idgradey)::smallint = (tb_2.idgradey)::smallint) AND ((idfilial)::integer = (tb_2.idfilial)::integer) AND ((datamovimento)::date <= tb_2.posicao))
  • Filter: ((idoperacaoproduto)::integer > 0)
  • Rows Removed by Filter: 12
197. 6.286 47.594 ↑ 1.0 1 898

Limit (cost=0.57..6.61 rows=1 width=56) (actual time=0.049..0.053 rows=1 loops=898)

198. 41.308 41.308 ↑ 1.0 1 898

Index Scan using idx_itembase_saldoanteriorposicao_desc on itembase ib_3 (cost=0.57..6.61 rows=1 width=56) (actual time=0.045..0.046 rows=1 loops=898)

  • Index Cond: (((idfilial)::integer = (tb_2.idfilial)::integer) AND ((idproduto)::integer = (tb_2.idproduto)::integer) AND ((idgradex)::smallint = (tb_2.idgradex)::smallint) AND ((idgradey)::smallint = (tb_2.idgradey)::smallint) AND ((datamovimento)::date <= tb_2.posicao))
  • Filter: ((idoperacaoproduto)::integer > 0)
  • Rows Removed by Filter: 0
199.          

CTE linhas

200. 0.043 9.261 ↑ 1.2 6 1

Subquery Scan on tb_3 (cost=3.69..763.77 rows=7 width=328) (actual time=5.415..9.261 rows=6 loops=1)

201.          

Initplan (for Subquery Scan)

202. 0.013 0.033 ↑ 1.0 1 1

Aggregate (cost=1.10..1.11 rows=1 width=8) (actual time=0.031..0.033 rows=1 loops=1)

203. 0.020 0.020 ↑ 1.0 6 1

Seq Scan on ccg_gerentes_grupo_comissao (cost=0.00..1.09 rows=6 width=0) (actual time=0.014..0.020 rows=6 loops=1)

  • Filter: (idgrupo <> 99)
  • Rows Removed by Filter: 1
204. 0.091 9.185 ↑ 1.2 6 1

WindowAgg (cost=2.58..762.50 rows=7 width=452) (actual time=5.372..9.185 rows=6 loops=1)

205. 0.076 4.674 ↑ 1.2 6 1

WindowAgg (cost=2.58..3.22 rows=7 width=360) (actual time=4.645..4.674 rows=6 loops=1)

206. 0.036 4.598 ↑ 1.2 6 1

WindowAgg (cost=2.58..2.87 rows=7 width=232) (actual time=4.589..4.598 rows=6 loops=1)

207. 0.011 4.562 ↑ 1.2 6 1

Subquery Scan on tb_4 (cost=2.58..2.77 rows=7 width=200) (actual time=4.543..4.562 rows=6 loops=1)

208. 0.077 4.551 ↑ 1.2 6 1

HashAggregate (cost=2.58..2.70 rows=7 width=196) (actual time=4.540..4.551 rows=6 loops=1)

  • Group Key: m.idgrupo, m.peso
209.          

Initplan (for HashAggregate)

210. 2.848 2.848 ↑ 1.0 1 1

CTE Scan on metavenda metavenda_1 (cost=0.00..0.02 rows=1 width=32) (actual time=2.844..2.848 rows=1 loops=1)

211. 0.366 0.366 ↑ 1.2 6 1

CTE Scan on metalinha m (cost=0.00..0.14 rows=7 width=168) (actual time=0.273..0.366 rows=6 loops=1)

212.          

SubPlan (for HashAggregate)

213. 0.300 1.260 ↑ 1.0 1 6

Aggregate (cost=0.32..0.33 rows=1 width=32) (actual time=0.209..0.210 rows=1 loops=6)

214. 0.960 0.960 ↓ 53.0 53 6

CTE Scan on realizado (cost=0.00..0.32 rows=1 width=32) (actual time=0.005..0.160 rows=53 loops=6)

  • Filter: (idgrupo = m.grupo)
  • Rows Removed by Filter: 265
215.          

SubPlan (for WindowAgg)

216. 0.036 3.348 ↑ 3.0 1 6

Bitmap Heap Scan on ccg_gerente_faixa_salario f_1 (cost=46.92..54.22 rows=3 width=5) (actual time=0.557..0.558 rows=1 loops=6)

  • Recheck Cond: (((sum(tb_4.sf) OVER (?)) >= (dofaturamento)::numeric) AND ((sum(tb_4.sf) OVER (?)) <= (atefaturamento)::numeric) AND (anomes = 201,909))
  • Heap Blocks: exact=6
217. 3.312 3.312 ↑ 3.0 1 6

Bitmap Index Scan on pk_ccg_gerente_faixa_salario (cost=0.00..46.92 rows=3 width=0) (actual time=0.552..0.552 rows=1 loops=6)

  • Index Cond: (((sum(tb_4.sf) OVER (?)) >= (dofaturamento)::numeric) AND ((sum(tb_4.sf) OVER (?)) <= (atefaturamento)::numeric) AND (anomes = 201,909))
218. 0.014 1.072 ↑ 3.0 1 2

Bitmap Heap Scan on ccg_gerente_faixa_salario f_2 (cost=46.92..54.22 rows=3 width=5) (actual time=0.534..0.536 rows=1 loops=2)

  • Recheck Cond: (((sum(tb_4.sf) OVER (?)) >= (dofaturamento)::numeric) AND ((sum(tb_4.sf) OVER (?)) <= (atefaturamento)::numeric) AND (anomes = 201,909))
  • Heap Blocks: exact=2
219. 1.058 1.058 ↑ 3.0 1 2

Bitmap Index Scan on pk_ccg_gerente_faixa_salario (cost=0.00..46.92 rows=3 width=0) (actual time=0.529..0.529 rows=1 loops=2)

  • Index Cond: (((sum(tb_4.sf) OVER (?)) >= (dofaturamento)::numeric) AND ((sum(tb_4.sf) OVER (?)) <= (atefaturamento)::numeric) AND (anomes = 201,909))
220.          

CTE dias

221. 0.042 6.795 ↑ 2.0 6 1

HashAggregate (cost=516.33..516.45 rows=12 width=292) (actual time=6.787..6.795 rows=6 loops=1)

  • Group Key: ('Dias'::text), tb_5.variavel, (1), tb_5.participacaometa, tb_5.participacaorealizada, tb_5.valormeta, tb_5.valorrealizado, tb_5.percrealizado, tb_5.pontos, (CASE WHEN ((tb_5.pontos = '1'::numeric) OR (tb_5.perctotal >= '100'::numeric)) THEN ((((SubPlan 51))::numeric * (tb_5.peso)::numeric) / '100'::numeric) ELSE '0'::numeric END)
222. 0.015 6.753 ↑ 2.0 6 1

Append (cost=1.62..516.03 rows=12 width=292) (actual time=1.623..6.753 rows=6 loops=1)

223. 0.058 3.293 ↑ 1.0 4 1

Subquery Scan on tb_5 (cost=1.62..218.98 rows=4 width=292) (actual time=1.621..3.293 rows=4 loops=1)

224. 0.074 1.075 ↑ 1.0 4 1

WindowAgg (cost=1.62..2.03 rows=4 width=324) (actual time=1.046..1.075 rows=4 loops=1)

225. 0.031 1.001 ↑ 1.0 4 1

WindowAgg (cost=1.62..1.79 rows=4 width=196) (actual time=0.995..1.001 rows=4 loops=1)

226. 0.009 0.970 ↑ 1.0 4 1

Subquery Scan on tb_6 (cost=1.62..1.73 rows=4 width=164) (actual time=0.957..0.970 rows=4 loops=1)

227. 0.051 0.961 ↑ 1.0 4 1

HashAggregate (cost=1.62..1.69 rows=4 width=160) (actual time=0.954..0.961 rows=4 loops=1)

  • Group Key: metadia.idgrupo, metadia.peso
228.          

Initplan (for HashAggregate)

229. 0.003 0.003 ↑ 1.0 1 1

CTE Scan on metavenda metavenda_2 (cost=0.00..0.02 rows=1 width=32) (actual time=0.001..0.003 rows=1 loops=1)

230. 0.135 0.135 ↑ 1.0 4 1

CTE Scan on metadia (cost=0.00..0.08 rows=4 width=136) (actual time=0.116..0.135 rows=4 loops=1)

231.          

SubPlan (for HashAggregate)

232. 0.292 0.772 ↑ 1.0 1 4

Aggregate (cost=0.36..0.37 rows=1 width=32) (actual time=0.192..0.193 rows=1 loops=4)

233. 0.480 0.480 ↓ 80.0 80 4

CTE Scan on realizado realizado_1 (cost=0.00..0.35 rows=1 width=32) (actual time=0.022..0.120 rows=80 loops=4)

  • Filter: ((dia >= metadia.dodia) AND (dia <= metadia.atedia))
  • Rows Removed by Filter: 238
234.          

SubPlan (for Subquery Scan)

235. 0.024 2.160 ↑ 3.0 1 4

Bitmap Heap Scan on ccg_gerente_faixa_salario f_3 (cost=46.92..54.22 rows=3 width=5) (actual time=0.539..0.540 rows=1 loops=4)

  • Recheck Cond: ((tb_5.valortotal >= (dofaturamento)::numeric) AND (tb_5.valortotal <= (atefaturamento)::numeric) AND (anomes = 201,909))
  • Heap Blocks: exact=4
236. 2.136 2.136 ↑ 3.0 1 4

Bitmap Index Scan on pk_ccg_gerente_faixa_salario (cost=0.00..46.92 rows=3 width=0) (actual time=0.534..0.534 rows=1 loops=4)

  • Index Cond: ((tb_5.valortotal >= (dofaturamento)::numeric) AND (tb_5.valortotal <= (atefaturamento)::numeric) AND (anomes = 201,909))
237. 0.011 3.445 ↑ 4.0 2 1

Subquery Scan on "*SELECT* 2_2" (cost=1.94..296.96 rows=8 width=292) (actual time=3.362..3.445 rows=2 loops=1)

238. 0.028 3.434 ↑ 4.0 2 1

Nested Loop Left Join (cost=1.94..296.76 rows=8 width=124) (actual time=3.355..3.434 rows=2 loops=1)

239. 0.049 3.152 ↑ 4.0 1 1

GroupAggregate (cost=1.94..218.93 rows=4 width=64) (actual time=3.150..3.152 rows=1 loops=1)

  • Group Key: tb_7.perctotal
240. 0.024 0.915 ↑ 1.0 4 1

Sort (cost=1.94..1.95 rows=4 width=128) (actual time=0.911..0.915 rows=4 loops=1)

  • Sort Key: tb_7.perctotal
  • Sort Method: quicksort Memory: 25kB
241. 0.009 0.891 ↑ 1.0 4 1

Subquery Scan on tb_7 (cost=1.61..1.90 rows=4 width=128) (actual time=0.871..0.891 rows=4 loops=1)

242. 0.040 0.882 ↑ 1.0 4 1

WindowAgg (cost=1.61..1.86 rows=4 width=160) (actual time=0.868..0.882 rows=4 loops=1)

243. 0.045 0.842 ↑ 1.0 4 1

HashAggregate (cost=1.61..1.67 rows=4 width=160) (actual time=0.836..0.842 rows=4 loops=1)

  • Group Key: metadia_1.idgrupo, metadia_1.peso
244.          

Initplan (for HashAggregate)

245. 0.004 0.004 ↑ 1.0 1 1

CTE Scan on metavenda metavenda_3 (cost=0.00..0.02 rows=1 width=32) (actual time=0.001..0.004 rows=1 loops=1)

246. 0.005 0.005 ↑ 1.0 4 1

CTE Scan on metadia metadia_1 (cost=0.00..0.08 rows=4 width=104) (actual time=0.001..0.005 rows=4 loops=1)

247.          

SubPlan (for HashAggregate)

248. 0.316 0.788 ↑ 1.0 1 4

Aggregate (cost=0.36..0.37 rows=1 width=32) (actual time=0.196..0.197 rows=1 loops=4)

249. 0.472 0.472 ↓ 80.0 80 4

CTE Scan on realizado realizado_2 (cost=0.00..0.35 rows=1 width=32) (actual time=0.020..0.118 rows=80 loops=4)

  • Filter: ((dia >= metadia_1.dodia) AND (dia <= metadia_1.atedia))
  • Rows Removed by Filter: 238
250.          

SubPlan (for GroupAggregate)

251. 0.028 2.188 ↑ 3.0 1 4

Bitmap Heap Scan on ccg_gerente_faixa_salario f_4 (cost=46.92..54.22 rows=3 width=5) (actual time=0.546..0.547 rows=1 loops=4)

  • Recheck Cond: ((tb_7.valortotal >= (dofaturamento)::numeric) AND (tb_7.valortotal <= (atefaturamento)::numeric) AND (anomes = 201,909))
  • Heap Blocks: exact=4
252. 2.160 2.160 ↑ 3.0 1 4

Bitmap Index Scan on pk_ccg_gerente_faixa_salario (cost=0.00..46.92 rows=3 width=0) (actual time=0.540..0.540 rows=1 loops=4)

  • Index Cond: ((tb_7.valortotal >= (dofaturamento)::numeric) AND (tb_7.valortotal <= (atefaturamento)::numeric) AND (anomes = 201,909))
253. 0.022 0.098 ↑ 1.0 2 1

Materialize (cost=0.00..4.33 rows=2 width=9) (actual time=0.083..0.098 rows=2 loops=1)

254. 0.076 0.076 ↑ 1.0 2 1

Seq Scan on ccg_gerente_bonus bo (cost=0.00..4.33 rows=2 width=9) (actual time=0.073..0.076 rows=2 loops=1)

  • Filter: (anomes = 201,909)
  • Rows Removed by Filter: 184
255.          

SubPlan (for Nested Loop Left Join)

256. 0.011 0.156 ↓ 0.0 0 2

Nested Loop (cost=4.79..9.16 rows=1 width=32) (actual time=0.076..0.078 rows=0 loops=2)

257. 0.014 0.120 ↓ 0.0 0 2

Aggregate (cost=4.79..4.81 rows=1 width=4) (actual time=0.059..0.060 rows=0 loops=2)

  • Filter: (max(b.idbonus) = bo.idbonus)
  • Rows Removed by Filter: 0
258. 0.106 0.106 ↑ 1.0 1 2

Seq Scan on ccg_gerente_bonus b (cost=0.00..4.79 rows=1 width=4) (actual time=0.051..0.053 rows=1 loops=2)

  • Filter: ((tb_7.perctotal >= (percmeta)::numeric) AND (anomes = 201,909))
  • Rows Removed by Filter: 185
259. 0.025 0.025 ↑ 1.0 1 1

Seq Scan on ccg_gerente_bonus gb (cost=0.00..4.33 rows=1 width=9) (actual time=0.023..0.025 rows=1 loops=1)

  • Filter: (idbonus = bo.idbonus)
  • Rows Removed by Filter: 185
260.          

CTE perdasreal

261. 0.000 0.000 ↓ 0.0 0

Subquery Scan on tb_8 (cost=1.42..1.45 rows=1 width=32) (never executed)

262. 0.000 0.000 ↓ 0.0 0

Aggregate (cost=1.42..1.43 rows=1 width=96) (never executed)

263. 0.000 0.000 ↓ 0.0 0

HashAggregate (cost=1.33..1.36 rows=3 width=96) (never executed)

  • Group Key: ""*SELECT* 1_3"".perdido, ((0)::numeric), (((0))::numeric)
264. 0.000 0.000 ↓ 0.0 0

Append (cost=1.20..1.30 rows=3 width=96) (never executed)

265. 0.000 0.000 ↓ 0.0 0

Result (cost=1.20..1.24 rows=2 width=96) (never executed)

266. 0.000 0.000 ↓ 0.0 0

Unique (cost=1.20..1.21 rows=2 width=68) (never executed)

267. 0.000 0.000 ↓ 0.0 0

Sort (cost=1.20..1.20 rows=2 width=68) (never executed)

  • Sort Key: ""*SELECT* 1_3"".perdido, ((0)::numeric), (0)
268. 0.000 0.000 ↓ 0.0 0

Append (cost=0.93..1.19 rows=2 width=68) (never executed)

269. 0.000 0.000 ↓ 0.0 0

Subquery Scan on "*SELECT* 1_3" (cost=0.93..0.95 rows=1 width=68) (never executed)

270. 0.000 0.000 ↓ 0.0 0

Aggregate (cost=0.93..0.94 rows=1 width=40) (never executed)

271. 0.000 0.000 ↓ 0.0 0

CTE Scan on perdas (cost=0.00..0.82 rows=41 width=32) (never executed)

272. 0.000 0.000 ↓ 0.0 0

Subquery Scan on "*SELECT* 2_3" (cost=0.20..0.23 rows=1 width=68) (never executed)

273. 0.000 0.000 ↓ 0.0 0

Aggregate (cost=0.20..0.21 rows=1 width=40) (never executed)

274. 0.000 0.000 ↓ 0.0 0

CTE Scan on recperda (cost=0.00..0.18 rows=9 width=32) (never executed)

275. 0.000 0.000 ↓ 0.0 0

Subquery Scan on "*SELECT* 3_3" (cost=0.02..0.05 rows=1 width=96) (never executed)

276. 0.000 0.000 ↓ 0.0 0

Aggregate (cost=0.02..0.03 rows=1 width=40) (never executed)

277. 0.000 0.000 ↓ 0.0 0

CTE Scan on vencido (cost=0.00..0.02 rows=1 width=32) (never executed)

278.          

CTE meta_superestoque

279. 0.000 0.000 ↓ 0.0 0

Function Scan on dblink dados (cost=0.01..10.01 rows=1,000 width=32) (never executed)

280.          

CTE se_depositos

281. 0.000 0.000 ↓ 0.0 0

Index Scan using ix_fk_filialrelacionada_tipofilialrelacionada on filialrelacionada fr (cost=0.29..6.31 rows=1 width=4) (never executed)

  • Index Cond: ((idtipofilialrelacionada)::integer = 99)
  • Filter: ((idfilial)::integer = 10,002)
282.          

CTE realizado_superestoque

283. 0.000 0.000 ↓ 0.0 0

Aggregate (cost=462,999.38..462,999.39 rows=1 width=32) (never executed)

284. 0.000 0.000 ↓ 0.0 0

Sort (cost=462,999.32..462,999.33 rows=4 width=140) (never executed)

  • Sort Key: ib_5.idfilial, (((((to_char((f_5.idempresa)::double precision, '00'::text) || '.'::text) || to_char((f_5.numerofilial)::integer, '000'::text)) || ' - '::text) || (f_5.fantasia)::text))
285. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=26,326.68..462,999.28 rows=4 width=140) (never executed)

286. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=26,326.41..462,998.02 rows=4 width=14) (never executed)

287. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=26,326.12..462,748.46 rows=801 width=18) (never executed)

288. 0.000 0.000 ↓ 0.0 0

HashAggregate (cost=0.02..0.03 rows=1 width=4) (never executed)

  • Group Key: (se_depositos.idfilial)::integer
289. 0.000 0.000 ↓ 0.0 0

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

290. 0.000 0.000 ↓ 0.0 0

Bitmap Heap Scan on itembase ib_5 (cost=26,326.10..462,740.42 rows=801 width=22) (never executed)

  • Recheck Cond: (((idfilial)::integer = (se_depositos.idfilial)::integer) AND ((idoperacaoproduto)::integer = ANY ('{102010,101040}'::integer[])))
  • Filter: (to_char((datamovimento)::timestamp with time zone, 'YYYYMM'::text) = '201909'::text)
291. 0.000 0.000 ↓ 0.0 0

Bitmap Index Scan on idx_itembase_idfilial_datamovimento_idoperacaoproduto (cost=0.00..26,325.90 rows=160,248 width=0) (never executed)

  • Index Cond: (((idfilial)::integer = (se_depositos.idfilial)::integer) AND ((idoperacaoproduto)::integer = ANY ('{102010,101040}'::integer[])))
292. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_vendedor on vendedor vendedor_2 (cost=0.29..0.31 rows=1 width=4) (never executed)

  • Index Cond: ((idvendedor)::integer = (ib_5.idvendedor)::integer)
  • Filter: ((idfilialorigem)::integer = 10,002)
293. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_filial on filial f_5 (cost=0.27..0.29 rows=1 width=28) (never executed)

  • Index Cond: ((idfilial)::integer = (ib_5.idfilial)::integer)
294.          

CTE carteira

295. 0.019 2,275.198 ↑ 4.0 2 1

HashAggregate (cost=397,217.32..397,217.40 rows=8 width=292) (actual time=2,275.195..2,275.198 rows=2 loops=1)

  • Group Key: ('Carteira'::text), ('Fiado'::text), (1), (((0))::numeric), (round(sf, 2)), (COALESCE((valormeta)::numeric, '0'::numeric)), (round(percvencido, 2)), (round(CASE WHEN ((valormeta)::numeric > '0'::numeric) THEN (('1'::numeric - ((percvencido - (valormeta)::numeric) / (valormeta)::numeric)) * '100'::numeric) ELSE '0'::numeric END, 2)), (round((CASE WHEN (percvencido <= (valormeta)::numeric) THEN 1 ELSE 0 END)::numeric, 2)), (CASE WHEN (excecao = 1) THEN (((fixo)::numeric * (peso)::numeric) / '100'::numeric) ELSE CASE WHEN (percvencido <= (valormeta)::numeric) THEN CASE WHEN ((peso)::numeric > '0'::numeric) THEN (((fixo)::numeric * (peso)::numeric) / '100'::numeric) ELSE '0'::numeric END ELSE '0'::numeric END END)
296. 0.006 2,275.179 ↑ 4.0 2 1

Append (cost=397,003.14..397,217.12 rows=8 width=292) (actual time=2,275.166..2,275.179 rows=2 loops=1)

297. 0.031 2,275.166 ↑ 3.0 2 1

HashAggregate (cost=397,003.14..397,003.22 rows=6 width=292) (actual time=2,275.163..2,275.166 rows=2 loops=1)

  • Group Key: ('Carteira'::text), ('Fiado'::text), (1), (0), (round(sf, 2)), (COALESCE((valormeta)::numeric, '0'::numeric)), (round(percvencido, 2)), (round(CASE WHEN ((valormeta)::numeric > '0'::numeric) THEN (('1'::numeric - ((percvencido - (valormeta)::numeric) / (valormeta)::numeric)) * '100'::numeric) ELSE '0'::numeric END, 2)), (round((CASE WHEN (percvencido <= (valormeta)::numeric) THEN 1 ELSE 0 END)::numeric, 2)), (CASE WHEN (excecao = 1) THEN (((fixo)::numeric * (peso)::numeric) / '100'::numeric) ELSE CASE WHEN (percvencido <= (valormeta)::numeric) THEN CASE WHEN ((peso)::numeric > '0'::numeric) THEN (((fixo)::numeric * (peso)::numeric) / '100'::numeric) ELSE '0'::numeric END ELSE '0'::numeric END END)
298. 0.012 2,275.135 ↑ 3.0 2 1

Append (cost=0.00..397,002.99 rows=6 width=264) (actual time=1,837.836..2,275.135 rows=2 loops=1)

299. 0.003 0.003 ↓ 0.0 0 1

Result (cost=0.00..0.00 rows=0 width=264) (actual time=0.002..0.003 rows=0 loops=1)

  • One-Time Filter: false
300. 0.103 1,837.836 ↑ 2.0 1 1

Subquery Scan on tb_9 (cost=396,864.73..396,864.84 rows=2 width=264) (actual time=1,837.829..1,837.836 rows=1 loops=1)

301.          

Initplan (for Subquery Scan)

302. 0.121 0.121 ↑ 5.0 1 1

CTE Scan on metarecebimento m_1 (cost=0.00..22.50 rows=5 width=32) (actual time=0.057..0.121 rows=1 loops=1)

  • Filter: (idfilial = 10,002)
  • Rows Removed by Filter: 279
303. 0.068 0.068 ↑ 5.0 1 1

CTE Scan on metarecebimento m_2 (cost=0.00..22.50 rows=5 width=32) (actual time=0.057..0.068 rows=1 loops=1)

  • Filter: (idfilial = 10,002)
  • Rows Removed by Filter: 279
304. 0.069 0.069 ↑ 5.0 1 1

CTE Scan on metarecebimento m_3 (cost=0.00..22.50 rows=5 width=32) (actual time=0.060..0.069 rows=1 loops=1)

  • Filter: (idfilial = 10,002)
  • Rows Removed by Filter: 279
305. 0.070 0.070 ↑ 5.0 1 1

CTE Scan on metarecebimento m_4 (cost=0.00..22.50 rows=5 width=32) (actual time=0.063..0.070 rows=1 loops=1)

  • Filter: (idfilial = 10,002)
  • Rows Removed by Filter: 279
306. 0.085 0.085 ↑ 5.0 1 1

CTE Scan on metarecebimento m_5 (cost=0.00..22.50 rows=5 width=32) (actual time=0.059..0.085 rows=1 loops=1)

  • Filter: (idfilial = 10,002)
  • Rows Removed by Filter: 279
307. 0.006 0.219 ↓ 0.0 0 1

Limit (cost=0.00..0.03 rows=1 width=4) (actual time=0.218..0.219 rows=0 loops=1)

308. 0.213 0.213 ↓ 0.0 0 1

CTE Scan on excecao excecao_1 (cost=0.00..0.03 rows=1 width=4) (actual time=0.212..0.213 rows=0 loops=1)

  • Filter: ((idfilial = 10,002) AND (anomes = 201,909) AND (idmeta = 0))
  • Rows Removed by Filter: 1
309. 0.000 0.000 ↓ 0.0 0

Bitmap Heap Scan on ccg_gerente_faixa_salario f_6 (cost=47.58..54.87 rows=3 width=5) (never executed)

  • Recheck Cond: (($97 >= (dofaturamento)::numeric) AND ($98 <= (atefaturamento)::numeric) AND (anomes = 201,909))
310.          

Initplan (for Bitmap Heap Scan)

311. 0.000 0.000 ↓ 0.0 0

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

312. 0.000 0.000 ↓ 0.0 0

CTE Scan on realizado realizado_3 (cost=0.00..0.28 rows=14 width=32) (never executed)

313. 0.000 0.000 ↓ 0.0 0

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

314. 0.000 0.000 ↓ 0.0 0

CTE Scan on realizado realizado_4 (cost=0.00..0.28 rows=14 width=32) (never executed)

315. 0.000 0.000 ↓ 0.0 0

Bitmap Index Scan on pk_ccg_gerente_faixa_salario (cost=0.00..46.92 rows=3 width=0) (never executed)

  • Index Cond: (($97 >= (dofaturamento)::numeric) AND ($98 <= (atefaturamento)::numeric) AND (anomes = 201,909))
316. 0.000 0.000 ↓ 0.0 0

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi (cost=0.42..6.45 rows=1 width=4) (never executed)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 0))
  • Filter: (idtipometa = 0)
317. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_1 (cost=0.00..4.99 rows=1 width=3) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 0) AND (idtipometa = 0))
318. 0.063 0.063 ↑ 5.0 1 1

CTE Scan on metarecebimento m_6 (cost=0.00..22.50 rows=5 width=32) (actual time=0.057..0.063 rows=1 loops=1)

  • Filter: (idfilial = 10,002)
  • Rows Removed by Filter: 279
319. 0.100 0.100 ↑ 1.0 1 1

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_1 (cost=0.42..6.45 rows=1 width=4) (actual time=0.097..0.100 rows=1 loops=1)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 0))
  • Filter: (idtipometa = 0)
320. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_2 (cost=0.00..4.99 rows=1 width=3) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 0) AND (idtipometa = 0))
321. 0.000 2.662 ↑ 3.0 1 1

Bitmap Heap Scan on ccg_gerente_faixa_salario f_7 (cost=47.58..54.87 rows=3 width=5) (actual time=2.659..2.662 rows=1 loops=1)

  • Recheck Cond: (($105 >= (dofaturamento)::numeric) AND ($106 <= (atefaturamento)::numeric) AND (anomes = 201,909))
  • Heap Blocks: exact=1
322.          

Initplan (for Bitmap Heap Scan)

323. 0.456 0.909 ↑ 1.0 1 1

Aggregate (cost=0.32..0.33 rows=1 width=32) (actual time=0.907..0.909 rows=1 loops=1)

324. 0.453 0.453 ↓ 22.7 318 1

CTE Scan on realizado realizado_5 (cost=0.00..0.28 rows=14 width=32) (actual time=0.004..0.453 rows=318 loops=1)

325. 0.428 0.813 ↑ 1.0 1 1

Aggregate (cost=0.32..0.33 rows=1 width=32) (actual time=0.811..0.813 rows=1 loops=1)

326. 0.385 0.385 ↓ 22.7 318 1

CTE Scan on realizado realizado_6 (cost=0.00..0.28 rows=14 width=32) (actual time=0.002..0.385 rows=318 loops=1)

327. 2.644 2.644 ↑ 3.0 1 1

Bitmap Index Scan on pk_ccg_gerente_faixa_salario (cost=0.00..46.92 rows=3 width=0) (actual time=2.644..2.644 rows=1 loops=1)

  • Index Cond: (($105 >= (dofaturamento)::numeric) AND ($106 <= (atefaturamento)::numeric) AND (anomes = 201,909))
328. 0.024 0.024 ↑ 1.0 1 1

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_2 (cost=0.42..6.45 rows=1 width=4) (actual time=0.022..0.024 rows=1 loops=1)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 0))
  • Filter: (idtipometa = 0)
329. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_3 (cost=0.00..4.99 rows=1 width=3) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 0) AND (idtipometa = 0))
330. 0.007 1,834.252 ↑ 2.0 1 1

Unique (cost=396,585.64..396,585.65 rows=2 width=32) (actual time=1,834.247..1,834.252 rows=1 loops=1)

331. 0.020 1,834.245 ↑ 2.0 1 1

Sort (cost=396,585.64..396,585.65 rows=2 width=32) (actual time=1,834.243..1,834.245 rows=1 loops=1)

  • Sort Key: (sum(CASE WHEN ((((date((('20190901'::cstring)::date + '1 mon'::interval)) - 1) - (tp_2.datavencimento)::date) >= 0)) THEN (sum(((tp_2.saldocapital)::numeric + COALESCE(tp_2.saldojuro, '0'::numeric)))) ELSE '0'::numeric END))
  • Sort Method: quicksort Memory: 25kB
332. 0.012 1,834.225 ↑ 2.0 1 1

Append (cost=396,563.44..396,585.63 rows=2 width=32) (actual time=1,834.009..1,834.225 rows=1 loops=1)

333. 0.037 1,834.009 ↑ 1.0 1 1

Aggregate (cost=396,563.44..396,563.45 rows=1 width=32) (actual time=1,834.005..1,834.009 rows=1 loops=1)

  • Filter: (sum(CASE WHEN ((((date((('20190901'::cstring)::date + '1 mon'::interval)) - 1) - (tp_2.datavencimento)::date) >= 0)) THEN (sum(((tp_2.saldocapital)::numeric + COALESCE(tp_2.saldojuro, '0'::numeric)))) ELSE '0'::numeric END) IS NOT NULL)
334. 40.490 1,833.972 ↑ 346.0 2 1

GroupAggregate (cost=396,459.55..396,553.06 rows=692 width=37) (actual time=1,823.378..1,833.972 rows=2 loops=1)

  • Group Key: tp_2.idfilial, ((((date((('20190901'::cstring)::date + '1 mon'::interval)) - 1) - (tp_2.datavencimento)::date) >= 0))
335.          

Initplan (for GroupAggregate)

336. 0.029 0.029 ↓ 0.0 0 1

Index Only Scan using ccg_historico_recebimento_idx on ccg_historico_recebimento (cost=0.28..3.32 rows=1 width=0) (actual time=0.027..0.029 rows=0 loops=1)

  • Index Cond: ((anomes = 201,909) AND (idfilial = 10,002))
  • Filter: (anomes <> (to_char((CURRENT_DATE)::timestamp with time zone, 'yyyymm'::text))::integer)
  • Heap Fetches: 0
337. 13.717 13.717 ↑ 2.0 1 1

CTE Scan on metarecebimento m_7 (cost=0.00..25.00 rows=2 width=0) (actual time=13.717..13.717 rows=1 loops=1)

  • Filter: ((COALESCE((metavencido)::numeric, '0'::numeric) > '0'::numeric) AND (idfilial = 10,002))
  • Rows Removed by Filter: 264
338. 110.503 1,779.736 ↓ 6.7 39,084 1

Sort (cost=396,443.73..396,458.28 rows=5,820 width=14) (actual time=1,740.422..1,779.736 rows=39,084 loops=1)

  • Sort Key: ((((date((('20190901'::cstring)::date + '1 mon'::interval)) - 1) - (tp_2.datavencimento)::date) >= 0))
  • Sort Method: quicksort Memory: 3,434kB
339. 148.696 1,669.233 ↓ 6.7 39,084 1

Result (cost=4,605.82..396,079.78 rows=5,820 width=14) (actual time=47.058..1,669.233 rows=39,084 loops=1)

  • One-Time Filter: ((NOT $110) AND $111)
340. 109.555 1,520.537 ↓ 6.7 39,084 1

Hash Join (cost=4,605.82..395,977.93 rows=5,820 width=17) (actual time=33.298..1,520.537 rows=39,084 loops=1)

  • Hash Cond: ((t_1.idprocesso)::smallint = ccg_gerente_processos_fiado.idprocesso)
341. 205.879 1,410.733 ↓ 4.6 46,386 1

Nested Loop (cost=4,599.96..395,944.68 rows=10,114 width=19) (actual time=27.586..1,410.733 rows=46,386 loops=1)

342. 672.556 694.608 ↓ 1.1 46,386 1

Bitmap Heap Scan on tituloparcela tp_2 (cost=4,599.39..125,751.28 rows=42,160 width=23) (actual time=27.462..694.608 rows=46,386 loops=1)

  • Recheck Cond: ((((date((('20190901'::cstring)::date + '1 mon'::interval)) - 1) < (databaixa)::date) AND ((idfilial)::integer = 10,002) AND ((idtipotitulo)::smallint = 1)) OR ((databaixa IS NULL) AND ((idfilial)::integer = 10,002) AND ((idtipotitulo)::smallint = 1)))
  • Filter: ((((date((('20190901'::cstring)::date + '1 mon'::interval)) - 1) < (databaixa)::date) OR (databaixa IS NULL)) AND ((date((('20190901'::cstring)::date + '1 mon'::interval)) - 1) >= (datainicial)::date))
  • Heap Blocks: exact=19,898
343. 0.004 22.052 ↓ 0.0 0 1

BitmapOr (cost=4,599.39..4,599.39 rows=42,201 width=0) (actual time=22.051..22.052 rows=0 loops=1)

344. 0.535 0.535 ↑ 11.4 27 1

Bitmap Index Scan on ""idx_TituloParcela_DataBaixa2"" (cost=0.00..3,490.06 rows=307 width=0) (actual time=0.534..0.535 rows=27 loops=1)

  • Index Cond: (((date((('20190901'::cstring)::date + '1 mon'::interval)) - 1) < (databaixa)::date) AND ((idfilial)::integer = 10,002) AND ((idtipotitulo)::smallint = 1))
345. 21.513 21.513 ↓ 1.2 49,599 1

Bitmap Index Scan on ""idx_TituloParcela_DataBaixa2"" (cost=0.00..1,088.25 rows=41,894 width=0) (actual time=21.512..21.513 rows=49,599 loops=1)

  • Index Cond: ((databaixa IS NULL) AND ((idfilial)::integer = 10,002) AND ((idtipotitulo)::smallint = 1))
346. 510.246 510.246 ↑ 1.0 1 46,386

Index Scan using pk_titulo on titulo t_1 (cost=0.57..6.41 rows=1 width=12) (actual time=0.011..0.011 rows=1 loops=46,386)

  • Index Cond: (((idtipotitulo)::smallint = 1) AND ((idfilial)::integer = 10,002) AND ((idtitulo)::integer = (tp_2.idtitulo)::integer))
347. 0.086 0.249 ↑ 1.0 86 1

Hash (cost=4.79..4.79 rows=86 width=4) (actual time=0.248..0.249 rows=86 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 12kB
348. 0.163 0.163 ↑ 1.0 86 1

Index Only Scan using ccg_gerente_processos_fiado_pkey on ccg_gerente_processos_fiado (cost=0.29..4.79 rows=86 width=4) (actual time=0.083..0.163 rows=86 loops=1)

  • Index Cond: (anomes = 201,909)
  • Heap Fetches: 0
349. 0.000 0.204 ↓ 0.0 0 1

Aggregate (cost=22.13..22.14 rows=1 width=32) (actual time=0.203..0.204 rows=0 loops=1)

  • Filter: (sum((r_1.valorvencido)::numeric) IS NOT NULL)
  • Rows Removed by Filter: 1
350.          

Initplan (for Aggregate)

351. 0.120 0.120 ↑ 2.0 1 1

CTE Scan on metarecebimento m_8 (cost=0.00..25.00 rows=2 width=0) (actual time=0.119..0.120 rows=1 loops=1)

  • Filter: ((COALESCE((metavencido)::numeric, '0'::numeric) > '0'::numeric) AND (idfilial = 10,002))
  • Rows Removed by Filter: 264
352. 0.059 0.059 ↓ 0.0 0 1

Index Only Scan using ccg_historico_recebimento_idx on ccg_historico_recebimento ccg_historico_recebimento_1 (cost=0.28..3.32 rows=1 width=0) (actual time=0.058..0.059 rows=0 loops=1)

  • Index Cond: ((anomes = 201,909) AND (idfilial = 10,002))
  • Filter: (anomes <> (to_char((CURRENT_DATE)::timestamp with time zone, 'yyyymm'::text))::integer)
  • Heap Fetches: 0
353. 0.191 0.191 ↓ 0.0 0 1

Result (cost=0.28..6.30 rows=1 width=8) (actual time=0.190..0.191 rows=0 loops=1)

  • One-Time Filter: ($112 AND $113)
354. 0.000 0.000 ↓ 0.0 0

Index Scan using ccg_historico_recebimento_idx on ccg_historico_recebimento r_1 (cost=0.28..6.30 rows=1 width=8) (never executed)

  • Index Cond: ((anomes = 201,909) AND (idfilial = 10,002))
355. 0.010 437.275 ↑ 1.0 1 1

Subquery Scan on "*SELECT* 3_4" (cost=77.95..78.02 rows=1 width=264) (actual time=437.267..437.275 rows=1 loops=1)

356. 0.021 437.265 ↑ 1.0 1 1

Subquery Scan on tb_10 (cost=77.95..78.01 rows=1 width=236) (actual time=437.260..437.265 rows=1 loops=1)

357. 0.030 437.244 ↑ 1.0 1 1

Aggregate (cost=77.95..77.96 rows=1 width=164) (actual time=437.241..437.244 rows=1 loops=1)

358.          

Initplan (for Aggregate)

359. 0.056 0.056 ↑ 1.0 1 1

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_3 (cost=0.42..6.45 rows=1 width=6) (actual time=0.053..0.056 rows=1 loops=1)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 2))
  • Filter: (idtipometa = 1)
360. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_4 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 2) AND (idtipometa = 1))
361. 0.013 0.013 ↑ 1.0 1 1

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_4 (cost=0.42..6.45 rows=1 width=4) (actual time=0.012..0.013 rows=1 loops=1)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 2))
  • Filter: (idtipometa = 1)
362. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_5 (cost=0.00..4.99 rows=1 width=3) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 2) AND (idtipometa = 1))
363. 0.000 2.141 ↑ 3.0 1 1

Bitmap Heap Scan on ccg_gerente_faixa_salario f_8 (cost=47.58..54.87 rows=3 width=5) (actual time=2.139..2.141 rows=1 loops=1)

  • Recheck Cond: (($118 >= (dofaturamento)::numeric) AND ($119 <= (atefaturamento)::numeric) AND (anomes = 201,909))
  • Heap Blocks: exact=1
364.          

Initplan (for Bitmap Heap Scan)

365. 0.415 0.824 ↑ 1.0 1 1

Aggregate (cost=0.32..0.33 rows=1 width=32) (actual time=0.822..0.824 rows=1 loops=1)

366. 0.409 0.409 ↓ 22.7 318 1

CTE Scan on realizado realizado_7 (cost=0.00..0.28 rows=14 width=32) (actual time=0.003..0.409 rows=318 loops=1)

367. 0.359 0.673 ↑ 1.0 1 1

Aggregate (cost=0.32..0.33 rows=1 width=32) (actual time=0.671..0.673 rows=1 loops=1)

368. 0.314 0.314 ↓ 22.7 318 1

CTE Scan on realizado realizado_8 (cost=0.00..0.28 rows=14 width=32) (actual time=0.002..0.314 rows=318 loops=1)

369. 2.127 2.127 ↑ 3.0 1 1

Bitmap Index Scan on pk_ccg_gerente_faixa_salario (cost=0.00..46.92 rows=3 width=0) (actual time=2.126..2.127 rows=1 loops=1)

  • Index Cond: (($118 >= (dofaturamento)::numeric) AND ($119 <= (atefaturamento)::numeric) AND (anomes = 201,909))
370. 435.004 435.004 ↑ 9.0 1 1

CTE Scan on recperda recperda_2 (cost=0.00..0.18 rows=9 width=32) (actual time=434.999..435.004 rows=1 loops=1)

371. 0.002 0.005 ↓ 0.0 0 1

Subquery Scan on "*SELECT* 4_4" (cost=60.04..60.08 rows=1 width=264) (actual time=0.005..0.005 rows=0 loops=1)

372. 0.003 0.003 ↓ 0.0 0 1

Result (cost=60.04..60.06 rows=1 width=180) (actual time=0.002..0.003 rows=0 loops=1)

  • One-Time Filter: false
373.          

Initplan (for Result)

374. 0.000 0.000 ↓ 0.0 0

CTE Scan on meta_superestoque (cost=0.00..20.00 rows=1,000 width=32) (never executed)

375. 0.000 0.000 ↓ 0.0 0

CTE Scan on realizado_superestoque (cost=0.00..0.02 rows=1 width=32) (never executed)

376. 0.000 0.000 ↓ 0.0 0

CTE Scan on meta_superestoque meta_superestoque_1 (cost=0.00..20.00 rows=1,000 width=32) (never executed)

377. 0.000 0.000 ↓ 0.0 0

CTE Scan on realizado_superestoque realizado_superestoque_1 (cost=0.00..0.02 rows=1 width=32) (never executed)

378. 0.000 0.000 ↓ 0.0 0

CTE Scan on meta_superestoque meta_superestoque_2 (cost=0.00..20.00 rows=1,000 width=32) (never executed)

379. 0.002 0.004 ↓ 0.0 0 1

Subquery Scan on "*SELECT* 5_2" (cost=0.00..0.00 rows=1 width=264) (actual time=0.003..0.004 rows=0 loops=1)

380. 0.002 0.002 ↓ 0.0 0 1

Result (cost=0.00..0.00 rows=0 width=236) (actual time=0.001..0.002 rows=0 loops=1)

  • One-Time Filter: false
381. 0.003 0.003 ↓ 0.0 0 1

Result (cost=213.86..213.86 rows=0 width=292) (actual time=0.001..0.003 rows=0 loops=1)

  • One-Time Filter: false
382.          

Initplan (for Result)

383. 0.000 0.000 ↓ 0.0 0

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

384. 0.000 0.000 ↓ 0.0 0

CTE Scan on recperda recperda_1 (cost=0.00..0.18 rows=9 width=32) (never executed)

385. 0.000 0.000 ↓ 0.0 0

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

386. 0.000 0.000 ↓ 0.0 0

CTE Scan on perdas perdas_1 (cost=0.00..0.82 rows=41 width=32) (never executed)

387. 0.000 0.000 ↓ 0.0 0

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_5 (cost=0.42..6.45 rows=1 width=6) (never executed)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 6))
  • Filter: (idtipometa = 0)
388. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_6 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 6) AND (idtipometa = 0))
389. 0.000 0.000 ↓ 0.0 0

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_6 (cost=0.42..6.45 rows=1 width=6) (never executed)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 6))
  • Filter: (idtipometa = 0)
390. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_7 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 6) AND (idtipometa = 0))
391. 0.000 0.000 ↓ 0.0 0

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_7 (cost=0.42..6.45 rows=1 width=6) (never executed)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 6))
  • Filter: (idtipometa = 0)
392. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_8 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 6) AND (idtipometa = 0))
393. 0.000 0.000 ↓ 0.0 0

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_8 (cost=0.42..6.45 rows=1 width=6) (never executed)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 6))
  • Filter: (idtipometa = 0)
394. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_9 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 6) AND (idtipometa = 0))
395. 0.000 0.000 ↓ 0.0 0

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_9 (cost=0.42..6.45 rows=1 width=6) (never executed)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 6))
  • Filter: (idtipometa = 0)
396. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_10 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 6) AND (idtipometa = 0))
397. 0.000 0.000 ↓ 0.0 0

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

398. 0.000 0.000 ↓ 0.0 0

CTE Scan on excecao excecao_2 (cost=0.00..0.03 rows=1 width=4) (never executed)

  • Filter: ((idfilial = 10,002) AND (anomes = 201,909) AND (idmeta = 6))
399. 0.000 0.000 ↓ 0.0 0

Bitmap Heap Scan on ccg_gerente_faixa_salario f_9 (cost=47.58..54.87 rows=3 width=5) (never executed)

  • Recheck Cond: (($139 >= (dofaturamento)::numeric) AND ($140 <= (atefaturamento)::numeric) AND (anomes = 201,909))
400.          

Initplan (for Bitmap Heap Scan)

401. 0.000 0.000 ↓ 0.0 0

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

402. 0.000 0.000 ↓ 0.0 0

CTE Scan on realizado realizado_9 (cost=0.00..0.28 rows=14 width=32) (never executed)

403. 0.000 0.000 ↓ 0.0 0

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

404. 0.000 0.000 ↓ 0.0 0

CTE Scan on realizado realizado_10 (cost=0.00..0.28 rows=14 width=32) (never executed)

405. 0.000 0.000 ↓ 0.0 0

Bitmap Index Scan on pk_ccg_gerente_faixa_salario (cost=0.00..46.92 rows=3 width=0) (never executed)

  • Index Cond: (($139 >= (dofaturamento)::numeric) AND ($140 <= (atefaturamento)::numeric) AND (anomes = 201,909))
406. 0.000 0.000 ↓ 0.0 0

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_10 (cost=0.42..6.45 rows=1 width=4) (never executed)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 6))
  • Filter: (idtipometa = 0)
407. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_11 (cost=0.00..4.99 rows=1 width=3) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 6) AND (idtipometa = 0))
408. 0.000 0.000 ↓ 0.0 0

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_11 (cost=0.42..6.45 rows=1 width=6) (never executed)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 6))
  • Filter: (idtipometa = 0)
409. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_12 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 6) AND (idtipometa = 0))
410. 0.000 0.000 ↓ 0.0 0

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_12 (cost=0.42..6.45 rows=1 width=4) (never executed)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 6))
  • Filter: (idtipometa = 0)
411. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_13 (cost=0.00..4.99 rows=1 width=3) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 6) AND (idtipometa = 0))
412. 0.000 0.000 ↓ 0.0 0

Bitmap Heap Scan on ccg_gerente_faixa_salario f_10 (cost=47.58..54.87 rows=3 width=5) (never executed)

  • Recheck Cond: (($148 >= (dofaturamento)::numeric) AND ($149 <= (atefaturamento)::numeric) AND (anomes = 201,909))
413.          

Initplan (for Bitmap Heap Scan)

414. 0.000 0.000 ↓ 0.0 0

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

415. 0.000 0.000 ↓ 0.0 0

CTE Scan on realizado realizado_11 (cost=0.00..0.28 rows=14 width=32) (never executed)

416. 0.000 0.000 ↓ 0.0 0

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

417. 0.000 0.000 ↓ 0.0 0

CTE Scan on realizado realizado_12 (cost=0.00..0.28 rows=14 width=32) (never executed)

418. 0.000 0.000 ↓ 0.0 0

Bitmap Index Scan on pk_ccg_gerente_faixa_salario (cost=0.00..46.92 rows=3 width=0) (never executed)

  • Index Cond: (($148 >= (dofaturamento)::numeric) AND ($149 <= (atefaturamento)::numeric) AND (anomes = 201,909))
419. 0.000 0.000 ↓ 0.0 0

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_13 (cost=0.42..6.45 rows=1 width=4) (never executed)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 6))
  • Filter: (idtipometa = 0)
420. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_14 (cost=0.00..4.99 rows=1 width=3) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 6) AND (idtipometa = 0))
421. 0.002 0.004 ↓ 0.0 0 1

Subquery Scan on "*SELECT* 7_1" (cost=0.00..0.00 rows=1 width=292) (actual time=0.003..0.004 rows=0 loops=1)

422. 0.002 0.002 ↓ 0.0 0 1

Result (cost=0.00..0.00 rows=0 width=264) (actual time=0.001..0.002 rows=0 loops=1)

  • One-Time Filter: false
423.          

CTE semgirovelho

424. 0.000 0.000 ↓ 0.0 0

Aggregate (cost=865,297.73..865,297.74 rows=1 width=32) (never executed)

425. 0.000 0.000 ↓ 0.0 0

Hash Left Join (cost=62,619.49..667,594.29 rows=14,732 width=16) (never executed)

  • Hash Cond: (substr((d_3.classificacao)::text, 1, 3) = (dsgl.linha)::text)
  • Filter: CASE WHEN ((tb_21.idsituacaoproduto)::smallint = 1) THEN (round(CASE WHEN ((tb_21.posicao - CASE WHEN (CASE WHEN (split_part((SubPlan 129), ';'::text, 6) = ''::text) THEN NULL::text ELSE split_part((SubPlan 130), ';'::text, 6) END <> ''::text) THEN (CASE WHEN (split_part((SubPlan 131), ';'::text, 6) = ''::text) THEN NULL::text ELSE split_part((SubPlan 132), ';'::text, 6) END)::date ELSE tb_21.posicao END) > COALESCE(dsgsl.dias, dsgl.dias, 0)) THEN ((split_part((SubPlan 133), ';'::text, 1))::numeric * (split_part((SubPlan 134), ';'::text, 4))::numeric) ELSE '0'::numeric END, 2) > '0'::numeric) ELSE ((split_part((SubPlan 135), ';'::text, 1))::numeric > '0'::numeric) END
426. 0.000 0.000 ↓ 0.0 0

Hash Left Join (cost=62,618.04..660,606.52 rows=29,464 width=29) (never executed)

  • Hash Cond: (substr((d_3.classificacao)::text, 1, 5) = (dsgsl.linha)::text)
427. 0.000 0.000 ↓ 0.0 0

Hash Left Join (cost=62,616.59..660,522.25 rows=29,464 width=25) (never executed)

  • Hash Cond: ((p_3.iddepartamento)::integer = (d_3.iddepartamento)::integer)
428. 0.000 0.000 ↓ 0.0 0

Hash Left Join (cost=62,447.68..660,275.93 rows=29,464 width=22) (never executed)

  • Hash Cond: ((tb_21.idproduto)::integer = (p_3.idproduto)::integer)
429. 0.000 0.000 ↓ 0.0 0

Subquery Scan on tb_21 (cost=52,730.39..650,481.29 rows=29,464 width=18) (never executed)

  • Filter: (COALESCE((split_part((SubPlan 128), ';'::text, 4))::numeric, '0'::numeric) > '0'::numeric)
430. 0.000 0.000 ↓ 0.0 0

HashAggregate (cost=52,730.39..56,487.05 rows=88,392 width=22) (never executed)

  • Group Key: pg_1.idfilial, pg_1.idproduto, pg_1.idgradex, pg_1.idgradey, pd_1.idsituacaoproduto
431. 0.000 0.000 ↓ 0.0 0

Hash Join (cost=41,824.12..51,625.49 rows=88,392 width=14) (never executed)

  • Hash Cond: (((pd_1.idproduto)::integer = (pg_1.idproduto)::integer) AND ((pd_1.idgradex)::smallint = (pg_1.idgradex)::smallint) AND ((pd_1.idgradey)::smallint = (pg_1.idgradey)::smallint))
432. 0.000 0.000 ↓ 0.0 0

Seq Scan on produtograde pd_1 (cost=0.00..7,782.59 rows=256,334 width=10) (never executed)

  • Filter: ((idsituacaoproduto)::smallint = ANY ('{1,2,3}'::integer[]))
433. 0.000 0.000 ↓ 0.0 0

Hash (cost=40,277.26..40,277.26 rows=88,392 width=12) (never executed)

434. 0.000 0.000 ↓ 0.0 0

Index Only Scan using pk_produtogradefilial on produtogradefilial pg_1 (cost=0.56..40,277.26 rows=88,392 width=12) (never executed)

  • Index Cond: (idfilial = 10,002)
  • Heap Fetches: 0
435.          

SubPlan (for Subquery Scan)

436. 0.000 0.000 ↓ 0.0 0

Subquery Scan on tb_13 (cost=0.57..6.70 rows=1 width=32) (never executed)

437. 0.000 0.000 ↓ 0.0 0

Limit (cost=0.57..6.62 rows=1 width=156) (never executed)

438. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_itembase_saldoanteriorposicao_desc on itembase ib_8 (cost=0.57..6.62 rows=1 width=156) (never executed)

  • Index Cond: (((idfilial)::integer = (tb_21.idfilial)::integer) AND ((idproduto)::integer = (tb_21.idproduto)::integer) AND ((idgradex)::smallint = (tb_21.idgradex)::smallint) AND ((idgradey)::smallint = (tb_21.idgradey)::smallint) AND ((datamovimento)::date <= tb_21.posicao))
  • Filter: (((idoperacaoproduto)::integer > 0) AND ((idlocalsaldo)::smallint = ANY ('{1,2}'::integer[])))
439. 0.000 0.000 ↓ 0.0 0

Hash (cost=7,443.24..7,443.24 rows=181,924 width=12) (never executed)

440. 0.000 0.000 ↓ 0.0 0

Seq Scan on produto p_3 (cost=0.00..7,443.24 rows=181,924 width=12) (never executed)

441. 0.000 0.000 ↓ 0.0 0

Hash (cost=108.96..108.96 rows=4,796 width=11) (never executed)

442. 0.000 0.000 ↓ 0.0 0

Seq Scan on departamento d_3 (cost=0.00..108.96 rows=4,796 width=11) (never executed)

443. 0.000 0.000 ↓ 0.0 0

Hash (cost=1.20..1.20 rows=20 width=8) (never executed)

444. 0.000 0.000 ↓ 0.0 0

Seq Scan on compras_departamento_dias_sem_giro dsgsl (cost=0.00..1.20 rows=20 width=8) (never executed)

445. 0.000 0.000 ↓ 0.0 0

Hash (cost=1.20..1.20 rows=20 width=8) (never executed)

446. 0.000 0.000 ↓ 0.0 0

Seq Scan on compras_departamento_dias_sem_giro dsgl (cost=0.00..1.20 rows=20 width=8) (never executed)

447.          

SubPlan (for Hash Left Join)

448. 0.000 0.000 ↓ 0.0 0

Subquery Scan on tb_14 (cost=0.57..6.70 rows=1 width=32) (never executed)

449. 0.000 0.000 ↓ 0.0 0

Limit (cost=0.57..6.62 rows=1 width=156) (never executed)

450. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_itembase_saldoanteriorposicao_desc on itembase ib_9 (cost=0.57..6.62 rows=1 width=156) (never executed)

  • Index Cond: (((idfilial)::integer = (tb_21.idfilial)::integer) AND ((idproduto)::integer = (tb_21.idproduto)::integer) AND ((idgradex)::smallint = (tb_21.idgradex)::smallint) AND ((idgradey)::smallint = (tb_21.idgradey)::smallint) AND ((datamovimento)::date <= tb_21.posicao))
  • Filter: (((idoperacaoproduto)::integer > 0) AND ((idlocalsaldo)::smallint = ANY ('{1,2}'::integer[])))
451. 0.000 0.000 ↓ 0.0 0

Subquery Scan on tb_15 (cost=0.57..6.70 rows=1 width=32) (never executed)

452. 0.000 0.000 ↓ 0.0 0

Limit (cost=0.57..6.62 rows=1 width=156) (never executed)

453. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_itembase_saldoanteriorposicao_desc on itembase ib_10 (cost=0.57..6.62 rows=1 width=156) (never executed)

  • Index Cond: (((idfilial)::integer = (tb_21.idfilial)::integer) AND ((idproduto)::integer = (tb_21.idproduto)::integer) AND ((idgradex)::smallint = (tb_21.idgradex)::smallint) AND ((idgradey)::smallint = (tb_21.idgradey)::smallint) AND ((datamovimento)::date <= tb_21.posicao))
  • Filter: (((idoperacaoproduto)::integer > 0) AND ((idlocalsaldo)::smallint = ANY ('{1,2}'::integer[])))
454. 0.000 0.000 ↓ 0.0 0

Subquery Scan on tb_16 (cost=0.57..6.70 rows=1 width=32) (never executed)

455. 0.000 0.000 ↓ 0.0 0

Limit (cost=0.57..6.62 rows=1 width=156) (never executed)

456. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_itembase_saldoanteriorposicao_desc on itembase ib_11 (cost=0.57..6.62 rows=1 width=156) (never executed)

  • Index Cond: (((idfilial)::integer = (tb_21.idfilial)::integer) AND ((idproduto)::integer = (tb_21.idproduto)::integer) AND ((idgradex)::smallint = (tb_21.idgradex)::smallint) AND ((idgradey)::smallint = (tb_21.idgradey)::smallint) AND ((datamovimento)::date <= tb_21.posicao))
  • Filter: (((idoperacaoproduto)::integer > 0) AND ((idlocalsaldo)::smallint = ANY ('{1,2}'::integer[])))
457. 0.000 0.000 ↓ 0.0 0

Subquery Scan on tb_17 (cost=0.57..6.70 rows=1 width=32) (never executed)

458. 0.000 0.000 ↓ 0.0 0

Limit (cost=0.57..6.62 rows=1 width=156) (never executed)

459. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_itembase_saldoanteriorposicao_desc on itembase ib_12 (cost=0.57..6.62 rows=1 width=156) (never executed)

  • Index Cond: (((idfilial)::integer = (tb_21.idfilial)::integer) AND ((idproduto)::integer = (tb_21.idproduto)::integer) AND ((idgradex)::smallint = (tb_21.idgradex)::smallint) AND ((idgradey)::smallint = (tb_21.idgradey)::smallint) AND ((datamovimento)::date <= tb_21.posicao))
  • Filter: (((idoperacaoproduto)::integer > 0) AND ((idlocalsaldo)::smallint = ANY ('{1,2}'::integer[])))
460. 0.000 0.000 ↓ 0.0 0

Subquery Scan on tb_18 (cost=0.57..6.70 rows=1 width=32) (never executed)

461. 0.000 0.000 ↓ 0.0 0

Limit (cost=0.57..6.62 rows=1 width=156) (never executed)

462. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_itembase_saldoanteriorposicao_desc on itembase ib_13 (cost=0.57..6.62 rows=1 width=156) (never executed)

  • Index Cond: (((idfilial)::integer = (tb_21.idfilial)::integer) AND ((idproduto)::integer = (tb_21.idproduto)::integer) AND ((idgradex)::smallint = (tb_21.idgradex)::smallint) AND ((idgradey)::smallint = (tb_21.idgradey)::smallint) AND ((datamovimento)::date <= tb_21.posicao))
  • Filter: (((idoperacaoproduto)::integer > 0) AND ((idlocalsaldo)::smallint = ANY ('{1,2}'::integer[])))
463. 0.000 0.000 ↓ 0.0 0

Subquery Scan on tb_19 (cost=0.57..6.70 rows=1 width=32) (never executed)

464. 0.000 0.000 ↓ 0.0 0

Limit (cost=0.57..6.62 rows=1 width=156) (never executed)

465. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_itembase_saldoanteriorposicao_desc on itembase ib_14 (cost=0.57..6.62 rows=1 width=156) (never executed)

  • Index Cond: (((idfilial)::integer = (tb_21.idfilial)::integer) AND ((idproduto)::integer = (tb_21.idproduto)::integer) AND ((idgradex)::smallint = (tb_21.idgradex)::smallint) AND ((idgradey)::smallint = (tb_21.idgradey)::smallint) AND ((datamovimento)::date <= tb_21.posicao))
  • Filter: (((idoperacaoproduto)::integer > 0) AND ((idlocalsaldo)::smallint = ANY ('{1,2}'::integer[])))
466. 0.000 0.000 ↓ 0.0 0

Subquery Scan on tb_20 (cost=0.57..6.70 rows=1 width=32) (never executed)

467. 0.000 0.000 ↓ 0.0 0

Limit (cost=0.57..6.62 rows=1 width=156) (never executed)

468. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_itembase_saldoanteriorposicao_desc on itembase ib_15 (cost=0.57..6.62 rows=1 width=156) (never executed)

  • Index Cond: (((idfilial)::integer = (tb_21.idfilial)::integer) AND ((idproduto)::integer = (tb_21.idproduto)::integer) AND ((idgradex)::smallint = (tb_21.idgradex)::smallint) AND ((idgradey)::smallint = (tb_21.idgradey)::smallint) AND ((datamovimento)::date <= tb_21.posicao))
  • Filter: (((idoperacaoproduto)::integer > 0) AND ((idlocalsaldo)::smallint = ANY ('{1,2}'::integer[])))
469.          

SubPlan (for Aggregate)

470. 0.000 0.000 ↓ 0.0 0

Subquery Scan on tb_11 (cost=0.57..6.70 rows=1 width=32) (never executed)

471. 0.000 0.000 ↓ 0.0 0

Limit (cost=0.57..6.62 rows=1 width=156) (never executed)

472. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_itembase_saldoanteriorposicao_desc on itembase ib_6 (cost=0.57..6.62 rows=1 width=156) (never executed)

  • Index Cond: (((idfilial)::integer = (tb_21.idfilial)::integer) AND ((idproduto)::integer = (tb_21.idproduto)::integer) AND ((idgradex)::smallint = (tb_21.idgradex)::smallint) AND ((idgradey)::smallint = (tb_21.idgradey)::smallint) AND ((datamovimento)::date <= tb_21.posicao))
  • Filter: (((idoperacaoproduto)::integer > 0) AND ((idlocalsaldo)::smallint = ANY ('{1,2}'::integer[])))
473. 0.000 0.000 ↓ 0.0 0

Subquery Scan on tb_12 (cost=0.57..6.70 rows=1 width=32) (never executed)

474. 0.000 0.000 ↓ 0.0 0

Limit (cost=0.57..6.62 rows=1 width=156) (never executed)

475. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_itembase_saldoanteriorposicao_desc on itembase ib_7 (cost=0.57..6.62 rows=1 width=156) (never executed)

  • Index Cond: (((idfilial)::integer = (tb_21.idfilial)::integer) AND ((idproduto)::integer = (tb_21.idproduto)::integer) AND ((idgradex)::smallint = (tb_21.idgradex)::smallint) AND ((idgradey)::smallint = (tb_21.idgradey)::smallint) AND ((datamovimento)::date <= tb_21.posicao))
  • Filter: (((idoperacaoproduto)::integer > 0) AND ((idlocalsaldo)::smallint = ANY ('{1,2}'::integer[])))
476.          

CTE semgironovo

477. 3.726 12,420.895 ↑ 1.0 1 1

Aggregate (cost=2,434,959.64..2,434,959.65 rows=1 width=32) (actual time=12,420.893..12,420.895 rows=1 loops=1)

478. 27.644 12,374.986 ↑ 89.7 327 1

Hash Left Join (cost=62,619.49..2,004,073.03 rows=29,317 width=12) (actual time=1,876.057..12,374.986 rows=327 loops=1)

  • Hash Cond: (substr((d_4.classificacao)::text, 1, 3) = (dsgl_1.linha)::text)
  • Filter: ((tb_22.posicaomes - (CASE WHEN ((((SubPlan 141))::date >= ((SubPlan 142))::date) AND (COALESCE((SubPlan 143), '0'::numeric) = '0'::numeric)) THEN (SubPlan 144) ELSE COALESCE((SubPlan 145), (SubPlan 146)) END)::date) > COALESCE(dsgsl_1.dias, dsgl_1.dias))
  • Rows Removed by Filter: 746
479. 4.230 12,065.490 ↑ 82.0 1,073 1

Hash Left Join (cost=62,618.04..1,973,036.39 rows=87,950 width=59) (actual time=1,865.759..12,065.490 rows=1,073 loops=1)

  • Hash Cond: (substr((d_4.classificacao)::text, 1, 5) = (dsgsl_1.linha)::text)
480. 4.320 12,061.175 ↑ 82.0 1,073 1

Hash Left Join (cost=62,616.59..1,972,787.69 rows=87,950 width=55) (actual time=1,865.623..12,061.175 rows=1,073 loops=1)

  • Hash Cond: ((p_4.iddepartamento)::integer = (d_4.iddepartamento)::integer)
481. 9.283 12,044.475 ↑ 82.0 1,073 1

Hash Left Join (cost=62,447.68..1,972,387.71 rows=87,950 width=52) (actual time=1,853.149..12,044.475 rows=1,073 loops=1)

  • Hash Cond: ((tb_22.idproduto)::integer = (p_4.idproduto)::integer)
482. 545.045 11,555.978 ↑ 82.0 1,073 1

Subquery Scan on tb_22 (cost=52,730.39..1,962,439.55 rows=87,950 width=48) (actual time=1,370.283..11,555.978 rows=1,073 loops=1)

  • Filter: ((split_part(COALESCE((SubPlan 140), '0;0'::text), ';'::text, 1))::numeric(14,2) <> '0'::numeric)
  • Rows Removed by Filter: 85,324
483. 732.875 5,049.540 ↑ 1.0 86,397 1

HashAggregate (cost=52,730.39..662,414.21 rows=88,392 width=54) (actual time=1,356.362..5,049.540 rows=86,397 loops=1)

  • Group Key: pg_2.idfilial, pg_2.idproduto, pg_2.idgradex, pg_2.idgradey, pd_2.idsituacaoproduto
484. 445.555 1,206.373 ↑ 1.0 86,397 1

Hash Join (cost=41,824.12..51,625.49 rows=88,392 width=14) (actual time=438.124..1,206.373 rows=86,397 loops=1)

  • Hash Cond: (((pd_2.idproduto)::integer = (pg_2.idproduto)::integer) AND ((pd_2.idgradex)::smallint = (pg_2.idgradex)::smallint) AND ((pd_2.idgradey)::smallint = (pg_2.idgradey)::smallint))
485. 323.846 323.846 ↓ 1.0 256,352 1

Seq Scan on produtograde pd_2 (cost=0.00..7,782.59 rows=256,334 width=10) (actual time=0.017..323.846 rows=256,352 loops=1)

  • Filter: ((idsituacaoproduto)::smallint = ANY ('{1,2,3}'::integer[]))
486. 158.988 436.972 ↑ 1.0 86,397 1

Hash (cost=40,277.26..40,277.26 rows=88,392 width=12) (actual time=436.971..436.972 rows=86,397 loops=1)

  • Buckets: 131,072 Batches: 1 Memory Usage: 4,737kB
487. 277.984 277.984 ↑ 1.0 86,397 1

Index Only Scan using pk_produtogradefilial on produtogradefilial pg_2 (cost=0.56..40,277.26 rows=88,392 width=12) (actual time=0.093..277.984 rows=86,397 loops=1)

  • Index Cond: (idfilial = 10,002)
  • Heap Fetches: 13,390
488.          

SubPlan (for HashAggregate)

489. 1,468.749 3,110.292 ↓ 0.0 0 86,397

Limit (cost=0.82..6.88 rows=1 width=52) (actual time=0.036..0.036 rows=0 loops=86,397)

490. 1,641.543 1,641.543 ↓ 0.0 0 86,397

Index Scan using idx_itembase_saldoanteriorposicao_desc on itembase ib_24 (cost=0.82..6.88 rows=1 width=52) (actual time=0.019..0.019 rows=0 loops=86,397)

  • Index Cond: (((idfilial)::integer = 10,002) AND ((idproduto)::integer = (pg_2.idproduto)::integer) AND ((idgradex)::smallint = (pg_2.idgradex)::smallint) AND ((idgradey)::smallint = (pg_2.idgradey)::smallint) AND ((datamovimento)::date <= gazin.ultimo_dia_mes(('20190901'::cstring)::date)))
  • Filter: ((idoperacaoproduto IS NOT NULL) AND (saldo = '0'::numeric) AND ((idoperacaoproduto)::integer = 102,010))
  • Rows Removed by Filter: 0
491.          

SubPlan (for Subquery Scan)

492. 518.382 5,961.393 ↑ 1.0 1 86,397

Subquery Scan on ii_1 (cost=14.65..14.69 rows=1 width=32) (actual time=0.066..0.069 rows=1 loops=86,397)

493. 604.779 5,443.011 ↑ 1.0 1 86,397

Aggregate (cost=14.65..14.66 rows=1 width=64) (actual time=0.062..0.063 rows=1 loops=86,397)

494.          

Initplan (for Aggregate)

495. 1,641.543 2,505.513 ↓ 0.0 0 86,397

Limit (cost=0.82..6.86 rows=1 width=56) (actual time=0.028..0.029 rows=0 loops=86,397)

496. 863.970 863.970 ↓ 0.0 0 86,397

Index Scan using idx_itembase_saldoanteriorposicao_desc on itembase ib_17 (cost=0.82..6.86 rows=1 width=56) (actual time=0.010..0.010 rows=0 loops=86,397)

  • Index Cond: (((idfilial)::integer = (tb_22.idfilial)::integer) AND ((idproduto)::integer = (tb_22.idproduto)::integer) AND ((idgradex)::smallint = (tb_22.idgradex)::smallint) AND ((idgradey)::smallint = (tb_22.idgradey)::smallint) AND ((datamovimento)::date <= gazin.ultimo_dia_mes(('20190901'::cstring)::date)))
  • Filter: ((idoperacaoproduto)::integer > 0)
  • Rows Removed by Filter: 0
497. 473.089 2,332.719 ↓ 0.0 0 86,397

Nested Loop (cost=0.56..7.78 rows=1 width=5) (actual time=0.022..0.027 rows=0 loops=86,397)

498. 1,727.940 1,727.940 ↓ 0.0 0 86,397

Index Scan using idx_produtogradesaldofilial_filialprodutograde on produtogradesaldofilial pgsf_2 (cost=0.56..6.59 rows=1 width=5) (actual time=0.018..0.020 rows=0 loops=86,397)

  • Index Cond: (((idfilial)::integer = (tb_22.idfilial)::integer) AND ((idproduto)::integer = (tb_22.idproduto)::integer) AND ((idgradex)::smallint = (tb_22.idgradex)::smallint) AND ((idgradey)::smallint = (tb_22.idgradey)::smallint))
  • Filter: ((idtiposaldoproduto)::smallint = 1)
  • Rows Removed by Filter: 1
499. 131.690 131.690 ↑ 1.0 1 26,338

Seq Scan on tiposaldoproduto tp_4 (cost=0.00..1.18 rows=1 width=4) (actual time=0.003..0.005 rows=1 loops=26,338)

  • Filter: ((idtiposaldoproduto)::smallint = 1)
  • Rows Removed by Filter: 13
500. 236.615 479.214 ↓ 1.0 181,940 1

Hash (cost=7,443.24..7,443.24 rows=181,924 width=12) (actual time=479.213..479.214 rows=181,940 loops=1)

  • Buckets: 262,144 Batches: 1 Memory Usage: 9,848kB
501. 242.599 242.599 ↓ 1.0 181,940 1

Seq Scan on produto p_4 (cost=0.00..7,443.24 rows=181,924 width=12) (actual time=0.022..242.599 rows=181,940 loops=1)

502. 6.024 12.380 ↑ 1.0 4,796 1

Hash (cost=108.96..108.96 rows=4,796 width=11) (actual time=12.380..12.380 rows=4,796 loops=1)

  • Buckets: 8,192 Batches: 1 Memory Usage: 270kB
503. 6.356 6.356 ↑ 1.0 4,796 1

Seq Scan on departamento d_4 (cost=0.00..108.96 rows=4,796 width=11) (actual time=0.044..6.356 rows=4,796 loops=1)

504. 0.042 0.085 ↑ 1.0 20 1

Hash (cost=1.20..1.20 rows=20 width=8) (actual time=0.084..0.085 rows=20 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
505. 0.043 0.043 ↑ 1.0 20 1

Seq Scan on compras_departamento_dias_sem_giro dsgsl_1 (cost=0.00..1.20 rows=20 width=8) (actual time=0.017..0.043 rows=20 loops=1)

506. 0.042 0.080 ↑ 1.0 20 1

Hash (cost=1.20..1.20 rows=20 width=8) (actual time=0.079..0.080 rows=20 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
507. 0.038 0.038 ↑ 1.0 20 1

Seq Scan on compras_departamento_dias_sem_giro dsgl_1 (cost=0.00..1.20 rows=20 width=8) (actual time=0.004..0.038 rows=20 loops=1)

508.          

SubPlan (for Hash Left Join)

509. 8.584 69.745 ↑ 1.0 1 1,073

Limit (cost=1.12..3.40 rows=1 width=20) (actual time=0.059..0.065 rows=1 loops=1,073)

510. 32.723 61.161 ↑ 4.0 1 1,073

Nested Loop (cost=1.12..10.25 rows=4 width=20) (actual time=0.056..0.057 rows=1 loops=1,073)

511. 17.168 17.168 ↑ 1.0 1 1,073

Index Scan using idx_itembase_saldoanteriorposicao_desc on itembase ib_18 (cost=0.84..6.88 rows=1 width=22) (actual time=0.015..0.016 rows=1 loops=1,073)

  • Index Cond: (((idfilial)::integer = (tb_22.idfilial)::integer) AND ((idproduto)::integer = (tb_22.idproduto)::integer) AND ((idgradex)::smallint = (tb_22.idgradex)::smallint) AND ((idgradey)::smallint = (tb_22.idgradey)::smallint) AND ((datamovimento)::date >= (split_part(tb_22.ultimosaldozerado, ';'::text, 1))::date) AND ((datamovimento)::date <= gazin.ultimo_dia_mes(('20190901'::cstring)::date)) AND ((idmovimento)::integer > (split_part(tb_22.ultimosaldozerado, ';'::text, 2))::integer))
  • Filter: (saldo > '0'::numeric)
  • Rows Removed by Filter: 0
512. 11.270 11.270 ↑ 3.0 1 1,127

Index Only Scan using pk_processocomposto on processocomposto pc (cost=0.28..3.35 rows=3 width=2) (actual time=0.009..0.010 rows=1 loops=1,127)

  • Index Cond: (idprocesso = (ib_18.idprocessomestre)::smallint)
  • Filter: ((idprocessocomposto)::smallint <> ALL ('{1060,1222,1228}'::integer[]))
  • Rows Removed by Filter: 0
  • Heap Fetches: 0
513. 11.803 76.183 ↑ 1.0 1 1,073

Limit (cost=1.83..19.91 rows=1 width=20) (actual time=0.062..0.071 rows=1 loops=1,073)

514. 27.752 64.380 ↑ 1.0 1 1,073

Nested Loop Anti Join (cost=1.83..19.91 rows=1 width=20) (actual time=0.059..0.060 rows=1 loops=1,073)

515. 17.168 17.168 ↑ 1.0 1 1,073

Index Scan using idx_itembase_saldoanteriorposicao_desc on itembase ib_19 (cost=0.83..6.87 rows=1 width=29) (actual time=0.015..0.016 rows=1 loops=1,073)

  • Index Cond: (((idfilial)::integer = (tb_22.idfilial)::integer) AND ((idproduto)::integer = (tb_22.idproduto)::integer) AND ((idgradex)::smallint = (tb_22.idgradex)::smallint) AND ((idgradey)::smallint = (tb_22.idgradey)::smallint) AND ((datamovimento)::date >= (split_part(tb_22.ultimosaldozerado, ';'::text, 1))::date) AND ((datamovimento)::date <= gazin.ultimo_dia_mes(('20190901'::cstring)::date)))
  • Filter: ((idoperacaoproduto)::integer = ANY ('{102010,102020}'::integer[]))
  • Rows Removed by Filter: 1
516. 2.544 19.460 ↓ 0.0 0 973

Nested Loop (cost=1.00..13.04 rows=1 width=13) (actual time=0.019..0.020 rows=0 loops=973)

  • Join Filter: (ibd.quantidade = ib_19.quantidade)
517. 13.622 13.622 ↓ 0.0 0 973

Index Scan using ix_fk_itemnotadevolucao_itembasereferente on itemnotadevolucao ind (cost=0.43..6.45 rows=1 width=12) (actual time=0.013..0.014 rows=0 loops=973)

  • Index Cond: (((idfilial)::integer = (ib_19.idfilial)::integer) AND ((idfilial)::integer = (tb_22.idfilial)::integer) AND ((iditembasereferente)::integer = (ib_19.iditembase)::integer))
518. 3.294 3.294 ↑ 1.0 1 61

Index Scan using pk_itembase on itembase ibd (cost=0.57..6.58 rows=1 width=13) (actual time=0.040..0.054 rows=1 loops=61)

  • Index Cond: (((idfilial)::integer = (tb_22.idfilial)::integer) AND ((iditembase)::integer = (ind.iditembasedevolucao)::integer))
519. 7.490 55.640 ↓ 0.0 0 1,070

Limit (cost=1.84..19.92 rows=1 width=24) (actual time=0.048..0.052 rows=0 loops=1,070)

520. 27.755 48.150 ↓ 0.0 0 1,070

Nested Loop Anti Join (cost=1.84..19.92 rows=1 width=24) (actual time=0.045..0.045 rows=0 loops=1,070)

521. 16.050 16.050 ↓ 0.0 0 1,070

Index Scan using idx_itembase_saldoanteriorposicao_desc on itembase ib_20 (cost=0.84..6.88 rows=1 width=33) (actual time=0.015..0.015 rows=0 loops=1,070)

  • Index Cond: (((idfilial)::integer = (tb_22.idfilial)::integer) AND ((idproduto)::integer = (tb_22.idproduto)::integer) AND ((idgradex)::smallint = (tb_22.idgradex)::smallint) AND ((idgradey)::smallint = (tb_22.idgradey)::smallint) AND ((datamovimento)::date >= (split_part(tb_22.ultimosaldozerado, ';'::text, 1))::date) AND ((datamovimento)::date <= gazin.ultimo_dia_mes(('20190901'::cstring)::date)) AND ((idmovimento)::integer > (split_part(tb_22.ultimosaldozerado, ';'::text, 2))::integer))
  • Filter: ((idoperacaoproduto)::integer = ANY ('{102010,102020}'::integer[]))
  • Rows Removed by Filter: 1
522. 1.120 4.345 ↓ 0.0 0 395

Nested Loop (cost=1.00..13.04 rows=1 width=13) (actual time=0.010..0.011 rows=0 loops=395)

  • Join Filter: (ibd_1.quantidade = ib_20.quantidade)
523. 2.765 2.765 ↓ 0.0 0 395

Index Scan using ix_fk_itemnotadevolucao_itembasereferente on itemnotadevolucao ind_1 (cost=0.43..6.45 rows=1 width=12) (actual time=0.006..0.007 rows=0 loops=395)

  • Index Cond: (((idfilial)::integer = (ib_20.idfilial)::integer) AND ((idfilial)::integer = (tb_22.idfilial)::integer) AND ((iditembasereferente)::integer = (ib_20.iditembase)::integer))
524. 0.460 0.460 ↑ 1.0 1 20

Index Scan using pk_itembase on itembase ibd_1 (cost=0.57..6.58 rows=1 width=13) (actual time=0.008..0.023 rows=1 loops=20)

  • Index Cond: (((idfilial)::integer = (tb_22.idfilial)::integer) AND ((iditembase)::integer = (ind_1.iditembasedevolucao)::integer))
525. 3.531 22.149 ↑ 1.0 1 321

Limit (cost=1.12..3.40 rows=1 width=20) (actual time=0.061..0.069 rows=1 loops=321)

526. 10.680 18.618 ↑ 4.0 1 321

Nested Loop (cost=1.12..10.25 rows=4 width=20) (actual time=0.058..0.058 rows=1 loops=321)

527. 5.136 5.136 ↑ 1.0 1 321

Index Scan using idx_itembase_saldoanteriorposicao_desc on itembase ib_21 (cost=0.84..6.88 rows=1 width=22) (actual time=0.013..0.016 rows=1 loops=321)

  • Index Cond: (((idfilial)::integer = (tb_22.idfilial)::integer) AND ((idproduto)::integer = (tb_22.idproduto)::integer) AND ((idgradex)::smallint = (tb_22.idgradex)::smallint) AND ((idgradey)::smallint = (tb_22.idgradey)::smallint) AND ((datamovimento)::date >= (split_part(tb_22.ultimosaldozerado, ';'::text, 1))::date) AND ((datamovimento)::date <= gazin.ultimo_dia_mes(('20190901'::cstring)::date)) AND ((idmovimento)::integer > (split_part(tb_22.ultimosaldozerado, ';'::text, 2))::integer))
  • Filter: (saldo > '0'::numeric)
  • Rows Removed by Filter: 0
528. 2.802 2.802 ↑ 3.0 1 467

Index Only Scan using pk_processocomposto on processocomposto pc_1 (cost=0.28..3.35 rows=3 width=2) (actual time=0.005..0.006 rows=1 loops=467)

  • Index Cond: (idprocesso = (ib_21.idprocessomestre)::smallint)
  • Filter: ((idprocessocomposto)::smallint <> ALL ('{1060,1222,1228}'::integer[]))
  • Rows Removed by Filter: 0
  • Heap Fetches: 0
529. 8.272 46.624 ↑ 1.0 1 752

Limit (cost=1.83..19.91 rows=1 width=20) (actual time=0.053..0.062 rows=1 loops=752)

530. 19.296 38.352 ↑ 1.0 1 752

Nested Loop Anti Join (cost=1.83..19.91 rows=1 width=20) (actual time=0.050..0.051 rows=1 loops=752)

531. 11.280 11.280 ↑ 1.0 1 752

Index Scan using idx_itembase_saldoanteriorposicao_desc on itembase ib_22 (cost=0.83..6.87 rows=1 width=29) (actual time=0.014..0.015 rows=1 loops=752)

  • Index Cond: (((idfilial)::integer = (tb_22.idfilial)::integer) AND ((idproduto)::integer = (tb_22.idproduto)::integer) AND ((idgradex)::smallint = (tb_22.idgradex)::smallint) AND ((idgradey)::smallint = (tb_22.idgradey)::smallint) AND ((datamovimento)::date >= (split_part(tb_22.ultimosaldozerado, ';'::text, 1))::date) AND ((datamovimento)::date <= gazin.ultimo_dia_mes(('20190901'::cstring)::date)))
  • Filter: ((idoperacaoproduto)::integer = ANY ('{102010,102020}'::integer[]))
  • Rows Removed by Filter: 1
532. 2.157 7.776 ↓ 0.0 0 648

Nested Loop (cost=1.00..13.04 rows=1 width=13) (actual time=0.011..0.012 rows=0 loops=648)

  • Join Filter: (ibd_2.quantidade = ib_22.quantidade)
533. 4.536 4.536 ↓ 0.0 0 648

Index Scan using ix_fk_itemnotadevolucao_itembasereferente on itemnotadevolucao ind_2 (cost=0.43..6.45 rows=1 width=12) (actual time=0.006..0.007 rows=0 loops=648)

  • Index Cond: (((idfilial)::integer = (ib_22.idfilial)::integer) AND ((idfilial)::integer = (tb_22.idfilial)::integer) AND ((iditembasereferente)::integer = (ib_22.iditembase)::integer))
534. 1.083 1.083 ↑ 1.0 1 57

Index Scan using pk_itembase on itembase ibd_2 (cost=0.57..6.58 rows=1 width=13) (actual time=0.009..0.019 rows=1 loops=57)

  • Index Cond: (((idfilial)::integer = (tb_22.idfilial)::integer) AND ((iditembase)::integer = (ind_2.iditembasedevolucao)::integer))
535. 1.610 11.431 ↑ 1.0 1 161

Limit (cost=1.12..3.40 rows=1 width=20) (actual time=0.064..0.071 rows=1 loops=161)

536. 6.116 9.821 ↑ 4.0 1 161

Nested Loop (cost=1.12..10.25 rows=4 width=20) (actual time=0.060..0.061 rows=1 loops=161)

537. 2.415 2.415 ↑ 1.0 1 161

Index Scan using idx_itembase_saldoanteriorposicao_desc on itembase ib_23 (cost=0.84..6.88 rows=1 width=22) (actual time=0.013..0.015 rows=1 loops=161)

  • Index Cond: (((idfilial)::integer = (tb_22.idfilial)::integer) AND ((idproduto)::integer = (tb_22.idproduto)::integer) AND ((idgradex)::smallint = (tb_22.idgradex)::smallint) AND ((idgradey)::smallint = (tb_22.idgradey)::smallint) AND ((datamovimento)::date >= (split_part(tb_22.ultimosaldozerado, ';'::text, 1))::date) AND ((datamovimento)::date <= gazin.ultimo_dia_mes(('20190901'::cstring)::date)) AND ((idmovimento)::integer > (split_part(tb_22.ultimosaldozerado, ';'::text, 2))::integer))
  • Filter: (saldo > '0'::numeric)
  • Rows Removed by Filter: 0
538. 1.290 1.290 ↑ 3.0 1 215

Index Only Scan using pk_processocomposto on processocomposto pc_2 (cost=0.28..3.35 rows=3 width=2) (actual time=0.006..0.006 rows=1 loops=215)

  • Index Cond: (idprocesso = (ib_23.idprocessomestre)::smallint)
  • Filter: ((idprocessocomposto)::smallint <> ALL ('{1060,1222,1228}'::integer[]))
  • Rows Removed by Filter: 0
  • Heap Fetches: 0
539.          

SubPlan (for Aggregate)

540. 3.924 42.183 ↑ 1.0 1 327

Subquery Scan on ii (cost=14.65..14.69 rows=1 width=32) (actual time=0.126..0.129 rows=1 loops=327)

541. 6.213 38.259 ↑ 1.0 1 327

Aggregate (cost=14.65..14.66 rows=1 width=64) (actual time=0.116..0.117 rows=1 loops=327)

542.          

Initplan (for Aggregate)

543. 9.810 16.677 ↑ 1.0 1 327

Limit (cost=0.82..6.86 rows=1 width=56) (actual time=0.048..0.051 rows=1 loops=327)

544. 6.867 6.867 ↑ 1.0 1 327

Index Scan using idx_itembase_saldoanteriorposicao_desc on itembase ib_16 (cost=0.82..6.86 rows=1 width=56) (actual time=0.020..0.021 rows=1 loops=327)

  • Index Cond: (((idfilial)::integer = (tb_22.idfilial)::integer) AND ((idproduto)::integer = (tb_22.idproduto)::integer) AND ((idgradex)::smallint = (tb_22.idgradex)::smallint) AND ((idgradey)::smallint = (tb_22.idgradey)::smallint) AND ((datamovimento)::date <= gazin.ultimo_dia_mes(('20190901'::cstring)::date)))
  • Filter: ((idoperacaoproduto)::integer > 0)
  • Rows Removed by Filter: 0
545. 5.943 15.369 ↓ 2.0 2 327

Nested Loop (cost=0.56..7.78 rows=1 width=5) (actual time=0.025..0.047 rows=2 loops=327)

546. 5.886 5.886 ↓ 2.0 2 327

Index Scan using idx_produtogradesaldofilial_filialprodutograde on produtogradesaldofilial pgsf_1 (cost=0.56..6.59 rows=1 width=5) (actual time=0.012..0.018 rows=2 loops=327)

  • Index Cond: (((idfilial)::integer = (tb_22.idfilial)::integer) AND ((idproduto)::integer = (tb_22.idproduto)::integer) AND ((idgradex)::smallint = (tb_22.idgradex)::smallint) AND ((idgradey)::smallint = (tb_22.idgradey)::smallint))
  • Filter: ((idtiposaldoproduto)::smallint = 1)
  • Rows Removed by Filter: 2
547. 3.540 3.540 ↑ 1.0 1 708

Seq Scan on tiposaldoproduto tp_3 (cost=0.00..1.18 rows=1 width=4) (actual time=0.003..0.005 rows=1 loops=708)

  • Filter: ((idtiposaldoproduto)::smallint = 1)
  • Rows Removed by Filter: 13
548.          

CTE semgiro

549. 0.004 12,420.939 ↑ 2.0 1 1

Unique (cost=0.05..0.06 rows=2 width=32) (actual time=12,420.936..12,420.939 rows=1 loops=1)

550. 0.026 12,420.935 ↑ 2.0 1 1

Sort (cost=0.05..0.06 rows=2 width=32) (actual time=12,420.933..12,420.935 rows=1 loops=1)

  • Sort Key: valorsemgiro
  • Sort Method: quicksort Memory: 25kB
551. 0.003 12,420.909 ↑ 2.0 1 1

Append (cost=0.00..0.04 rows=2 width=32) (actual time=12,420.904..12,420.909 rows=1 loops=1)

552. 0.004 0.004 ↓ 0.0 0 1

Result (cost=0.00..0.00 rows=0 width=0) (actual time=0.002..0.004 rows=0 loops=1)

  • One-Time Filter: false
553. 12,420.902 12,420.902 ↑ 1.0 1 1

CTE Scan on semgironovo (cost=0.00..0.02 rows=1 width=32) (actual time=12,420.899..12,420.902 rows=1 loops=1)

554.          

CTE foralinha

555. 388.473 11,068.804 ↑ 1.0 1 1

Aggregate (cost=411,899.08..411,899.09 rows=1 width=32) (actual time=11,068.803..11,068.804 rows=1 loops=1)

556. 332.539 1,218.200 ↓ 2.5 58,771 1

HashAggregate (cost=52,617.33..53,153.48 rows=23,829 width=16) (actual time=990.761..1,218.200 rows=58,771 loops=1)

  • Group Key: pg_3.idfilial, pg_3.idproduto, pg_3.idgradex, pg_3.idgradey
557. 182.323 885.661 ↓ 2.5 58,771 1

Hash Join (cost=11,406.22..52,379.04 rows=23,829 width=12) (actual time=491.837..885.661 rows=58,771 loops=1)

  • Hash Cond: (((pg_3.idproduto)::integer = (pd_3.idproduto)::integer) AND ((pg_3.idgradex)::smallint = (pd_3.idgradex)::smallint) AND ((pg_3.idgradey)::smallint = (pd_3.idgradey)::smallint))
558. 212.449 212.449 ↑ 1.0 86,397 1

Index Only Scan using pk_produtogradefilial on produtogradefilial pg_3 (cost=0.56..40,277.26 rows=88,392 width=12) (actual time=0.092..212.449 rows=86,397 loops=1)

  • Index Cond: (idfilial = 10,002)
  • Heap Fetches: 13,390
559. 195.192 490.889 ↓ 2.0 138,208 1

Hash (cost=10,196.35..10,196.35 rows=69,103 width=8) (actual time=490.888..490.889 rows=138,208 loops=1)

  • Buckets: 262,144 (originally 131072) Batches: 1 (originally 1) Memory Usage: 7,447kB
560. 281.246 295.697 ↓ 2.0 138,208 1

Bitmap Heap Scan on produtograde pd_3 (cost=2,137.66..10,196.35 rows=69,103 width=8) (actual time=15.102..295.697 rows=138,208 loops=1)

  • Recheck Cond: ((idsituacaoproduto)::smallint = ANY ('{2,3}'::integer[]))
  • Filter: CASE WHEN (ultimaalteracao IS NOT NULL) THEN ((ultimaalteracao)::timestamp without time zone <= (date((('20190901'::cstring)::date + '1 mon'::interval)) - 1)) ELSE true END
  • Rows Removed by Filter: 8
  • Heap Blocks: exact=3,302
561. 14.451 14.451 ↓ 1.0 138,223 1

Bitmap Index Scan on idx_produtograde_situacaoproduto (cost=0.00..2,120.39 rows=138,207 width=0) (actual time=14.450..14.451 rows=138,223 loops=1)

  • Index Cond: ((idsituacaoproduto)::smallint = ANY ('{2,3}'::integer[]))
562.          

SubPlan (for Aggregate)

563. 235.084 8,639.337 ↑ 1.0 1 58,771

Aggregate (cost=8.43..8.44 rows=1 width=32) (actual time=0.146..0.147 rows=1 loops=58,771)

564. 352.626 8,404.253 ↓ 0.0 0 58,771

Unique (cost=8.40..8.41 rows=1 width=30) (actual time=0.136..0.143 rows=0 loops=58,771)

565. 1,116.649 8,051.627 ↓ 3.0 3 58,771

Sort (cost=8.40..8.41 rows=1 width=30) (actual time=0.134..0.137 rows=3 loops=58,771)

  • Sort Key: ib_25.idlocalsaldo, ib_25.datamovimento DESC, ib_25.idmovimento DESC, ib_25.iditembase DESC
  • Sort Method: quicksort Memory: 25kB
566. 1,163.852 6,934.978 ↓ 3.0 3 58,771

Hash Join (cost=6.61..8.39 rows=1 width=30) (actual time=0.109..0.118 rows=3 loops=58,771)

  • Hash Cond: ((localsaldo.idlocalsaldo)::smallint = (ib_25.idlocalsaldo)::smallint)
567. 716.820 716.820 ↑ 1.0 56 13,785

Seq Scan on localsaldo (cost=0.00..1.56 rows=56 width=2) (actual time=0.003..0.052 rows=56 loops=13,785)

568. 411.397 5,054.306 ↓ 3.0 3 58,771

Hash (cost=6.60..6.60 rows=1 width=30) (actual time=0.086..0.086 rows=3 loops=58,771)

  • Buckets: 1,024 Batches: 1 Memory Usage: 8kB
569. 4,642.909 4,642.909 ↓ 3.0 3 58,771

Index Scan using idx_itembase_saldoanterior_desc on itembase ib_25 (cost=0.57..6.60 rows=1 width=30) (actual time=0.024..0.079 rows=3 loops=58,771)

  • Index Cond: (((idproduto)::integer = (pg_3.idproduto)::integer) AND ((idgradex)::smallint = (pg_3.idgradex)::smallint) AND ((idgradey)::smallint = (pg_3.idgradey)::smallint) AND ((idfilial)::integer = (pg_3.idfilial)::integer) AND ((datamovimento)::date <= ((date((('20190901'::cstring)::date + '1 mon'::interval)) - 1))))
  • Filter: ((idoperacaoproduto)::integer > 0)
  • Rows Removed by Filter: 1
570. 176.313 822.794 ↓ 0.0 0 58,771

Limit (cost=0.57..6.61 rows=1 width=56) (actual time=0.014..0.014 rows=0 loops=58,771)

571. 646.481 646.481 ↓ 0.0 0 58,771

Index Scan using idx_itembase_saldoanteriorposicao_desc on itembase ib_26 (cost=0.57..6.61 rows=1 width=56) (actual time=0.011..0.011 rows=0 loops=58,771)

  • Index Cond: (((idfilial)::integer = (pg_3.idfilial)::integer) AND ((idproduto)::integer = (pg_3.idproduto)::integer) AND ((idgradex)::smallint = (pg_3.idgradex)::smallint) AND ((idgradey)::smallint = (pg_3.idgradey)::smallint) AND ((datamovimento)::date <= ((date((('20190901'::cstring)::date + '1 mon'::interval)) - 1))))
  • Filter: ((idoperacaoproduto)::integer > 0)
  • Rows Removed by Filter: 0
572.          

CTE auditoria

573. 13.215 13.215 ↑ 1.0 1 1

Result (cost=0.00..0.26 rows=1 width=32) (actual time=13.213..13.215 rows=1 loops=1)

574.          

CTE estoque

575. 0.067 35,614.782 ↑ 1.5 4 1

HashAggregate (cost=931.54..931.60 rows=6 width=212) (actual time=35,614.762..35,614.782 rows=4 loops=1)

  • Group Key: ('Estoque'::text), ('Total Estoque'::text), (1), (0), (0), ""*SELECT* 1_4"".valormeta, ""*SELECT* 1_4"".valorrealizado, ""*SELECT* 1_4"".percrealizado, ((""*SELECT* 1_4"".pontos)::double precision), ""*SELECT* 1_4"".comissao
576. 0.018 35,614.715 ↑ 1.5 4 1

Append (cost=224.15..931.39 rows=6 width=212) (actual time=12,110.704..35,614.715 rows=4 loops=1)

577. 0.013 12,110.707 ↑ 1.0 1 1

Subquery Scan on "*SELECT* 1_4" (cost=224.15..224.25 rows=1 width=212) (actual time=12,110.702..12,110.707 rows=1 loops=1)

578. 12,110.520 12,110.694 ↑ 1.0 1 1

CTE Scan on saldofin (cost=224.15..224.24 rows=1 width=236) (actual time=12,110.689..12,110.694 rows=1 loops=1)

579.          

Initplan (for CTE Scan)

580. 0.058 0.058 ↑ 1.0 1 1

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_14 (cost=0.42..6.45 rows=1 width=6) (actual time=0.056..0.058 rows=1 loops=1)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 4))
  • Filter: (idtipometa = 1)
581. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_15 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 4) AND (idtipometa = 1))
582. 0.032 0.032 ↑ 1.0 1 1

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_15 (cost=0.42..6.45 rows=1 width=6) (actual time=0.030..0.032 rows=1 loops=1)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 4))
  • Filter: (idtipometa = 1)
583. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_16 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 4) AND (idtipometa = 1))
584. 0.011 0.011 ↑ 1.0 1 1

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_16 (cost=0.42..6.45 rows=1 width=6) (actual time=0.009..0.011 rows=1 loops=1)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 4))
  • Filter: (idtipometa = 1)
585. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_17 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 4) AND (idtipometa = 1))
586. 0.011 0.011 ↑ 1.0 1 1

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_17 (cost=0.42..6.45 rows=1 width=6) (actual time=0.010..0.011 rows=1 loops=1)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 4))
  • Filter: (idtipometa = 1)
587. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_18 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 4) AND (idtipometa = 1))
588. 0.011 0.011 ↑ 1.0 1 1

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_18 (cost=0.42..6.45 rows=1 width=6) (actual time=0.009..0.011 rows=1 loops=1)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 4))
  • Filter: (idtipometa = 1)
589. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_19 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 4) AND (idtipometa = 1))
590. 0.012 0.012 ↑ 1.0 1 1

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_19 (cost=0.42..6.45 rows=1 width=6) (actual time=0.009..0.012 rows=1 loops=1)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 4))
  • Filter: (idtipometa = 1)
591. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_20 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 4) AND (idtipometa = 1))
592. 0.002 0.010 ↓ 0.0 0 1

Limit (cost=0.00..0.03 rows=1 width=4) (actual time=0.009..0.010 rows=0 loops=1)

593. 0.008 0.008 ↓ 0.0 0 1

CTE Scan on excecao excecao_3 (cost=0.00..0.03 rows=1 width=4) (actual time=0.007..0.008 rows=0 loops=1)

  • Filter: ((idfilial = 10,002) AND (anomes = 201,909) AND (idmeta = 4))
  • Rows Removed by Filter: 1
594. 0.000 0.000 ↓ 0.0 0

Bitmap Heap Scan on ccg_gerente_faixa_salario f_11 (cost=47.58..54.87 rows=3 width=5) (never executed)

  • Recheck Cond: (($291 >= (dofaturamento)::numeric) AND ($292 <= (atefaturamento)::numeric) AND (anomes = 201,909))
595.          

Initplan (for Bitmap Heap Scan)

596. 0.000 0.000 ↓ 0.0 0

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

597. 0.000 0.000 ↓ 0.0 0

CTE Scan on realizado realizado_13 (cost=0.00..0.28 rows=14 width=32) (never executed)

598. 0.000 0.000 ↓ 0.0 0

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

599. 0.000 0.000 ↓ 0.0 0

CTE Scan on realizado realizado_14 (cost=0.00..0.28 rows=14 width=32) (never executed)

600. 0.000 0.000 ↓ 0.0 0

Bitmap Index Scan on pk_ccg_gerente_faixa_salario (cost=0.00..46.92 rows=3 width=0) (never executed)

  • Index Cond: (($291 >= (dofaturamento)::numeric) AND ($292 <= (atefaturamento)::numeric) AND (anomes = 201,909))
601. 0.000 0.000 ↓ 0.0 0

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_20 (cost=0.42..6.45 rows=1 width=4) (never executed)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 4))
  • Filter: (idtipometa = 1)
602. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_21 (cost=0.00..4.99 rows=1 width=3) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 4) AND (idtipometa = 1))
603. 0.017 0.017 ↑ 1.0 1 1

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_21 (cost=0.42..6.45 rows=1 width=6) (actual time=0.015..0.017 rows=1 loops=1)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 4))
  • Filter: (idtipometa = 1)
604. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_22 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 4) AND (idtipometa = 1))
605. 0.012 0.012 ↑ 1.0 1 1

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_22 (cost=0.42..6.45 rows=1 width=6) (actual time=0.010..0.012 rows=1 loops=1)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 4))
  • Filter: (idtipometa = 1)
606. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_23 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 4) AND (idtipometa = 1))
607. 0.000 0.000 ↓ 0.0 0

Bitmap Heap Scan on ccg_gerente_faixa_salario f_12 (cost=47.58..54.87 rows=3 width=5) (never executed)

  • Recheck Cond: (($300 >= (dofaturamento)::numeric) AND ($301 <= (atefaturamento)::numeric) AND (anomes = 201,909))
608.          

Initplan (for Bitmap Heap Scan)

609. 0.000 0.000 ↓ 0.0 0

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

610. 0.000 0.000 ↓ 0.0 0

CTE Scan on realizado realizado_15 (cost=0.00..0.28 rows=14 width=32) (never executed)

611. 0.000 0.000 ↓ 0.0 0

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

612. 0.000 0.000 ↓ 0.0 0

CTE Scan on realizado realizado_16 (cost=0.00..0.28 rows=14 width=32) (never executed)

613. 0.000 0.000 ↓ 0.0 0

Bitmap Index Scan on pk_ccg_gerente_faixa_salario (cost=0.00..46.92 rows=3 width=0) (never executed)

  • Index Cond: (($300 >= (dofaturamento)::numeric) AND ($301 <= (atefaturamento)::numeric) AND (anomes = 201,909))
614. 0.000 0.000 ↓ 0.0 0

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_23 (cost=0.42..6.45 rows=1 width=4) (never executed)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 4))
  • Filter: (idtipometa = 1)
615. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_24 (cost=0.00..4.99 rows=1 width=3) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 4) AND (idtipometa = 1))
616. 0.010 12,421.213 ↑ 2.0 1 1

Subquery Scan on "*SELECT* 2_4" (cost=235.58..235.75 rows=2 width=212) (actual time=12,421.205..12,421.213 rows=1 loops=1)

617. 12,420.996 12,421.203 ↑ 2.0 1 1

CTE Scan on semgiro (cost=235.58..235.72 rows=2 width=184) (actual time=12,421.197..12,421.203 rows=1 loops=1)

618.          

Initplan (for CTE Scan)

619. 0.057 0.057 ↑ 1.0 1 1

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_24 (cost=0.42..6.45 rows=1 width=6) (actual time=0.055..0.057 rows=1 loops=1)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 9))
  • Filter: (idtipometa = 1)
620. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_25 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 9) AND (idtipometa = 1))
621. 0.029 0.029 ↑ 1.0 1 1

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_25 (cost=0.42..6.45 rows=1 width=6) (actual time=0.027..0.029 rows=1 loops=1)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 9))
  • Filter: (idtipometa = 1)
622. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_26 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 9) AND (idtipometa = 1))
623. 0.024 0.024 ↑ 1.0 1 1

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_26 (cost=0.42..6.45 rows=1 width=6) (actual time=0.022..0.024 rows=1 loops=1)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 9))
  • Filter: (idtipometa = 1)
624. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_27 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 9) AND (idtipometa = 1))
625. 0.019 0.019 ↑ 1.0 1 1

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_27 (cost=0.42..6.45 rows=1 width=6) (actual time=0.017..0.019 rows=1 loops=1)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 9))
  • Filter: (idtipometa = 1)
626. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_28 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 9) AND (idtipometa = 1))
627. 0.019 0.019 ↑ 1.0 1 1

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_28 (cost=0.42..6.45 rows=1 width=6) (actual time=0.017..0.019 rows=1 loops=1)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 9))
  • Filter: (idtipometa = 1)
628. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_29 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 9) AND (idtipometa = 1))
629. 0.003 0.011 ↓ 0.0 0 1

Limit (cost=0.00..0.03 rows=1 width=4) (actual time=0.010..0.011 rows=0 loops=1)

630. 0.008 0.008 ↓ 0.0 0 1

CTE Scan on excecao excecao_4 (cost=0.00..0.03 rows=1 width=4) (actual time=0.007..0.008 rows=0 loops=1)

  • Filter: ((idfilial = 10,002) AND (anomes = 201,909) AND (idmeta = 9))
  • Rows Removed by Filter: 1
631. 0.000 0.000 ↓ 0.0 0

Bitmap Heap Scan on ccg_gerente_faixa_salario f_13 (cost=47.58..54.87 rows=3 width=5) (never executed)

  • Recheck Cond: (($316 >= (dofaturamento)::numeric) AND ($317 <= (atefaturamento)::numeric) AND (anomes = 201,909))
632.          

Initplan (for Bitmap Heap Scan)

633. 0.000 0.000 ↓ 0.0 0

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

634. 0.000 0.000 ↓ 0.0 0

CTE Scan on realizado realizado_17 (cost=0.00..0.28 rows=14 width=32) (never executed)

635. 0.000 0.000 ↓ 0.0 0

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

636. 0.000 0.000 ↓ 0.0 0

CTE Scan on realizado realizado_18 (cost=0.00..0.28 rows=14 width=32) (never executed)

637. 0.000 0.000 ↓ 0.0 0

Bitmap Index Scan on pk_ccg_gerente_faixa_salario (cost=0.00..46.92 rows=3 width=0) (never executed)

  • Index Cond: (($316 >= (dofaturamento)::numeric) AND ($317 <= (atefaturamento)::numeric) AND (anomes = 201,909))
638. 0.000 0.000 ↓ 0.0 0

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_29 (cost=0.42..6.45 rows=1 width=4) (never executed)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 9))
  • Filter: (idtipometa = 1)
639. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_30 (cost=0.00..4.99 rows=1 width=3) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 9) AND (idtipometa = 1))
640. 0.024 0.024 ↑ 1.0 1 1

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_30 (cost=0.42..6.45 rows=1 width=6) (actual time=0.021..0.024 rows=1 loops=1)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 9))
  • Filter: (idtipometa = 1)
641. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_31 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 9) AND (idtipometa = 1))
642. 0.024 0.024 ↑ 1.0 1 1

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_31 (cost=0.42..6.45 rows=1 width=6) (actual time=0.022..0.024 rows=1 loops=1)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 9))
  • Filter: (idtipometa = 1)
643. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_32 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 9) AND (idtipometa = 1))
644. 0.000 0.000 ↓ 0.0 0

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_32 (cost=0.42..6.45 rows=1 width=6) (never executed)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 9))
  • Filter: (idtipometa = 1)
645. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_33 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 9) AND (idtipometa = 1))
646. 0.000 0.000 ↓ 0.0 0

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_33 (cost=0.42..6.45 rows=1 width=6) (never executed)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 9))
  • Filter: (idtipometa = 1)
647. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_34 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 9) AND (idtipometa = 1))
648. 0.000 0.000 ↓ 0.0 0

Bitmap Heap Scan on ccg_gerente_faixa_salario f_14 (cost=47.58..54.87 rows=3 width=5) (never executed)

  • Recheck Cond: (($329 >= (dofaturamento)::numeric) AND ($330 <= (atefaturamento)::numeric) AND (anomes = 201,909))
649.          

Initplan (for Bitmap Heap Scan)

650. 0.000 0.000 ↓ 0.0 0

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

651. 0.000 0.000 ↓ 0.0 0

CTE Scan on realizado realizado_19 (cost=0.00..0.28 rows=14 width=32) (never executed)

652. 0.000 0.000 ↓ 0.0 0

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

653. 0.000 0.000 ↓ 0.0 0

CTE Scan on realizado realizado_20 (cost=0.00..0.28 rows=14 width=32) (never executed)

654. 0.000 0.000 ↓ 0.0 0

Bitmap Index Scan on pk_ccg_gerente_faixa_salario (cost=0.00..46.92 rows=3 width=0) (never executed)

  • Index Cond: (($329 >= (dofaturamento)::numeric) AND ($330 <= (atefaturamento)::numeric) AND (anomes = 201,909))
655. 0.000 0.000 ↓ 0.0 0

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_34 (cost=0.42..6.45 rows=1 width=4) (never executed)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 9))
  • Filter: (idtipometa = 1)
656. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_35 (cost=0.00..4.99 rows=1 width=3) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 9) AND (idtipometa = 1))
657. 0.013 11,069.093 ↑ 1.0 1 1

Subquery Scan on "*SELECT* 3_5" (cost=258.46..258.57 rows=1 width=212) (actual time=11,069.087..11,069.093 rows=1 loops=1)

658. 11,068.889 11,069.080 ↑ 1.0 1 1

CTE Scan on foralinha (cost=258.46..258.55 rows=1 width=236) (actual time=11,069.076..11,069.080 rows=1 loops=1)

659.          

Initplan (for CTE Scan)

660. 0.050 0.050 ↑ 1.0 1 1

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_35 (cost=0.42..6.45 rows=1 width=6) (actual time=0.048..0.050 rows=1 loops=1)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 8))
  • Filter: (idtipometa = 1)
661. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_36 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 8) AND (idtipometa = 1))
662. 0.028 0.028 ↑ 1.0 1 1

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_36 (cost=0.42..6.45 rows=1 width=6) (actual time=0.026..0.028 rows=1 loops=1)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 8))
  • Filter: (idtipometa = 1)
663. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_37 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 8) AND (idtipometa = 1))
664. 0.011 0.011 ↑ 1.0 1 1

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_37 (cost=0.42..6.45 rows=1 width=6) (actual time=0.009..0.011 rows=1 loops=1)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 8))
  • Filter: (idtipometa = 1)
665. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_38 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 8) AND (idtipometa = 1))
666. 0.011 0.011 ↑ 1.0 1 1

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_38 (cost=0.42..6.45 rows=1 width=6) (actual time=0.009..0.011 rows=1 loops=1)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 8))
  • Filter: (idtipometa = 1)
667. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_39 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 8) AND (idtipometa = 1))
668. 0.011 0.011 ↑ 1.0 1 1

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_39 (cost=0.42..6.45 rows=1 width=6) (actual time=0.009..0.011 rows=1 loops=1)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 8))
  • Filter: (idtipometa = 1)
669. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_40 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 8) AND (idtipometa = 1))
670. 0.024 0.024 ↑ 1.0 1 1

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_40 (cost=0.42..6.45 rows=1 width=6) (actual time=0.022..0.024 rows=1 loops=1)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 8))
  • Filter: (idtipometa = 1)
671. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_41 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 8) AND (idtipometa = 1))
672. 0.012 0.012 ↑ 1.0 1 1

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_41 (cost=0.42..6.45 rows=1 width=6) (actual time=0.010..0.012 rows=1 loops=1)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 8))
  • Filter: (idtipometa = 1)
673. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_42 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 8) AND (idtipometa = 1))
674. 0.002 0.009 ↓ 0.0 0 1

Limit (cost=0.00..0.03 rows=1 width=4) (actual time=0.009..0.009 rows=0 loops=1)

675. 0.007 0.007 ↓ 0.0 0 1

CTE Scan on excecao excecao_5 (cost=0.00..0.03 rows=1 width=4) (actual time=0.006..0.007 rows=0 loops=1)

  • Filter: ((idfilial = 10,002) AND (anomes = 201,909) AND (idmeta = 8))
  • Rows Removed by Filter: 1
676. 0.000 0.000 ↓ 0.0 0

Bitmap Heap Scan on ccg_gerente_faixa_salario f_15 (cost=47.58..54.87 rows=3 width=5) (never executed)

  • Recheck Cond: (($349 >= (dofaturamento)::numeric) AND ($350 <= (atefaturamento)::numeric) AND (anomes = 201,909))
677.          

Initplan (for Bitmap Heap Scan)

678. 0.000 0.000 ↓ 0.0 0

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

679. 0.000 0.000 ↓ 0.0 0

CTE Scan on realizado realizado_21 (cost=0.00..0.28 rows=14 width=32) (never executed)

680. 0.000 0.000 ↓ 0.0 0

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

681. 0.000 0.000 ↓ 0.0 0

CTE Scan on realizado realizado_22 (cost=0.00..0.28 rows=14 width=32) (never executed)

682. 0.000 0.000 ↓ 0.0 0

Bitmap Index Scan on pk_ccg_gerente_faixa_salario (cost=0.00..46.92 rows=3 width=0) (never executed)

  • Index Cond: (($349 >= (dofaturamento)::numeric) AND ($350 <= (atefaturamento)::numeric) AND (anomes = 201,909))
683. 0.000 0.000 ↓ 0.0 0

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_42 (cost=0.42..6.45 rows=1 width=4) (never executed)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 8))
  • Filter: (idtipometa = 1)
684. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_43 (cost=0.00..4.99 rows=1 width=3) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 8) AND (idtipometa = 1))
685. 0.012 0.012 ↑ 1.0 1 1

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_43 (cost=0.42..6.45 rows=1 width=6) (actual time=0.010..0.012 rows=1 loops=1)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 8))
  • Filter: (idtipometa = 1)
686. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_44 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 8) AND (idtipometa = 1))
687. 0.012 0.012 ↑ 1.0 1 1

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_44 (cost=0.42..6.45 rows=1 width=6) (actual time=0.009..0.012 rows=1 loops=1)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 8))
  • Filter: (idtipometa = 1)
688. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_45 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 8) AND (idtipometa = 1))
689. 0.011 0.011 ↑ 1.0 1 1

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_45 (cost=0.42..6.45 rows=1 width=6) (actual time=0.009..0.011 rows=1 loops=1)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 8))
  • Filter: (idtipometa = 1)
690. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_46 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 8) AND (idtipometa = 1))
691. 0.000 0.000 ↓ 0.0 0

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_46 (cost=0.42..6.45 rows=1 width=6) (never executed)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 8))
  • Filter: (idtipometa = 1)
692. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_47 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 8) AND (idtipometa = 1))
693. 0.000 0.000 ↓ 0.0 0

Bitmap Heap Scan on ccg_gerente_faixa_salario f_16 (cost=47.58..54.87 rows=3 width=5) (never executed)

  • Recheck Cond: (($362 >= (dofaturamento)::numeric) AND ($363 <= (atefaturamento)::numeric) AND (anomes = 201,909))
694.          

Initplan (for Bitmap Heap Scan)

695. 0.000 0.000 ↓ 0.0 0

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

696. 0.000 0.000 ↓ 0.0 0

CTE Scan on realizado realizado_23 (cost=0.00..0.28 rows=14 width=32) (never executed)

697. 0.000 0.000 ↓ 0.0 0

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

698. 0.000 0.000 ↓ 0.0 0

CTE Scan on realizado realizado_24 (cost=0.00..0.28 rows=14 width=32) (never executed)

699. 0.000 0.000 ↓ 0.0 0

Bitmap Index Scan on pk_ccg_gerente_faixa_salario (cost=0.00..46.92 rows=3 width=0) (never executed)

  • Index Cond: (($362 >= (dofaturamento)::numeric) AND ($363 <= (atefaturamento)::numeric) AND (anomes = 201,909))
700. 0.000 0.000 ↓ 0.0 0

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_47 (cost=0.42..6.45 rows=1 width=4) (never executed)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 8))
  • Filter: (idtipometa = 1)
701. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_48 (cost=0.00..4.99 rows=1 width=3) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 8) AND (idtipometa = 1))
702. 0.015 13.677 ↑ 1.0 1 1

Subquery Scan on "*SELECT* 4_5" (cost=212.71..212.80 rows=1 width=212) (actual time=13.670..13.677 rows=1 loops=1)

703. 13.355 13.662 ↑ 1.0 1 1

CTE Scan on auditoria (cost=212.71..212.78 rows=1 width=236) (actual time=13.658..13.662 rows=1 loops=1)

704.          

Initplan (for CTE Scan)

705. 0.158 0.158 ↑ 1.0 1 1

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_48 (cost=0.42..6.45 rows=1 width=6) (actual time=0.154..0.158 rows=1 loops=1)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 7))
  • Filter: (idtipometa = 1)
706. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_49 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 7) AND (idtipometa = 1))
707. 0.019 0.019 ↑ 1.0 1 1

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_49 (cost=0.42..6.45 rows=1 width=6) (actual time=0.016..0.019 rows=1 loops=1)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 7))
  • Filter: (idtipometa = 1)
708. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_50 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 7) AND (idtipometa = 1))
709. 0.012 0.012 ↑ 1.0 1 1

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_50 (cost=0.42..6.45 rows=1 width=6) (actual time=0.010..0.012 rows=1 loops=1)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 7))
  • Filter: (idtipometa = 1)
710. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_51 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 7) AND (idtipometa = 1))
711. 0.040 0.040 ↑ 1.0 1 1

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_51 (cost=0.42..6.45 rows=1 width=6) (actual time=0.037..0.040 rows=1 loops=1)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 7))
  • Filter: (idtipometa = 1)
712. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_52 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 7) AND (idtipometa = 1))
713. 0.005 0.016 ↓ 0.0 0 1

Limit (cost=0.00..0.03 rows=1 width=4) (actual time=0.015..0.016 rows=0 loops=1)

714. 0.011 0.011 ↓ 0.0 0 1

CTE Scan on excecao excecao_6 (cost=0.00..0.03 rows=1 width=4) (actual time=0.011..0.011 rows=0 loops=1)

  • Filter: ((idfilial = 10,002) AND (anomes = 201,909) AND (idmeta = 7))
  • Rows Removed by Filter: 1
715. 0.000 0.000 ↓ 0.0 0

Bitmap Heap Scan on ccg_gerente_faixa_salario f_17 (cost=47.58..54.87 rows=3 width=5) (never executed)

  • Recheck Cond: (($376 >= (dofaturamento)::numeric) AND ($377 <= (atefaturamento)::numeric) AND (anomes = 201,909))
716.          

Initplan (for Bitmap Heap Scan)

717. 0.000 0.000 ↓ 0.0 0

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

718. 0.000 0.000 ↓ 0.0 0

CTE Scan on realizado realizado_25 (cost=0.00..0.28 rows=14 width=32) (never executed)

719. 0.000 0.000 ↓ 0.0 0

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

720. 0.000 0.000 ↓ 0.0 0

CTE Scan on realizado realizado_26 (cost=0.00..0.28 rows=14 width=32) (never executed)

721. 0.000 0.000 ↓ 0.0 0

Bitmap Index Scan on pk_ccg_gerente_faixa_salario (cost=0.00..46.92 rows=3 width=0) (never executed)

  • Index Cond: (($376 >= (dofaturamento)::numeric) AND ($377 <= (atefaturamento)::numeric) AND (anomes = 201,909))
722. 0.000 0.000 ↓ 0.0 0

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_52 (cost=0.42..6.45 rows=1 width=4) (never executed)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 7))
  • Filter: (idtipometa = 1)
723. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_53 (cost=0.00..4.99 rows=1 width=3) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 7) AND (idtipometa = 1))
724. 0.030 0.030 ↑ 1.0 1 1

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_53 (cost=0.42..6.45 rows=1 width=6) (actual time=0.027..0.030 rows=1 loops=1)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 7))
  • Filter: (idtipometa = 1)
725. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_54 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 7) AND (idtipometa = 1))
726. 0.019 0.019 ↑ 1.0 1 1

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_54 (cost=0.42..6.45 rows=1 width=6) (actual time=0.016..0.019 rows=1 loops=1)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 7))
  • Filter: (idtipometa = 1)
727. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_55 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 7) AND (idtipometa = 1))
728. 0.013 0.013 ↑ 1.0 1 1

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_55 (cost=0.42..6.45 rows=1 width=6) (actual time=0.010..0.013 rows=1 loops=1)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 7))
  • Filter: (idtipometa = 1)
729. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_56 (cost=0.00..4.99 rows=1 width=7) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 7) AND (idtipometa = 1))
730. 0.000 0.000 ↓ 0.0 0

Bitmap Heap Scan on ccg_gerente_faixa_salario f_18 (cost=47.58..54.87 rows=3 width=5) (never executed)

  • Recheck Cond: (($387 >= (dofaturamento)::numeric) AND ($388 <= (atefaturamento)::numeric) AND (anomes = 201,909))
731.          

Initplan (for Bitmap Heap Scan)

732. 0.000 0.000 ↓ 0.0 0

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

733. 0.000 0.000 ↓ 0.0 0

CTE Scan on realizado realizado_27 (cost=0.00..0.28 rows=14 width=32) (never executed)

734. 0.000 0.000 ↓ 0.0 0

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

735. 0.000 0.000 ↓ 0.0 0

CTE Scan on realizado realizado_28 (cost=0.00..0.28 rows=14 width=32) (never executed)

736. 0.000 0.000 ↓ 0.0 0

Bitmap Index Scan on pk_ccg_gerente_faixa_salario (cost=0.00..46.92 rows=3 width=0) (never executed)

  • Index Cond: (($387 >= (dofaturamento)::numeric) AND ($388 <= (atefaturamento)::numeric) AND (anomes = 201,909))
737. 0.000 0.000 ↓ 0.0 0

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_56 (cost=0.42..6.45 rows=1 width=4) (never executed)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 7))
  • Filter: (idtipometa = 1)
738. 0.000 0.000 ↓ 0.0 0

Seq Scan on ccg_gerente_metas gm_57 (cost=0.00..4.99 rows=1 width=3) (never executed)

  • Filter: ((anomes = 201,909) AND (idmeta = 7) AND (idtipometa = 1))
739. 0.004 0.007 ↓ 0.0 0 1

Subquery Scan on "*SELECT* 5_3" (cost=0.00..0.00 rows=1 width=212) (actual time=0.006..0.007 rows=0 loops=1)

740. 0.003 0.003 ↓ 0.0 0 1

Result (cost=0.00..0.00 rows=0 width=236) (actual time=0.003..0.003 rows=0 loops=1)

  • One-Time Filter: false
741.          

CTE margem

742. 0.150 15.532 ↑ 2.8 12 1

HashAggregate (cost=260.05..260.39 rows=34 width=236) (actual time=15.456..15.532 rows=12 loops=1)

  • Group Key: ('Margem'::text), ('Faturamento Bruto'::text), (1), (0), (0), ""*SELECT* 1_5"".valormeta, ""*SELECT* 1_5"".valorrealizado, ""*SELECT* 1_5"".percrealizado, ((0)::numeric), (((0))::numeric)
743. 0.030 15.382 ↑ 2.8 12 1

Append (cost=188.22..259.20 rows=34 width=236) (actual time=11.160..15.382 rows=12 loops=1)

744. 0.083 11.180 ↑ 1.8 11 1

HashAggregate (cost=188.22..188.47 rows=20 width=236) (actual time=11.156..11.180 rows=11 loops=1)

  • Group Key: ('Margem'::text), ('Faturamento Bruto'::text), (1), (0), (0), ""*SELECT* 1_5"".valormeta, ""*SELECT* 1_5"".valorrealizado, ""*SELECT* 1_5"".percrealizado, ((0)::numeric), (0)
745. 0.057 11.097 ↑ 1.8 11 1

Append (cost=6.82..187.72 rows=20 width=208) (actual time=1.486..11.097 rows=11 loops=1)

746. 0.010 1.490 ↑ 1.0 1 1

Subquery Scan on "*SELECT* 1_5" (cost=6.82..6.90 rows=1 width=208) (actual time=1.483..1.490 rows=1 loops=1)

747. 0.038 1.480 ↑ 1.0 1 1

Subquery Scan on tb_23 (cost=6.82..6.88 rows=1 width=180) (actual time=1.475..1.480 rows=1 loops=1)

748. 0.737 1.442 ↑ 1.0 1 1

Aggregate (cost=6.82..6.83 rows=1 width=128) (actual time=1.439..1.442 rows=1 loops=1)

749.          

Initplan (for Aggregate)

750. 0.004 0.004 ↑ 1.0 1 1

CTE Scan on metavenda metavenda_4 (cost=0.00..0.02 rows=1 width=32) (actual time=0.002..0.004 rows=1 loops=1)

751. 0.091 0.091 ↑ 1.0 1 1

Index Scan using ccg_gerente_metas_individual_idx on ccg_gerente_metas_individual gmi_57 (cost=0.42..6.45 rows=1 width=6) (actual time=0.088..0.091 rows=1 loops=1)

  • Index Cond: (((idfilial)::integer = 10,002) AND (anomes = 201,909) AND (idmeta = 3))
  • Filter: (idtipometa = 0)
752. 0.610 0.610 ↓ 22.7 318 1

CTE Scan on realizado realizado_31 (cost=0.00..0.28 rows=14 width=64) (actual time=0.003..0.610 rows=318 loops=1)

753. 0.027 1.082 ↑ 1.0 1 1

Subquery Scan on tb_24 (cost=0.34..0.39 rows=1 width=208) (actual time=1.079..1.082 rows=1 loops=1)

754. 0.509 1.055 ↑ 1.0 1 1

Aggregate (cost=0.34..0.35 rows=1 width=64) (actual time=1.053..1.055 rows=1 loops=1)

755.          

Initplan (for Aggregate)

756. 0.003 0.003 ↑ 1.0 1 1

CTE Scan on metavenda metavenda_5 (cost=0.00..0.02 rows=1 width=32) (actual time=0.002..0.003 rows=1 loops=1)

757. 0.543 0.543 ↓ 22.7 318 1

CTE Scan on realizado realizado_32 (cost=0.00..0.28 rows=14 width=32) (actual time=0.002..0.543 rows=318 loops=1)

758. 0.015 1.117 ↑ 1.0 1 1

Subquery Scan on "*SELECT* 3_6" (cost=0.32..0.36 rows=1 width=208) (actual time=1.112..1.117 rows=1 loops=1)

759. 0.030 1.102 ↑ 1.0 1 1

Subquery Scan on tb_25 (cost=0.32..0.34 rows=1 width=124) (actual time=1.098..1.102 rows=1 loops=1)

760. 0.651 1.072 ↑ 1.0 1 1

Aggregate (cost=0.32..0.33 rows=1 width=32) (actual time=1.070..1.072 rows=1 loops=1)

761. 0.421 0.421 ↓ 22.7 318 1

CTE Scan on realizado realizado_33 (cost=0.00..0.28 rows=14 width=32) (actual time=0.002..0.421 rows=318 loops=1)

762. 0.011 0.997 ↑ 1.0 1 1

Subquery Scan on "*SELECT* 4_6" (cost=0.32..0.36 rows=1 width=208) (actual time=0.992..0.997 rows=1 loops=1)

763. 0.012 0.986 ↑ 1.0 1 1

Subquery Scan on tb_26 (cost=0.32..0.34 rows=1 width=124) (actual time=0.983..0.986 rows=1 loops=1)

764. 0.572 0.974 ↑ 1.0 1 1

Aggregate (cost=0.32..0.33 rows=1 width=32) (actual time=0.972..0.974 rows=1 loops=1)

765. 0.402 0.402 ↓ 22.7 318 1

CTE Scan on realizado realizado_34 (cost=0.00..0.28 rows=14 width=32) (actual time=0.003..0.402 rows=318 loops=1)

766. 0.004 0.007 ↓ 0.0 0 1

Subquery Scan on "*SELECT* 5_4" (cost=0.00..0.00 rows=1 width=208) (actual time=0.006..0.007 rows=0 loops=1)

767. 0.003 0.003 ↓ 0.0 0 1

Result (cost=0.00..0.00 rows=0 width=180) (actual time=0.002..0.003 rows=0 loops=1)

  • One-Time Filter: false
768. 0.012 0.022 ↑ 1.0 1 1

Subquery Scan on "*SELECT* 6_1" (cost=0.00..0.03 rows=1 width=208) (actual time=0.017..0.022 rows=1 loops=1)

769. 0.010 0.010 ↑ 1.0 1 1

Result (cost=0.00..0.01 rows=1 width=96) (actual time=0.006..0.010 rows=1 loops=1)

770. 0.019 6.325 ↑ 2.3 6 1

Subquery Scan on "*SELECT* 7_2" (cost=178.88..179.58 rows=14 width=208) (actual time=6.268..6.325 rows=6 loops=1)

771. 0.063 6.306 ↑ 2.3 6 1

Subquery Scan on tb_27 (cost=178.88..179.44 rows=14 width=184) (actual time=6.261..6.306 rows=6 loops=1)

772. 0.044 6.243 ↑ 2.3 6 1

Sort (cost=178.88..178.91 rows=14 width=168) (actual time=6.236..6.243 rows=6 loops=1)

  • Sort Key: tb_28.descricao
  • Sort Method: quicksort Memory: 25kB
773. 0.026 6.199 ↑ 2.3 6 1

Subquery Scan on tb_28 (cost=89.72..178.61 rows=14 width=168) (actual time=5.457..6.199 rows=6 loops=1)

774. 0.029 6.173 ↑ 2.3 6 1

Subquery Scan on tb_29 (cost=89.72..178.40 rows=14 width=488) (actual time=5.448..6.173 rows=6 loops=1)

775.          

Initplan (for Subquery Scan)

776. 0.013 0.013 ↑ 1.0 1 1

CTE Scan on verbaextra (cost=0.00..0.02 rows=1 width=32) (actual time=0.010..0.013 rows=1 loops=1)

777. 0.758 6.131 ↑ 2.3 6 1

GroupAggregate (cost=89.70..178.21 rows=14 width=278) (actual time=5.420..6.131 rows=6 loops=1)

  • Group Key: r_2.idgrupo, ggc.descricao, r_2.anomes, r_2.uf, ((SubPlan 273))
778. 1.379 5.373 ↓ 22.7 318 1

Sort (cost=89.70..89.74 rows=14 width=150) (actual time=5.043..5.373 rows=318 loops=1)

  • Sort Key: r_2.idgrupo, ggc.descricao, r_2.anomes, r_2.uf, ((SubPlan 273))
  • Sort Method: quicksort Memory: 49kB
779. 1.438 3.994 ↓ 22.7