explain.depesz.com

PostgreSQL's explain analyze made readable

Result: OUQj

Settings
# exclusive inclusive rows x rows loops node
1. 0.011 382,324.574 ↓ 0.0 0 1

Sort (cost=5,839,885.25..5,839,885.34 rows=37 width=952) (actual time=382,324.574..382,324.574 rows=0 loops=1)

  • Sort Key: abt.referencia_bico, (min(COALESCE((min((b_1.abt_vl_encerrante - b_1.abt_vl_abastecimento))), (COALESCE(min(abt.encerrante_inicial_abt) FILTER (WHERE ((abt.data_abt >= $2) OR (NOT (alternatives: SubPlan 3 or hashed SubPlan 4)))), '0'::numeric)))) OVER (?)), (max(CASE WHEN ((((max(abt.encerrante_final_abt)) - (COALESCE(min(abt.encerrante_inicial_abt) FILTER (WHERE ((abt.data_abt >= $2) OR (NOT (alternatives: SubPlan 3 or hashed SubPlan 4)))), '0'::numeric))) - (sum(abt.quantidade_afericao))) > (COALESCE(sum(b.abt_vl_volume_abastecido), '0'::numeric))) THEN ((max(abt.encerrante_final_abt)) - (COALESCE(sum(b.abt_vl_volume_abastecido), '0'::numeric))) ELSE (max(abt.encerrante_final_abt)) END) OVER (?)), abt.preco_bomba
  • Sort Method: quicksort Memory: 25kB
2.          

CTE caixa_meta

3. 0.003 0.245 ↑ 1.0 1 1

Aggregate (cost=2.65..2.66 rows=1 width=24) (actual time=0.245..0.245 rows=1 loops=1)

4. 0.242 0.242 ↓ 0.0 0 1

Index Scan using caixa_pkey on caixa cai_6 (cost=0.42..2.64 rows=1 width=12) (actual time=0.242..0.242 rows=0 loops=1)

  • Index Cond: (cai_cd_caixa = 1353808)
5. 0.006 382,324.563 ↓ 0.0 0 1

WindowAgg (cost=5,839,878.01..5,839,881.62 rows=37 width=952) (actual time=382,324.563..382,324.563 rows=0 loops=1)

6. 0.009 382,324.557 ↓ 0.0 0 1

Sort (cost=5,839,878.01..5,839,878.11 rows=37 width=728) (actual time=382,324.557..382,324.557 rows=0 loops=1)

  • Sort Key: abt.bico, abt.substituicao, abt.produto
  • Sort Method: quicksort Memory: 25kB
7. 0.002 382,324.548 ↓ 0.0 0 1

Group (cost=5,839,874.55..5,839,877.05 rows=37 width=728) (actual time=382,324.548..382,324.548 rows=0 loops=1)

  • Group Key: abt.referencia_bico, abt.descricao_produto, (sum(abt.quantidade_afericao)), (sum(abt.qtd_abastecimento)), abt.preco_bomba, (CASE WHEN (sum((abt.valor_venda_item - abt.valor_abastecimento)) > '0'::numeric) THEN sum((abt.valor_venda_item - abt.valor_abastecimento)) ELSE '0'::numeric END), (CASE WHEN (sum((abt.valor_venda_item - abt.valor_abastecimento)) < '0'::numeric) THEN abs(sum((abt.valor_venda_item - abt.valor_abastecimento))) ELSE '0'::numeric END), (COALESCE(sum(abt.valor_venda_item), '0'::numeric)), abt.substituicao, abt.descricao_bomba, (COALESCE(min(abt.encerrante_inicial_abt) FILTER (WHERE ((abt.data_abt >= $2) OR (NOT (alternatives: SubPlan 3 or hashed SubPlan 4)))), '0'::numeric)), (COALESCE(sum(b_1.abt_vl_volume_abastecido), '0'::numeric)), (max(abt.encerrante_final_abt)), (COALESCE(sum(b.abt_vl_volume_abastecido), '0'::numeric)), abt.bico, abt.produto, (((((abt.bico)::character varying)::text || ((abt.substituicao)::character varying)::text) || ((abt.produto)::character varying)::text)), (min((b_1.abt_vl_encerrante - b_1.abt_vl_abastecimento)))
8. 0.009 382,324.546 ↓ 0.0 0 1

Sort (cost=5,839,874.55..5,839,874.65 rows=37 width=728) (actual time=382,324.546..382,324.546 rows=0 loops=1)

  • Sort Key: abt.referencia_bico, abt.descricao_produto, (sum(abt.quantidade_afericao)), (sum(abt.qtd_abastecimento)), abt.preco_bomba, (CASE WHEN (sum((abt.valor_venda_item - abt.valor_abastecimento)) > '0'::numeric) THEN sum((abt.valor_venda_item - abt.valor_abastecimento)) ELSE '0'::numeric END), (CASE WHEN (sum((abt.valor_venda_item - abt.valor_abastecimento)) < '0'::numeric) THEN abs(sum((abt.valor_venda_item - abt.valor_abastecimento))) ELSE '0'::numeric END), (COALESCE(sum(abt.valor_venda_item), '0'::numeric)), abt.substituicao, abt.descricao_bomba, (COALESCE(min(abt.encerrante_inicial_abt) FILTER (WHERE ((abt.data_abt >= $2) OR (NOT (alternatives: SubPlan 3 or hashed SubPlan 4)))), '0'::numeric)), (COALESCE(sum(b_1.abt_vl_volume_abastecido), '0'::numeric)), (max(abt.encerrante_final_abt)), (COALESCE(sum(b.abt_vl_volume_abastecido), '0'::numeric)), abt.bico, abt.produto, (((((abt.bico)::character varying)::text || ((abt.substituicao)::character varying)::text) || ((abt.produto)::character varying)::text)), (min((b_1.abt_vl_encerrante - b_1.abt_vl_abastecimento)))
  • Sort Method: quicksort Memory: 25kB
9. 0.001 382,324.537 ↓ 0.0 0 1

Nested Loop (cost=5,425,066.48..5,839,873.59 rows=37 width=728) (actual time=382,324.537..382,324.537 rows=0 loops=1)

10. 0.001 382,324.536 ↓ 0.0 0 1

Nested Loop (cost=5,421,383.22..5,703,591.08 rows=37 width=632) (actual time=382,324.536..382,324.536 rows=0 loops=1)

11. 0.001 382,324.535 ↓ 0.0 0 1

GroupAggregate (cost=5,414,283.34..5,440,893.96 rows=37 width=604) (actual time=382,324.535..382,324.535 rows=0 loops=1)

  • Group Key: abt.referencia_bico, abt.descricao_produto, abt.preco_bomba, abt.substituicao, abt.descricao_bomba, abt.produto, abt.bico
12.          

Initplan (for GroupAggregate)

13. 0.000 0.000 ↓ 0.0 0

Aggregate (cost=2.65..2.65 rows=1 width=4) (never executed)

14. 0.000 0.000 ↓ 0.0 0

Index Scan using caixa_pkey on caixa caii (cost=0.42..2.64 rows=1 width=4) (never executed)

  • Index Cond: (cai_cd_caixa = 1508518)
15. 0.008 382,324.534 ↓ 0.0 0 1

Sort (cost=5,414,280.68..5,414,280.77 rows=37 width=580) (actual time=382,324.534..382,324.534 rows=0 loops=1)

  • Sort Key: abt.referencia_bico, abt.descricao_produto, abt.preco_bomba, abt.substituicao, abt.descricao_bomba, abt.produto, abt.bico
  • Sort Method: quicksort Memory: 25kB
16. 0.001 382,324.526 ↓ 0.0 0 1

Subquery Scan on abt (cost=3.11..5,414,279.72 rows=37 width=580) (actual time=382,324.526..382,324.526 rows=0 loops=1)

17. 0.003 382,324.525 ↓ 0.0 0 1

Append (cost=3.11..5,414,279.35 rows=37 width=612) (actual time=382,324.525..382,324.525 rows=0 loops=1)

18. 0.000 0.261 ↓ 0.0 0 1

Subquery Scan on *SELECT* 1 (cost=3.11..736.06 rows=2 width=192) (actual time=0.261..0.261 rows=0 loops=1)

19. 0.000 0.261 ↓ 0.0 0 1

Nested Loop (cost=3.11..736.03 rows=2 width=136) (actual time=0.261..0.261 rows=0 loops=1)

20. 0.001 0.261 ↓ 0.0 0 1

Nested Loop (cost=2.83..731.47 rows=2 width=91) (actual time=0.260..0.261 rows=0 loops=1)

21. 0.000 0.260 ↓ 0.0 0 1

Nested Loop (cost=2.41..726.42 rows=2 width=63) (actual time=0.260..0.260 rows=0 loops=1)

22. 0.000 0.260 ↓ 0.0 0 1

Nested Loop (cost=2.12..721.74 rows=2 width=51) (actual time=0.260..0.260 rows=0 loops=1)

23. 0.000 0.260 ↓ 0.0 0 1

Nested Loop (cost=1.56..716.39 rows=2 width=18) (actual time=0.260..0.260 rows=0 loops=1)

24. 0.001 0.260 ↓ 0.0 0 1

Nested Loop (cost=0.99..350.42 rows=1 width=12) (actual time=0.259..0.260 rows=0 loops=1)

25. 0.001 0.259 ↓ 0.0 0 1

Nested Loop (cost=0.56..347.77 rows=1 width=12) (actual time=0.259..0.259 rows=0 loops=1)

  • Join Filter: ((ven.ven_dt_fiscal >= (cm.min_dt_movimento - 2)) AND (ven.ven_dt_fiscal <= (cm.max_dt_movimento + 2)))
26. 0.247 0.247 ↑ 1.0 1 1

CTE Scan on caixa_meta cm (cost=0.00..0.02 rows=1 width=8) (actual time=0.247..0.247 rows=1 loops=1)

27. 0.011 0.011 ↓ 0.0 0 1

Index Scan using venda_idx_caixa on venda ven (cost=0.56..347.59 rows=8 width=16) (actual time=0.011..0.011 rows=0 loops=1)

  • Index Cond: (ven_cd_caixa = 1508518)
  • Filter: ((ven_cd_unidade_negocio = 180) AND (ven_fl_cancelada = 'N'::bpchar))
28. 0.000 0.000 ↓ 0.0 0

Index Scan using caixa_pkey on caixa cai (cost=0.42..2.65 rows=1 width=12) (never executed)

  • Index Cond: (cai_cd_caixa = 1508518)
  • Filter: (cai_cd_unidade_negocio = 180)
29. 0.000 0.000 ↓ 0.0 0

Index Scan using venda_item_idx_venda_rebuild_1 on venda_item vei (cost=0.57..361.85 rows=412 width=14) (never executed)

  • Index Cond: (vei_cd_venda = ven.ven_cd_venda)
30. 0.000 0.000 ↓ 0.0 0

Index Scan using abastecimento_abt_cd_venda_item_key on abastecimento abt_1 (cost=0.57..2.67 rows=1 width=41) (never executed)

  • Index Cond: (abt_cd_venda_item = vei.vei_cd_venda_item)
  • Filter: (NOT abt_bl_afericao)
31. 0.000 0.000 ↓ 0.0 0

Index Scan using bico_pkey on bico bic (cost=0.28..2.34 rows=1 width=16) (never executed)

  • Index Cond: (bic_cd_bico = abt_1.abt_cd_bico)
32. 0.000 0.000 ↓ 0.0 0

Index Scan using produto_pkey on produto pro (cost=0.42..2.53 rows=1 width=32) (never executed)

  • Index Cond: (pro_cd_produto = bic.bic_cd_produto)
33. 0.000 0.000 ↓ 0.0 0

Index Scan using bomba_pkey on bomba bom (cost=0.28..2.28 rows=1 width=13) (never executed)

  • Index Cond: (bom_cd_bomba = bic.bic_cd_bomba)
34. 0.000 0.303 ↓ 0.0 0 1

Subquery Scan on *SELECT* 2 (cost=2.40..60.53 rows=1 width=218) (actual time=0.303..0.303 rows=0 loops=1)

35. 0.000 0.303 ↓ 0.0 0 1

Nested Loop (cost=2.40..60.51 rows=1 width=134) (actual time=0.303..0.303 rows=0 loops=1)

  • Join Filter: (abt_2.abt_dt_abastecimento >= cai_1.cai_dt_movimento)
36. 0.000 0.303 ↓ 0.0 0 1

Nested Loop (cost=1.97..57.85 rows=1 width=90) (actual time=0.303..0.303 rows=0 loops=1)

37. 0.000 0.303 ↓ 0.0 0 1

Nested Loop (cost=1.69..56.00 rows=1 width=85) (actual time=0.303..0.303 rows=0 loops=1)

38. 0.001 0.303 ↓ 0.0 0 1

Nested Loop (cost=1.27..53.36 rows=1 width=57) (actual time=0.302..0.303 rows=0 loops=1)

39. 0.000 0.302 ↓ 0.0 0 1

Nested Loop (cost=0.99..51.39 rows=1 width=45) (actual time=0.302..0.302 rows=0 loops=1)

40. 0.302 0.302 ↓ 0.0 0 1

Index Scan using abastecimento_afericao_idx_aba_cd_caixa on abastecimento_afericao aba (cost=0.42..15.15 rows=13 width=8) (actual time=0.302..0.302 rows=0 loops=1)

  • Index Cond: (aba_cd_caixa = 1508518)
41. 0.000 0.000 ↓ 0.0 0

Index Scan using abastecimento_pkey on abastecimento abt_2 (cost=0.57..2.79 rows=1 width=45) (never executed)

  • Index Cond: (abt_cd_abastecimento = aba.aba_cd_abastecimento)
  • Filter: ((NOT abt_bl_afericao) AND (abt_cd_unidade_negocio = 180))
42. 0.000 0.000 ↓ 0.0 0

Index Scan using bico_pkey on bico bic_1 (cost=0.28..1.88 rows=1 width=20) (never executed)

  • Index Cond: (bic_cd_bico = abt_2.abt_cd_bico)
  • Filter: (bic_cd_unidade_negocio = 180)
43. 0.000 0.000 ↓ 0.0 0

Index Scan using produto_pkey on produto pro_1 (cost=0.42..2.64 rows=1 width=32) (never executed)

  • Index Cond: (pro_cd_produto = bic_1.bic_cd_produto)
44. 0.000 0.000 ↓ 0.0 0

Index Scan using bomba_pkey on bomba bom_1 (cost=0.28..1.85 rows=1 width=13) (never executed)

  • Index Cond: (bom_cd_bomba = bic_1.bic_cd_bomba)
45. 0.000 0.000 ↓ 0.0 0

Index Scan using caixa_pkey on caixa cai_1 (cost=0.42..2.65 rows=1 width=12) (never executed)

  • Index Cond: (cai_cd_caixa = 1508518)
  • Filter: (cai_cd_unidade_negocio = 180)
46. 0.001 382,323.958 ↓ 0.0 0 1

Subquery Scan on *SELECT* 3 (cost=159,711.08..5,413,482.57 rows=34 width=321) (actual time=382,323.958..382,323.958 rows=0 loops=1)

47. 18.721 382,323.957 ↓ 0.0 0 1

Merge Anti Join (cost=159,711.08..5,413,481.72 rows=34 width=153) (actual time=382,323.957..382,323.957 rows=0 loops=1)

  • Merge Cond: (bic_2.bic_cd_bico = abt_3.abt_cd_bico)
48. 0.034 382,305.236 ↓ 0.0 0 1

Nested Loop (cost=158,989.33..5,412,759.87 rows=34 width=93) (actual time=382,305.236..382,305.236 rows=0 loops=1)

49. 0.076 17.736 ↑ 1.0 34 1

Nested Loop (cost=0.98..7,154.70 rows=34 width=57) (actual time=4.470..17.736 rows=34 loops=1)

50. 0.079 16.572 ↑ 1.0 34 1

Nested Loop (cost=0.70..7,076.46 rows=34 width=52) (actual time=4.456..16.572 rows=34 loops=1)

51. 0.063 13.909 ↑ 1.0 34 1

Nested Loop (cost=0.28..6,986.70 rows=34 width=24) (actual time=4.363..13.909 rows=34 loops=1)

52. 13.812 13.812 ↑ 1.0 34 1

Index Scan using bico_pkey on bico bic_2 (cost=0.28..6,986.01 rows=34 width=16) (actual time=4.359..13.812 rows=34 loops=1)

  • Filter: (bic_cd_unidade_negocio = 180)
  • Rows Removed by Filter: 6586
53. 0.034 0.034 ↑ 1.0 1 34

CTE Scan on caixa_meta cm_1 (cost=0.00..0.02 rows=1 width=8) (actual time=0.000..0.001 rows=1 loops=34)

54. 2.584 2.584 ↑ 1.0 1 34

Index Scan using produto_pkey on produto pro_2 (cost=0.42..2.64 rows=1 width=32) (actual time=0.076..0.076 rows=1 loops=34)

  • Index Cond: (pro_cd_produto = bic_2.bic_cd_produto)
55. 1.088 1.088 ↑ 1.0 1 34

Index Scan using bomba_pkey on bomba bom_2 (cost=0.28..2.30 rows=1 width=13) (actual time=0.032..0.032 rows=1 loops=34)

  • Index Cond: (bom_cd_bomba = bic_2.bic_cd_bomba)
56. 0.102 382,287.466 ↓ 0.0 0 34

Limit (cost=158,988.35..158,988.37 rows=1 width=40) (actual time=11,243.748..11,243.749 rows=0 loops=34)

57. 0.102 382,287.364 ↓ 0.0 0 34

GroupAggregate (cost=158,988.35..158,988.83 rows=24 width=40) (actual time=11,243.746..11,243.746 rows=0 loops=34)

  • Group Key: abt_4.abt_cd_substituicao
58. 0.272 382,287.262 ↓ 0.0 0 34

Sort (cost=158,988.35..158,988.41 rows=24 width=12) (actual time=11,243.743..11,243.743 rows=0 loops=34)

  • Sort Key: abt_4.abt_cd_substituicao DESC
  • Sort Method: quicksort Memory: 25kB
59. 0.034 382,286.990 ↓ 0.0 0 34

Nested Loop (cost=2.12..158,987.80 rows=24 width=12) (actual time=11,243.735..11,243.735 rows=0 loops=34)

  • Join Filter: (cai_3.cai_ts_abertura < cm_3.min_ts_abertura)
60. 231.030 382,286.956 ↓ 0.0 0 34

Nested Loop (cost=1.70..158,802.20 rows=73 width=24) (actual time=11,243.734..11,243.734 rows=0 loops=34)

  • Join Filter: ((ven_2.ven_dt_fiscal >= (cm_3.min_dt_movimento - 2)) AND (ven_2.ven_dt_fiscal <= (cm_3.max_dt_movimento + 2)))
  • Rows Removed by Join Filter: 44938
61. 0.068 0.068 ↑ 1.0 1 34

CTE Scan on caixa_meta cm_3 (cost=0.00..0.02 rows=1 width=16) (actual time=0.000..0.002 rows=1 loops=34)

62. 1,199.396 382,055.858 ↓ 68.1 44,938 34

Nested Loop (cost=1.70..158,788.98 rows=660 width=20) (actual time=0.491..11,236.937 rows=44,938 loops=34)

63. 1,376.020 223,484.822 ↓ 1.8 44,938 34

Nested Loop (cost=1.14..93,486.49 rows=24,402 width=16) (actual time=0.331..6,573.083 rows=44,938 loops=34)

64. 55,175.302 55,175.302 ↓ 1.8 45,044 34

Index Scan using abastecimento_idx_cd_bico on abastecimento abt_4 (cost=0.57..26,581.82 rows=24,402 width=16) (actual time=0.154..1,622.803 rows=45,044 loops=34)

  • Index Cond: (abt_cd_bico = bic_2.bic_cd_bico)
65. 166,933.500 166,933.500 ↑ 1.0 1 1,531,500

Index Scan using venda_item_pkey on venda_item vei_2 (cost=0.57..2.74 rows=1 width=8) (actual time=0.109..0.109 rows=1 loops=1,531,500)

  • Index Cond: (vei_cd_venda_item = abt_4.abt_cd_venda_item)
66. 157,371.640 157,371.640 ↑ 1.0 1 1,527,880

Index Scan using venda_pkey on venda ven_2 (cost=0.56..2.68 rows=1 width=12) (actual time=0.103..0.103 rows=1 loops=1,527,880)

  • Index Cond: (ven_cd_venda = vei_2.vei_cd_venda)
  • Filter: ((ven_cd_unidade_negocio = 180) AND (ven_fl_cancelada = 'N'::bpchar))
67. 0.000 0.000 ↓ 0.0 0

Index Scan using caixa_pkey on caixa cai_3 (cost=0.42..2.53 rows=1 width=12) (never executed)

  • Index Cond: (cai_cd_caixa = ven_2.ven_cd_caixa)
68. 0.000 0.000 ↓ 0.0 0

Sort (cost=721.75..721.75 rows=2 width=4) (never executed)

  • Sort Key: abt_3.abt_cd_bico
69. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=2.12..721.74 rows=2 width=4) (never executed)

70. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=1.56..716.39 rows=2 width=4) (never executed)

71. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.99..350.42 rows=1 width=4) (never executed)

72. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.56..347.77 rows=1 width=8) (never executed)

  • Join Filter: ((ven_1.ven_dt_fiscal >= (cm_2.min_dt_movimento - 2)) AND (ven_1.ven_dt_fiscal <= (cm_2.max_dt_movimento + 2)))
73. 0.000 0.000 ↓ 0.0 0

CTE Scan on caixa_meta cm_2 (cost=0.00..0.02 rows=1 width=8) (never executed)

74. 0.000 0.000 ↓ 0.0 0

Index Scan using venda_idx_caixa on venda ven_1 (cost=0.56..347.59 rows=8 width=12) (never executed)

  • Index Cond: (ven_cd_caixa = 1508518)
  • Filter: ((ven_cd_unidade_negocio = 180) AND (ven_fl_cancelada = 'N'::bpchar))
75. 0.000 0.000 ↓ 0.0 0

Index Only Scan using caixa_pkey on caixa cai_2 (cost=0.42..2.64 rows=1 width=4) (never executed)

  • Index Cond: (cai_cd_caixa = 1508518)
  • Heap Fetches: 0
76. 0.000 0.000 ↓ 0.0 0

Index Scan using venda_item_idx_venda_rebuild_1 on venda_item vei_1 (cost=0.57..361.85 rows=412 width=8) (never executed)

  • Index Cond: (vei_cd_venda = ven_1.ven_cd_venda)
77. 0.000 0.000 ↓ 0.0 0

Index Scan using abastecimento_abt_cd_venda_item_key on abastecimento abt_3 (cost=0.57..2.67 rows=1 width=8) (never executed)

  • Index Cond: (abt_cd_venda_item = vei_1.vei_cd_venda_item)
78.          

SubPlan (for GroupAggregate)

79. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=1.70..719.11 rows=1 width=0) (never executed)

  • Join Filter: (abtc_1.abt_dt_abastecimento >= cm_6.min_dt_movimento)
80. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=1.13..713.73 rows=2 width=8) (never executed)

81. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.56..347.77 rows=1 width=8) (never executed)

  • Join Filter: ((ven_6.ven_dt_fiscal >= (cm_6.min_dt_movimento - 2)) AND (ven_6.ven_dt_fiscal <= (cm_6.max_dt_movimento + 2)))
82. 0.000 0.000 ↓ 0.0 0

CTE Scan on caixa_meta cm_6 (cost=0.00..0.02 rows=1 width=8) (never executed)

83. 0.000 0.000 ↓ 0.0 0

Index Scan using venda_idx_caixa on venda ven_6 (cost=0.56..347.59 rows=8 width=8) (never executed)

  • Index Cond: (ven_cd_caixa = abt.caixa)
  • Filter: ((ven_cd_unidade_negocio = 180) AND (ven_fl_cancelada = 'N'::bpchar))
84. 0.000 0.000 ↓ 0.0 0

Index Scan using venda_item_idx_venda_rebuild_1 on venda_item vei_6 (cost=0.57..361.85 rows=412 width=8) (never executed)

  • Index Cond: (vei_cd_venda = ven_6.ven_cd_venda)
85. 0.000 0.000 ↓ 0.0 0

Index Scan using abastecimento_abt_cd_venda_item_key on abastecimento abtc_1 (cost=0.57..2.68 rows=1 width=8) (never executed)

  • Index Cond: (abt_cd_venda_item = vei_6.vei_cd_venda_item)
  • Filter: (abt_cd_bico = abt.bico)
86. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=172,056.59..4,647,807.46 rows=107,238 width=8) (never executed)

  • Join Filter: (abtc_2.abt_dt_abastecimento >= cm_7.min_dt_movimento)
87. 0.000 0.000 ↓ 0.0 0

Hash Join (cost=172,056.03..3,686,209.98 rows=357,864 width=12) (never executed)

  • Hash Cond: (vei_7.vei_cd_venda = ven_7.ven_cd_venda)
88. 0.000 0.000 ↓ 0.0 0

Seq Scan on venda_item vei_7 (cost=0.00..3,064,123.40 rows=119,053,840 width=8) (never executed)

89. 0.000 0.000 ↓ 0.0 0

Hash (cost=170,169.55..170,169.55 rows=150,918 width=12) (never executed)

90. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.57..170,169.55 rows=150,918 width=12) (never executed)

91. 0.000 0.000 ↓ 0.0 0

CTE Scan on caixa_meta cm_7 (cost=0.00..0.02 rows=1 width=8) (never executed)

92. 0.000 0.000 ↓ 0.0 0

Index Scan using venda_ven_cd_unidade_negocio_ven_fl_cancelada_ven_dt_fiscal_ven on venda ven_7 (cost=0.57..168,660.35 rows=150,918 width=12) (never executed)

  • Index Cond: ((ven_cd_unidade_negocio = 180) AND (ven_fl_cancelada = 'N'::bpchar) AND (ven_dt_fiscal >= (cm_7.min_dt_movimento - 2)) AND (ven_dt_fiscal <= (cm_7.max_dt_movimento + 2)))
93. 0.000 0.000 ↓ 0.0 0

Index Scan using abastecimento_abt_cd_venda_item_key on abastecimento abtc_2 (cost=0.57..2.67 rows=1 width=12) (never executed)

  • Index Cond: (abt_cd_venda_item = vei_7.vei_cd_venda_item)
94. 0.000 0.000 ↓ 0.0 0

Aggregate (cost=7,099.88..7,099.89 rows=1 width=32) (never executed)

95. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=6,962.08..7,099.88 rows=1 width=6) (never executed)

  • Join Filter: ((cai_4.cai_ts_abertura > cm_4.max_ts_abertura) AND (ven_3.ven_dt_fiscal >= (cm_4.min_dt_movimento - 2)) AND (ven_3.ven_dt_fiscal <= (cm_4.max_dt_movimento + 2)))
96. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=6,962.08..7,099.83 rows=1 width=18) (never executed)

97. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=6,961.65..7,097.30 rows=1 width=18) (never executed)

98. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=6,961.09..7,094.57 rows=1 width=14) (never executed)

99. 0.000 0.000 ↓ 0.0 0

Bitmap Heap Scan on abastecimento b (cost=6,960.52..7,091.78 rows=1 width=14) (never executed)

  • Recheck Cond: ((abt_cd_bico = abt.bico) AND (abt_cd_unidade_negocio = 180) AND (abt_dt_fiscal >= (max(abt.maior_data))))
  • Filter: ((abt_vl_encerrante < (max(abt.encerrante_final_abt))) AND (abt_cd_substituicao = abt.substituicao))
100. 0.000 0.000 ↓ 0.0 0

BitmapAnd (cost=6,960.52..6,960.52 rows=117 width=0) (never executed)

101. 0.000 0.000 ↓ 0.0 0

Bitmap Index Scan on abastecimento_idx_cd_bico (cost=0.00..257.28 rows=24,402 width=0) (never executed)

  • Index Cond: (abt_cd_bico = abt.bico)
102. 0.000 0.000 ↓ 0.0 0

Bitmap Index Scan on abastecimento_abt_cd_unidade_negocio_abt_dt_fiscal_idx (cost=0.00..6,702.99 rows=514,922 width=0) (never executed)

  • Index Cond: ((abt_cd_unidade_negocio = 180) AND (abt_dt_fiscal >= (max(abt.maior_data))))
103. 0.000 0.000 ↓ 0.0 0

Index Scan using venda_item_pkey on venda_item vei_3 (cost=0.57..2.79 rows=1 width=8) (never executed)

  • Index Cond: (vei_cd_venda_item = b.abt_cd_venda_item)
  • Filter: (vei_cd_produto = abt.produto)
104. 0.000 0.000 ↓ 0.0 0

Index Scan using venda_pkey on venda ven_3 (cost=0.56..2.74 rows=1 width=16) (never executed)

  • Index Cond: (ven_cd_venda = vei_3.vei_cd_venda)
  • Filter: ((ven_cd_caixa <> 1508518) AND (ven_cd_unidade_negocio = 180) AND (ven_fl_cancelada = 'N'::bpchar))
105. 0.000 0.000 ↓ 0.0 0

Index Scan using caixa_pkey on caixa cai_4 (cost=0.42..2.53 rows=1 width=16) (never executed)

  • Index Cond: (cai_cd_caixa = ven_3.ven_cd_caixa)
  • Filter: (cai_cd_unidade_negocio = 180)
106. 0.000 0.000 ↓ 0.0 0

CTE Scan on caixa_meta cm_4 (cost=0.00..0.02 rows=1 width=16) (never executed)

107. 0.000 0.000 ↓ 0.0 0

Aggregate (cost=3,683.26..3,683.27 rows=1 width=64) (never executed)

108. 0.000 0.000 ↓ 0.0 0

Nested Loop Semi Join (cost=3.82..3,683.25 rows=1 width=19) (never executed)

  • Join Filter: ((abtc.abt_dt_abastecimento >= cai_5.cai_dt_movimento) AND (ven_5.ven_dt_fiscal >= (cm_5.min_dt_movimento - 2)) AND (ven_5.ven_dt_fiscal <= (cm_5.max_dt_movimento + 2)))
109. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=2.12..355.99 rows=1 width=39) (never executed)

110. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=1.70..353.33 rows=1 width=39) (never executed)

  • Join Filter: (b_1.abt_dt_abastecimento < cm_5.min_dt_movimento)
111. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=1.13..350.56 rows=1 width=20) (never executed)

112. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.56..347.77 rows=1 width=20) (never executed)

  • Join Filter: ((ven_4.ven_dt_fiscal >= (cm_5.min_dt_movimento - 2)) AND (ven_4.ven_dt_fiscal <= (cm_5.max_dt_movimento + 2)))
113. 0.000 0.000 ↓ 0.0 0

CTE Scan on caixa_meta cm_5 (cost=0.00..0.02 rows=1 width=8) (never executed)

114. 0.000 0.000 ↓ 0.0 0

Index Scan using venda_idx_caixa on venda ven_4 (cost=0.56..347.59 rows=8 width=16) (never executed)

  • Index Cond: (ven_cd_caixa = 1508518)
  • Filter: ((ven_cd_unidade_negocio = 180) AND (ven_fl_cancelada = 'N'::bpchar))
115. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_tst_01_rebuild_1 on venda_item vei_4 (cost=0.57..2.79 rows=1 width=8) (never executed)

  • Index Cond: ((vei_cd_venda = ven_4.ven_cd_venda) AND (vei_cd_produto = abt.produto))
116. 0.000 0.000 ↓ 0.0 0

Index Scan using abastecimento_abt_cd_venda_item_key on abastecimento b_1 (cost=0.57..2.76 rows=1 width=35) (never executed)

  • Index Cond: (abt_cd_venda_item = vei_4.vei_cd_venda_item)
  • Filter: ((abt_cd_unidade_negocio = 180) AND (abt_cd_bico = abt.bico) AND (abt_cd_substituicao = abt.substituicao))
117. 0.000 0.000 ↓ 0.0 0

Index Scan using caixa_pkey on caixa cai_5 (cost=0.42..2.65 rows=1 width=12) (never executed)

  • Index Cond: (cai_cd_caixa = 1508518)
  • Filter: (cai_cd_unidade_negocio = 180)
118. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=1.70..3,327.24 rows=1 width=16) (never executed)

119. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=1.13..3,275.34 rows=19 width=12) (never executed)

120. 0.000 0.000 ↓ 0.0 0

Index Scan using venda_idx_caixa on venda ven_5 (cost=0.56..347.59 rows=8 width=12) (never executed)

  • Index Cond: (ven_cd_caixa = 1508518)
  • Filter: ((ven_cd_unidade_negocio = 180) AND (ven_fl_cancelada = 'N'::bpchar))
121. 0.000 0.000 ↓ 0.0 0

Index Scan using venda_item_idx_venda_rebuild_1 on venda_item vei_5 (cost=0.57..361.85 rows=412 width=8) (never executed)

  • Index Cond: (vei_cd_venda = ven_5.ven_cd_venda)
122. 0.000 0.000 ↓ 0.0 0

Index Scan using abastecimento_abt_cd_venda_item_key on abastecimento abtc (cost=0.57..2.73 rows=1 width=12) (never executed)

  • Index Cond: (abt_cd_venda_item = vei_5.vei_cd_venda_item)
  • Filter: (abt_cd_bico = abt.bico)
Planning time : 18.751 ms
Execution time : 382,330.594 ms