explain.depesz.com

PostgreSQL's explain analyze made readable

Result: d2jK

Settings
# exclusive inclusive rows x rows loops node
1. 0.016 77.516 ↑ 1.2 12 1

Sort (cost=7,404,219.74..7,404,219.78 rows=15 width=952) (actual time=77.515..77.516 rows=12 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 >= $1) OR (NOT (SubPlan 3)))), '0'::numeric)))) OVER (?)), (max(CASE WHEN ((((max(abt.encerrante_final_abt)) - (COALESCE(min(abt.encerrante_inicial_abt) FILTER (WHERE ((abt.data_abt >= $1) OR (NOT (SubPlan 3)))), '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: 28kB
2. 0.058 77.500 ↑ 1.2 12 1

WindowAgg (cost=7,404,217.99..7,404,219.45 rows=15 width=952) (actual time=77.459..77.500 rows=12 loops=1)

3. 0.010 77.442 ↑ 1.2 12 1

Sort (cost=7,404,217.99..7,404,218.02 rows=15 width=728) (actual time=77.441..77.442 rows=12 loops=1)

  • Sort Key: abt.bico, abt.substituicao, abt.produto
  • Sort Method: quicksort Memory: 26kB
4. 0.009 77.432 ↑ 1.2 12 1

Group (cost=7,404,216.68..7,404,217.69 rows=15 width=728) (actual time=77.424..77.432 rows=12 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 >= $1) OR (NOT (SubPlan 3)))), '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)))
5. 0.015 77.423 ↑ 1.2 12 1

Sort (cost=7,404,216.68..7,404,216.72 rows=15 width=728) (actual time=77.423..77.423 rows=12 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 >= $1) OR (NOT (SubPlan 3)))), '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: 26kB
6. 0.018 77.408 ↑ 1.2 12 1

Nested Loop (cost=3,847,923.68..7,404,216.39 rows=15 width=728) (actual time=77.234..77.408 rows=12 loops=1)

7. 0.010 77.258 ↑ 1.2 12 1

Nested Loop (cost=3,685,546.95..4,968,564.68 rows=15 width=632) (actual time=77.204..77.258 rows=12 loops=1)

8. 0.033 77.212 ↑ 1.2 12 1

GroupAggregate (cost=3,684,668.67..4,955,389.85 rows=15 width=604) (actual time=77.191..77.212 rows=12 loops=1)

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

Initplan (for GroupAggregate)

10. 0.001 0.009 ↑ 1.0 1 1

Aggregate (cost=2.64..2.65 rows=1 width=4) (actual time=0.009..0.009 rows=1 loops=1)

11. 0.008 0.008 ↑ 1.0 1 1

Index Scan using caixa_pkey on caixa caii (cost=0.42..2.64 rows=1 width=4) (actual time=0.007..0.008 rows=1 loops=1)

  • Index Cond: (cai_cd_caixa = 1353808)
12. 0.016 77.170 ↑ 1.2 12 1

Sort (cost=3,684,666.01..3,684,666.05 rows=15 width=580) (actual time=77.169..77.170 rows=12 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: 26kB
13. 0.004 77.154 ↑ 1.2 12 1

Subquery Scan on abt (cost=3.10..3,684,665.72 rows=15 width=580) (actual time=67.276..77.154 rows=12 loops=1)

14. 0.004 77.150 ↑ 1.2 12 1

Append (cost=3.10..3,684,665.57 rows=15 width=612) (actual time=67.275..77.150 rows=12 loops=1)

15. 0.001 0.108 ↓ 0.0 0 1

Subquery Scan on *SELECT* 1 (cost=3.10..987.77 rows=2 width=189) (actual time=0.108..0.108 rows=0 loops=1)

16. 0.000 0.107 ↓ 0.0 0 1

Nested Loop (cost=3.10..987.74 rows=2 width=133) (actual time=0.107..0.107 rows=0 loops=1)

17. 0.000 0.107 ↓ 0.0 0 1

Nested Loop (cost=2.82..983.24 rows=2 width=89) (actual time=0.107..0.107 rows=0 loops=1)

18. 0.000 0.107 ↓ 0.0 0 1

Nested Loop (cost=2.40..978.18 rows=2 width=62) (actual time=0.107..0.107 rows=0 loops=1)

19. 0.005 0.107 ↓ 0.0 0 1

Nested Loop (cost=2.12..973.50 rows=2 width=50) (actual time=0.107..0.107 rows=0 loops=1)

20. 0.007 0.082 ↓ 2.5 5 1

Nested Loop (cost=1.55..968.16 rows=2 width=17) (actual time=0.045..0.082 rows=5 loops=1)

21. 0.005 0.051 ↓ 4.0 4 1

Nested Loop (cost=0.99..499.20 rows=1 width=12) (actual time=0.030..0.051 rows=4 loops=1)

22. 0.026 0.026 ↓ 4.0 4 1

Index Scan using venda_idx_caixa on venda ven (cost=0.56..496.54 rows=1 width=12) (actual time=0.019..0.026 rows=4 loops=1)

  • Index Cond: (ven_cd_caixa = 1353808)
  • Filter: ((ven_cd_unidade_negocio = 647) AND (ven_fl_cancelada = 'N'::bpchar))
23. 0.020 0.020 ↑ 1.0 1 4

Index Scan using caixa_pkey on caixa cai (cost=0.42..2.64 rows=1 width=12) (actual time=0.005..0.005 rows=1 loops=4)

  • Index Cond: (cai_cd_caixa = 1353808)
  • Filter: (cai_cd_unidade_negocio = 647)
24. 0.024 0.024 ↑ 427.0 1 4

Index Scan using venda_item_idx_venda_rebuild_2 on venda_item vei (cost=0.57..464.69 rows=427 width=13) (actual time=0.006..0.006 rows=1 loops=4)

  • Index Cond: (vei_cd_venda = ven.ven_cd_venda)
25. 0.020 0.020 ↓ 0.0 0 5

Index Scan using abastecimento_abt_cd_venda_item_key on abastecimento abt_1 (cost=0.57..2.67 rows=1 width=41) (actual time=0.004..0.004 rows=0 loops=5)

  • Index Cond: (abt_cd_venda_item = vei.vei_cd_venda_item)
  • Filter: (NOT abt_bl_afericao)
26. 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)
27. 0.000 0.000 ↓ 0.0 0

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

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

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

  • Index Cond: (bom_cd_bomba = bic.bic_cd_bomba)
29. 0.001 0.008 ↓ 0.0 0 1

Subquery Scan on *SELECT* 2 (cost=2.26..38.67 rows=1 width=216) (actual time=0.008..0.008 rows=0 loops=1)

30. 0.000 0.007 ↓ 0.0 0 1

Nested Loop (cost=2.26..38.65 rows=1 width=132) (actual time=0.007..0.007 rows=0 loops=1)

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

Nested Loop (cost=1.84..35.99 rows=1 width=88) (actual time=0.007..0.007 rows=0 loops=1)

32. 0.000 0.007 ↓ 0.0 0 1

Nested Loop (cost=1.56..34.04 rows=1 width=84) (actual time=0.007..0.007 rows=0 loops=1)

33. 0.000 0.007 ↓ 0.0 0 1

Nested Loop (cost=1.14..31.40 rows=1 width=57) (actual time=0.007..0.007 rows=0 loops=1)

34. 0.001 0.007 ↓ 0.0 0 1

Nested Loop (cost=0.86..29.49 rows=1 width=45) (actual time=0.007..0.007 rows=0 loops=1)

35. 0.006 0.006 ↓ 0.0 0 1

Index Scan using abastecimento_afericao_idx_aba_cd_caixa on abastecimento_afericao aba (cost=0.29..4.40 rows=9 width=8) (actual time=0.006..0.006 rows=0 loops=1)

  • Index Cond: (aba_cd_caixa = 1353808)
36. 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 = 647))
37. 0.000 0.000 ↓ 0.0 0

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

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

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

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

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

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

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

  • Index Cond: (cai_cd_caixa = 1353808)
  • Filter: (cai_cd_unidade_negocio = 647)
41. 0.009 77.030 ↑ 1.0 12 1

Subquery Scan on *SELECT* 3 (cost=289,784.23..3,683,639.06 rows=12 width=319) (actual time=67.158..77.030 rows=12 loops=1)

42. 0.016 77.021 ↑ 1.0 12 1

Nested Loop (cost=289,784.23..3,683,638.76 rows=12 width=151) (actual time=67.155..77.021 rows=12 loops=1)

43.          

Initplan (for Nested Loop)

44. 0.002 0.011 ↑ 1.0 1 1

Aggregate (cost=2.64..2.65 rows=1 width=4) (actual time=0.011..0.011 rows=1 loops=1)

45. 0.009 0.009 ↑ 1.0 1 1

Index Scan using caixa_pkey on caixa cx (cost=0.42..2.64 rows=1 width=4) (actual time=0.008..0.009 rows=1 loops=1)

  • Index Cond: (cai_cd_caixa = 1353808)
46. 0.002 0.004 ↑ 1.0 1 1

Aggregate (cost=2.64..2.65 rows=1 width=4) (actual time=0.004..0.004 rows=1 loops=1)

47. 0.002 0.002 ↑ 1.0 1 1

Index Scan using caixa_pkey on caixa cx_1 (cost=0.42..2.64 rows=1 width=4) (actual time=0.002..0.002 rows=1 loops=1)

  • Index Cond: (cai_cd_caixa = 1353808)
48. 0.000 1.758 ↓ 1.3 16 1

Nested Loop Anti Join (cost=3.10..206,321.17 rows=12 width=47) (actual time=1.152..1.758 rows=16 loops=1)

  • Join Filter: (abt_3.abt_cd_bico = bic_2.bic_cd_bico)
49. 0.009 1.694 ↑ 1.0 16 1

Nested Loop (cost=0.98..1,969.56 rows=16 width=47) (actual time=1.095..1.694 rows=16 loops=1)

50. 0.017 1.653 ↑ 1.0 16 1

Nested Loop (cost=0.70..1,931.84 rows=16 width=43) (actual time=1.087..1.653 rows=16 loops=1)

51. 1.588 1.588 ↑ 1.0 16 1

Index Scan using bico_pkey on bico bic_2 (cost=0.28..1,889.60 rows=16 width=16) (actual time=1.073..1.588 rows=16 loops=1)

  • Filter: (bic_cd_unidade_negocio = 647)
  • Rows Removed by Filter: 3169
52. 0.048 0.048 ↑ 1.0 1 16

Index Scan using produto_pkey on produto pro_2 (cost=0.42..2.64 rows=1 width=31) (actual time=0.003..0.003 rows=1 loops=16)

  • Index Cond: (pro_cd_produto = bic_2.bic_cd_produto)
53. 0.032 0.032 ↑ 1.0 1 16

Index Scan using bomba_pkey on bomba bom_2 (cost=0.28..2.36 rows=1 width=12) (actual time=0.002..0.002 rows=1 loops=16)

  • Index Cond: (bom_cd_bomba = bic_2.bic_cd_bomba)
54. 0.010 0.064 ↓ 0.0 0 16

Materialize (cost=2.12..204,151.63 rows=842 width=4) (actual time=0.004..0.004 rows=0 loops=16)

55. 0.003 0.054 ↓ 0.0 0 1

Nested Loop (cost=2.12..204,147.42 rows=842 width=4) (actual time=0.054..0.054 rows=0 loops=1)

56. 0.004 0.036 ↑ 201.2 5 1

Nested Loop (cost=1.55..201,458.94 rows=1,006 width=4) (actual time=0.017..0.036 rows=5 loops=1)

57. 0.002 0.016 ↑ 111.2 4 1

Nested Loop (cost=0.99..501.41 rows=445 width=4) (actual time=0.011..0.016 rows=4 loops=1)

58. 0.006 0.006 ↑ 1.0 1 1

Index Only Scan using caixa_pkey on caixa cai_2 (cost=0.42..2.64 rows=1 width=4) (actual time=0.005..0.006 rows=1 loops=1)

  • Index Cond: (cai_cd_caixa = 1353808)
  • Heap Fetches: 1
59. 0.008 0.008 ↑ 111.2 4 1

Index Scan using venda_idx_caixa on venda ven_1 (cost=0.56..494.32 rows=445 width=8) (actual time=0.005..0.008 rows=4 loops=1)

  • Index Cond: (ven_cd_caixa = 1353808)
60. 0.016 0.016 ↑ 427.0 1 4

Index Scan using venda_item_idx_venda_rebuild_2 on venda_item vei_1 (cost=0.57..447.32 rows=427 width=8) (actual time=0.004..0.004 rows=1 loops=4)

  • Index Cond: (vei_cd_venda = ven_1.ven_cd_venda)
61. 0.015 0.015 ↓ 0.0 0 5

Index Scan using abastecimento_abt_cd_venda_item_key on abastecimento abt_3 (cost=0.57..2.67 rows=1 width=8) (actual time=0.003..0.003 rows=0 loops=5)

  • Index Cond: (abt_cd_venda_item = vei_1.vei_cd_venda_item)
62. 0.003 75.232 ↑ 1.0 1 16

Limit (cost=289,775.82..289,776.00 rows=1 width=40) (actual time=4.701..4.702 rows=1 loops=16)

63.          

Initplan (for Limit)

64. 0.006 0.013 ↑ 1.0 1 1

Aggregate (cost=2.64..2.65 rows=1 width=8) (actual time=0.013..0.013 rows=1 loops=1)

65. 0.007 0.007 ↑ 1.0 1 1

Index Scan using caixa_pkey on caixa caii_2 (cost=0.42..2.64 rows=1 width=8) (actual time=0.006..0.007 rows=1 loops=1)

  • Index Cond: (cai_cd_caixa = 1353808)
66. 0.064 75.216 ↑ 825.0 1 16

GroupAggregate (cost=289,773.17..289,922.19 rows=825 width=40) (actual time=4.701..4.701 rows=1 loops=16)

  • Group Key: abt_4.abt_cd_substituicao
67. 0.096 75.152 ↑ 938.5 15 16

Sort (cost=289,773.17..289,808.36 rows=14,077 width=12) (actual time=4.697..4.697 rows=15 loops=16)

  • Sort Key: abt_4.abt_cd_substituicao DESC
  • Sort Method: quicksort Memory: 25kB
68. 0.567 75.056 ↑ 469.2 30 16

Hash Join (cost=15,544.62..288,803.19 rows=14,077 width=12) (actual time=4.036..4.691 rows=30 loops=16)

  • Hash Cond: (ven_2.ven_cd_caixa = cai_3.cai_cd_caixa)
69. 1.646 13.344 ↑ 332.5 127 16

Nested Loop (cost=1.70..273,149.41 rows=42,231 width=16) (actual time=0.011..0.834 rows=127 loops=16)

70. 1.968 7.648 ↑ 332.5 127 16

Nested Loop (cost=1.14..160,433.57 rows=42,231 width=16) (actual time=0.008..0.478 rows=127 loops=16)

71. 1.360 1.360 ↑ 312.8 135 16

Index Scan using abastecimento_idx_cd_bico on abastecimento abt_4 (cost=0.57..45,257.83 rows=42,231 width=16) (actual time=0.004..0.085 rows=135 loops=16)

  • Index Cond: (abt_cd_bico = bic_2.bic_cd_bico)
72. 4.320 4.320 ↑ 1.0 1 2,160

Index Scan using venda_item_pkey on venda_item vei_2 (cost=0.57..2.73 rows=1 width=8) (actual time=0.002..0.002 rows=1 loops=2,160)

  • Index Cond: (vei_cd_venda_item = abt_4.abt_cd_venda_item)
73. 4.050 4.050 ↑ 1.0 1 2,025

Index Scan using venda_pkey on venda ven_2 (cost=0.56..2.67 rows=1 width=8) (actual time=0.002..0.002 rows=1 loops=2,025)

  • Index Cond: (ven_cd_venda = vei_2.vei_cd_venda)
74. 22.196 61.145 ↑ 1.9 89,769 1

Hash (cost=13,426.51..13,426.51 rows=169,313 width=4) (actual time=61.144..61.145 rows=89,769 loops=1)

  • Buckets: 262144 Batches: 1 Memory Usage: 5204kB
75. 31.161 38.949 ↑ 1.9 89,769 1

Bitmap Heap Scan on caixa cai_3 (cost=1,824.10..13,426.51 rows=169,313 width=4) (actual time=8.921..38.949 rows=89,769 loops=1)

  • Recheck Cond: (cai_ts_abertura < $16)
  • Heap Blocks: exact=5065
76. 7.788 7.788 ↑ 1.9 89,769 1

Bitmap Index Scan on caixa_abertura (cost=0.00..1,781.77 rows=169,313 width=0) (actual time=7.787..7.788 rows=89,769 loops=1)

  • Index Cond: (cai_ts_abertura < $16)
77.          

SubPlan (for GroupAggregate)

78. 0.000 0.000 ↓ 0.0 0

Hash Join (cost=504.78..84,714.65 rows=1 width=0) (never executed)

  • Hash Cond: (vei_6.vei_cd_venda = ven_6.ven_cd_venda)
79.          

Initplan (for Hash Join)

80. 0.000 0.000 ↓ 0.0 0

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

81. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (cai_cd_caixa = 1353808)
82. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=1.14..84,174.05 rows=14,077 width=4) (never executed)

83. 0.000 0.000 ↓ 0.0 0

Index Scan using abastecimento_idx_cd_bico on abastecimento abtc_1 (cost=0.57..45,363.41 rows=14,077 width=4) (never executed)

  • Index Cond: (abt_cd_bico = abt.bico)
  • Filter: (abt_dt_abastecimento >= $3)
84. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (vei_cd_venda_item = abtc_1.abt_cd_venda_item)
85. 0.000 0.000 ↓ 0.0 0

Hash (cost=495.42..495.42 rows=446 width=4) (never executed)

86. 0.000 0.000 ↓ 0.0 0

Index Scan using venda_idx_caixa on venda ven_6 (cost=0.56..495.42 rows=446 width=4) (never executed)

  • Index Cond: (ven_cd_caixa = abt.caixa)
87. 0.000 0.036 ↑ 1.0 1 12

Aggregate (cost=878.28..878.29 rows=1 width=32) (actual time=0.003..0.003 rows=1 loops=12)

88.          

Initplan (for Aggregate)

89. 0.000 0.000 ↓ 0.0 0

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

90. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (cai_cd_caixa = 1353808)
91. 0.000 0.036 ↓ 0.0 0 12

Nested Loop (cost=2.12..875.62 rows=1 width=6) (actual time=0.003..0.003 rows=0 loops=12)

92. 0.012 0.036 ↓ 0.0 0 12

Nested Loop (cost=1.70..873.08 rows=1 width=14) (actual time=0.003..0.003 rows=0 loops=12)

93. 0.000 0.024 ↓ 0.0 0 12

Nested Loop (cost=1.14..870.34 rows=1 width=14) (actual time=0.002..0.002 rows=0 loops=12)

94. 0.024 0.024 ↓ 0.0 0 12

Index Scan using abt_unidade_dtfiscal_bico on abastecimento b (cost=0.57..867.55 rows=1 width=14) (actual time=0.002..0.002 rows=0 loops=12)

  • Index Cond: ((abt_cd_unidade_negocio = 647) AND (abt_dt_fiscal >= (max(abt.maior_data))) AND (abt_cd_bico = abt.bico))
  • Filter: ((abt_vl_encerrante < (max(abt.encerrante_final_abt))) AND (abt_cd_substituicao = abt.substituicao))
95. 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)
96. 0.000 0.000 ↓ 0.0 0

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

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

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

  • Index Cond: (cai_cd_caixa = ven_3.ven_cd_caixa)
  • Filter: ((cai_ts_abertura > $19) AND (cai_cd_unidade_negocio = 647))
98. 0.000 0.132 ↑ 1.0 1 12

Aggregate (cost=162,376.73..162,376.74 rows=1 width=64) (actual time=0.011..0.011 rows=1 loops=12)

99.          

Initplan (for Aggregate)

100. 0.000 0.000 ↓ 0.0 0

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

101. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (cai_cd_caixa = 1353808)
102. 0.000 0.132 ↓ 0.0 0 12

Nested Loop Semi Join (cost=503.14..162,374.07 rows=1 width=19) (actual time=0.011..0.011 rows=0 loops=12)

  • Join Filter: (abtc.abt_dt_abastecimento >= cai_5.cai_dt_movimento)
103. 0.000 0.132 ↓ 0.0 0 12

Nested Loop (cost=2.12..506.95 rows=1 width=31) (actual time=0.011..0.011 rows=0 loops=12)

104. 0.012 0.132 ↓ 0.0 0 12

Nested Loop (cost=1.70..504.30 rows=1 width=31) (actual time=0.011..0.011 rows=0 loops=12)

105. 0.024 0.120 ↓ 0.0 0 12

Nested Loop (cost=1.13..499.34 rows=1 width=12) (actual time=0.010..0.010 rows=0 loops=12)

106. 0.048 0.048 ↓ 4.0 4 12

Index Scan using venda_idx_caixa on venda ven_4 (cost=0.56..496.54 rows=1 width=12) (actual time=0.002..0.004 rows=4 loops=12)

  • Index Cond: (ven_cd_caixa = 1353808)
  • Filter: ((ven_cd_unidade_negocio = 647) AND (ven_fl_cancelada = 'N'::bpchar))
107. 0.048 0.048 ↓ 0.0 0 48

Index Scan using idx_tst_01_rebuild_2 on venda_item vei_4 (cost=0.57..2.79 rows=1 width=8) (actual time=0.001..0.001 rows=0 loops=48)

  • Index Cond: ((vei_cd_venda = ven_4.ven_cd_venda) AND (vei_cd_produto = abt.produto))
108. 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=31) (never executed)

  • Index Cond: (abt_cd_venda_item = vei_4.vei_cd_venda_item)
  • Filter: ((abt_dt_abastecimento < $26) AND (abt_cd_unidade_negocio = 647) AND (abt_cd_bico = abt.bico) AND (abt_cd_substituicao = abt.substituicao))
109. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (cai_cd_caixa = 1353808)
  • Filter: (cai_cd_unidade_negocio = 647)
110. 0.000 0.000 ↓ 0.0 0

Hash Join (cost=501.02..161,867.10 rows=1 width=12) (never executed)

  • Hash Cond: (vei_5.vei_cd_venda = ven_5.ven_cd_venda)
111. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=1.14..161,256.37 rows=42,231 width=12) (never executed)

112. 0.000 0.000 ↓ 0.0 0

Index Scan using abastecimento_idx_cd_bico on abastecimento abtc (cost=0.57..45,257.83 rows=42,231 width=12) (never executed)

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

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

  • Index Cond: (vei_cd_venda_item = abtc.abt_cd_venda_item)
114. 0.000 0.000 ↓ 0.0 0

Hash (cost=494.32..494.32 rows=445 width=8) (never executed)

115. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (ven_cd_caixa = 1353808)
Planning time : 16.036 ms
Execution time : 78.265 ms