explain.depesz.com

PostgreSQL's explain analyze made readable

Result: qmKk

Settings
# exclusive inclusive rows x rows loops node
1. 0.023 163.096 ↑ 1.2 12 1

Sort (cost=7,420,539.27..7,420,539.30 rows=15 width=952) (actual time=163.096..163.096 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.057 163.073 ↑ 1.2 12 1

WindowAgg (cost=7,420,537.51..7,420,538.97 rows=15 width=952) (actual time=163.033..163.073 rows=12 loops=1)

3. 0.015 163.016 ↑ 1.2 12 1

Sort (cost=7,420,537.51..7,420,537.55 rows=15 width=728) (actual time=163.015..163.016 rows=12 loops=1)

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

Group (cost=7,420,536.21..7,420,537.22 rows=15 width=728) (actual time=162.993..163.001 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.028 162.992 ↑ 1.2 12 1

Sort (cost=7,420,536.21..7,420,536.24 rows=15 width=728) (actual time=162.991..162.992 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.017 162.964 ↑ 1.2 12 1

Nested Loop (cost=3,867,658.09..7,420,535.91 rows=15 width=728) (actual time=162.633..162.964 rows=12 loops=1)

7. 0.010 162.791 ↑ 1.2 12 1

Nested Loop (cost=3,705,654.77..4,990,485.31 rows=15 width=632) (actual time=162.593..162.791 rows=12 loops=1)

8. 0.043 162.517 ↑ 1.2 12 1

GroupAggregate (cost=3,704,533.33..4,973,663.21 rows=15 width=604) (actual time=162.494..162.517 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.002 0.014 ↑ 1.0 1 1

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

11. 0.012 0.012 ↑ 1.0 1 1

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

  • Index Cond: (cai_cd_caixa = 1353808)
12. 0.034 162.460 ↑ 1.2 12 1

Sort (cost=3,704,530.68..3,704,530.72 rows=15 width=580) (actual time=162.459..162.460 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 162.426 ↑ 1.2 12 1

Subquery Scan on abt (cost=987.75..3,704,530.39 rows=15 width=580) (actual time=152.434..162.426 rows=12 loops=1)

14. 0.004 162.422 ↑ 1.2 12 1

Append (cost=987.75..3,704,530.24 rows=15 width=612) (actual time=152.433..162.422 rows=12 loops=1)

15. 0.001 0.152 ↓ 0.0 0 1

Subquery Scan on *SELECT* 1 (cost=987.75..987.88 rows=2 width=189) (actual time=0.152..0.152 rows=0 loops=1)

16. 0.000 0.151 ↓ 0.0 0 1

GroupAggregate (cost=987.75..987.85 rows=2 width=133) (actual time=0.151..0.151 rows=0 loops=1)

  • Group Key: abt_1.abt_cd_substituicao, abt_1.abt_vl_volume_abastecido, abt_1.abt_vl_abastecimento, ((abt_1.abt_vl_encerrante - abt_1.abt_vl_volume_abastecido)), abt_1.abt_vl_encerrante, vei.vei_vl_item, 0, 0, bom.bom_ds_bomba, bic.bic_cd_bico, pro.pro_cd_produto, abt_1.abt_vl_preco_unitario, abt_1.abt_dt_abastecimento, ven.ven_cd_caixa
17. 0.015 0.151 ↓ 0.0 0 1

Sort (cost=987.75..987.75 rows=2 width=133) (actual time=0.151..0.151 rows=0 loops=1)

  • Sort Key: abt_1.abt_cd_substituicao, abt_1.abt_vl_volume_abastecido, abt_1.abt_vl_abastecimento, ((abt_1.abt_vl_encerrante - abt_1.abt_vl_volume_abastecido)), abt_1.abt_vl_encerrante, vei.vei_vl_item, bom.bom_ds_bomba, bic.bic_cd_bico, pro.pro_cd_produto, abt_1.abt_vl_preco_unitario, abt_1.abt_dt_abastecimento
  • Sort Method: quicksort Memory: 25kB
18. 0.001 0.136 ↓ 0.0 0 1

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

19. 0.000 0.135 ↓ 0.0 0 1

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

20. 0.000 0.135 ↓ 0.0 0 1

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

21. 0.003 0.135 ↓ 0.0 0 1

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

22. 0.004 0.107 ↓ 2.5 5 1

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

23. 0.005 0.075 ↓ 4.0 4 1

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

24. 0.038 0.038 ↓ 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.030..0.038 rows=4 loops=1)

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

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

  • Index Cond: (cai_cd_caixa = 1353808)
  • Filter: (cai_cd_unidade_negocio = 647)
26. 0.028 0.028 ↑ 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.007 rows=1 loops=4)

  • Index Cond: (vei_cd_venda = ven.ven_cd_venda)
27. 0.025 0.025 ↓ 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.005..0.005 rows=0 loops=5)

  • Index Cond: (abt_cd_venda_item = vei.vei_cd_venda_item)
  • Filter: (NOT abt_bl_afericao)
28. 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)
29. 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)
30. 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)
31. 0.000 0.028 ↓ 0.0 0 1

Subquery Scan on *SELECT* 2 (cost=38.66..38.73 rows=1 width=216) (actual time=0.028..0.028 rows=0 loops=1)

32. 0.001 0.028 ↓ 0.0 0 1

GroupAggregate (cost=38.66..38.71 rows=1 width=132) (actual time=0.028..0.028 rows=0 loops=1)

  • Group Key: abt_2.abt_cd_substituicao, 0, 0, ((abt_2.abt_vl_encerrante - abt_2.abt_vl_volume_abastecido)), abt_2.abt_vl_encerrante, 0, abt_2.abt_vl_volume_abastecido, abt_2.abt_vl_abastecimento, abt_2.abt_vl_preco_unitario, bom_1.bom_ds_bomba, bic_1.bic_cd_bico, pro_1.pro_cd_produto, abt_2.abt_dt_abastecimento, cai_1.cai_cd_caixa
33. 0.015 0.027 ↓ 0.0 0 1

Sort (cost=38.66..38.66 rows=1 width=132) (actual time=0.027..0.027 rows=0 loops=1)

  • Sort Key: abt_2.abt_cd_substituicao, ((abt_2.abt_vl_encerrante - abt_2.abt_vl_volume_abastecido)), abt_2.abt_vl_encerrante, abt_2.abt_vl_volume_abastecido, abt_2.abt_vl_abastecimento, abt_2.abt_vl_preco_unitario, bom_1.bom_ds_bomba, bic_1.bic_cd_bico, pro_1.pro_cd_produto, abt_2.abt_dt_abastecimento
  • Sort Method: quicksort Memory: 25kB
34. 0.001 0.012 ↓ 0.0 0 1

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

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

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

36. 0.000 0.011 ↓ 0.0 0 1

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

37. 0.000 0.011 ↓ 0.0 0 1

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

38. 0.001 0.011 ↓ 0.0 0 1

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

39. 0.010 0.010 ↓ 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.010..0.010 rows=0 loops=1)

  • Index Cond: (aba_cd_caixa = 1353808)
40. 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))
41. 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)
42. 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)
43. 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)
44. 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)
45. 0.010 162.238 ↑ 1.0 12 1

Subquery Scan on *SELECT* 3 (cost=291,439.61..3,703,503.55 rows=12 width=319) (actual time=152.251..162.238 rows=12 loops=1)

46. 0.020 162.228 ↑ 1.0 12 1

Nested Loop (cost=291,439.61..3,703,503.25 rows=12 width=151) (actual time=152.248..162.228 rows=12 loops=1)

47.          

Initplan (for Nested Loop)

48. 0.002 0.014 ↑ 1.0 1 1

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

49. 0.012 0.012 ↑ 1.0 1 1

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

  • Index Cond: (cai_cd_caixa = 1353808)
50. 0.002 0.010 ↑ 1.0 1 1

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

51. 0.008 0.008 ↑ 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.008..0.008 rows=1 loops=1)

  • Index Cond: (cai_cd_caixa = 1353808)
52. 0.011 1.784 ↓ 1.3 16 1

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

  • Join Filter: (abt_3.abt_cd_bico = bic_2.bic_cd_bico)
53. 0.014 1.693 ↑ 1.0 16 1

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

54. 0.006 1.647 ↑ 1.0 16 1

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

55. 1.577 1.577 ↑ 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.059..1.577 rows=16 loops=1)

  • Filter: (bic_cd_unidade_negocio = 647)
  • Rows Removed by Filter: 3169
56. 0.064 0.064 ↑ 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.004..0.004 rows=1 loops=16)

  • Index Cond: (pro_cd_produto = bic_2.bic_cd_produto)
57. 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)
58. 0.002 0.080 ↓ 0.0 0 16

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

59. 0.002 0.078 ↓ 0.0 0 1

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

60. 0.006 0.051 ↑ 201.2 5 1

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

61. 0.002 0.025 ↑ 111.2 4 1

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

62. 0.011 0.011 ↑ 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.011..0.011 rows=1 loops=1)

  • Index Cond: (cai_cd_caixa = 1353808)
  • Heap Fetches: 1
63. 0.012 0.012 ↑ 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.009..0.012 rows=4 loops=1)

  • Index Cond: (ven_cd_caixa = 1353808)
64. 0.020 0.020 ↑ 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.005..0.005 rows=1 loops=4)

  • Index Cond: (vei_cd_venda = ven_1.ven_cd_venda)
65. 0.025 0.025 ↓ 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.005..0.005 rows=0 loops=5)

  • Index Cond: (abt_cd_venda_item = vei_1.vei_cd_venda_item)
66. 0.000 160.400 ↑ 1.0 1 16

Limit (cost=291,431.20..291,431.38 rows=1 width=40) (actual time=10.025..10.025 rows=1 loops=16)

67.          

Initplan (for Limit)

68. 0.007 0.031 ↑ 1.0 1 1

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

69. 0.024 0.024 ↑ 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.023..0.024 rows=1 loops=1)

  • Index Cond: (cai_cd_caixa = 1353808)
70. 0.048 160.384 ↑ 854.0 1 16

GroupAggregate (cost=291,428.55..291,577.37 rows=854 width=40) (actual time=10.024..10.024 rows=1 loops=16)

  • Group Key: abt_4.abt_cd_substituicao
71. 0.112 160.336 ↑ 935.2 15 16

Sort (cost=291,428.55..291,463.62 rows=14,028 width=12) (actual time=10.020..10.021 rows=15 loops=16)

  • Sort Key: abt_4.abt_cd_substituicao DESC
  • Sort Method: quicksort Memory: 25kB
72. 1.444 160.224 ↑ 467.6 30 16

Hash Join (cost=17,965.09..290,462.30 rows=14,028 width=12) (actual time=9.345..10.014 rows=30 loops=16)

  • Hash Cond: (ven_2.ven_cd_caixa = cai_3.cai_cd_caixa)
73. 0.000 13.648 ↑ 331.4 127 16

Nested Loop (cost=1.70..272,388.44 rows=42,084 width=16) (actual time=0.012..0.853 rows=127 loops=16)

74. 0.000 7.856 ↑ 331.4 127 16

Nested Loop (cost=1.14..160,064.95 rows=42,084 width=16) (actual time=0.009..0.491 rows=127 loops=16)

75. 1.424 1.424 ↑ 311.7 135 16

Index Scan using abastecimento_idx_cd_bico on abastecimento abt_4 (cost=0.57..45,286.51 rows=42,084 width=16) (actual time=0.005..0.089 rows=135 loops=16)

  • Index Cond: (abt_cd_bico = bic_2.bic_cd_bico)
76. 6.480 6.480 ↑ 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.003..0.003 rows=1 loops=2,160)

  • Index Cond: (vei_cd_venda_item = abt_4.abt_cd_venda_item)
77. 6.075 6.075 ↑ 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.003..0.003 rows=1 loops=2,025)

  • Index Cond: (ven_cd_venda = vei_2.vei_cd_venda)
78. 15.206 145.132 ↑ 1.9 89,769 1

Hash (cost=15,844.04..15,844.04 rows=169,548 width=4) (actual time=145.132..145.132 rows=89,769 loops=1)

  • Buckets: 262144 Batches: 1 Memory Usage: 5204kB
79. 129.926 129.926 ↑ 1.9 89,769 1

Seq Scan on caixa cai_3 (cost=0.00..15,844.04 rows=169,548 width=4) (actual time=0.054..129.926 rows=89,769 loops=1)

  • Filter: (cai_ts_abertura < $15)
  • Rows Removed by Filter: 418171
80.          

SubPlan (for GroupAggregate)

81. 0.000 0.000 ↓ 0.0 0

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

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

Initplan (for Hash Join)

83. 0.000 0.000 ↓ 0.0 0

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

84. 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)
85. 0.000 0.000 ↓ 0.0 0

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

86. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (abt_cd_bico = abt.bico)
  • Filter: (abt_dt_abastecimento >= $3)
87. 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)
88. 0.000 0.000 ↓ 0.0 0

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

89. 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)
90. 0.000 0.264 ↑ 1.0 1 12

Aggregate (cost=1,121.43..1,121.44 rows=1 width=32) (actual time=0.022..0.022 rows=1 loops=12)

91.          

Initplan (for Aggregate)

92. 0.000 0.000 ↓ 0.0 0

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

93. 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)
94. 0.000 0.264 ↓ 0.0 0 12

Nested Loop (cost=1,088.69..1,118.78 rows=1 width=6) (actual time=0.022..0.022 rows=0 loops=12)

95. 0.012 0.264 ↓ 0.0 0 12

Nested Loop (cost=1,088.27..1,116.23 rows=1 width=14) (actual time=0.022..0.022 rows=0 loops=12)

96. 0.024 0.252 ↓ 0.0 0 12

Nested Loop (cost=1,087.70..1,113.49 rows=1 width=14) (actual time=0.021..0.021 rows=0 loops=12)

97. 0.000 0.228 ↓ 0.0 0 12

Bitmap Heap Scan on abastecimento b (cost=1,087.14..1,110.70 rows=1 width=14) (actual time=0.019..0.019 rows=0 loops=12)

  • Recheck Cond: ((abt_cd_bico = abt.bico) AND (abt_cd_unidade_negocio = 647) AND (abt_dt_fiscal >= (max(abt.maior_data))))
  • Filter: ((abt_vl_encerrante < (max(abt.encerrante_final_abt))) AND (abt_cd_substituicao = abt.substituicao))
98. 0.048 0.228 ↓ 0.0 0 12

BitmapAnd (cost=1,087.14..1,087.14 rows=21 width=0) (actual time=0.019..0.019 rows=0 loops=12)

99. 0.156 0.156 ↑ 237.8 177 12

Bitmap Index Scan on abastecimento_idx_cd_bico (cost=0.00..443.80 rows=42,084 width=0) (actual time=0.013..0.013 rows=177 loops=12)

  • Index Cond: (abt_cd_bico = abt.bico)
100. 0.024 0.024 ↓ 0.0 0 12

Bitmap Index Scan on abastecimento_abt_cd_unidade_negocio_abt_dt_fiscal_idx (cost=0.00..643.09 rows=49,292 width=0) (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))))
101. 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)
102. 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))
103. 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 > $17) AND (cai_cd_unidade_negocio = 647))
104. 0.000 0.156 ↑ 1.0 1 12

Aggregate (cost=162,003.32..162,003.33 rows=1 width=64) (actual time=0.013..0.013 rows=1 loops=12)

105.          

Initplan (for Aggregate)

106. 0.000 0.000 ↓ 0.0 0

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

107. 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)
108. 0.012 0.156 ↓ 0.0 0 12

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

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

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

110. 0.000 0.144 ↓ 0.0 0 12

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

111. 0.036 0.144 ↓ 0.0 0 12

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

112. 0.060 0.060 ↓ 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.003..0.005 rows=4 loops=12)

  • Index Cond: (ven_cd_caixa = 1353808)
  • Filter: ((ven_cd_unidade_negocio = 647) AND (ven_fl_cancelada = 'N'::bpchar))
113. 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))
114. 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 < $24) AND (abt_cd_unidade_negocio = 647) AND (abt_cd_bico = abt.bico) AND (abt_cd_substituicao = abt.substituicao))
115. 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)
116. 0.000 0.000 ↓ 0.0 0

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

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

Nested Loop (cost=1.14..160,883.35 rows=42,084 width=12) (never executed)

118. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (abt_cd_bico = abt.bico)
119. 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)
120. 0.000 0.000 ↓ 0.0 0

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

121. 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.357 ms
Execution time : 164.413 ms