# Result: xSvO

Settings
# exclusive inclusive rows x rows loops node
1. 0.008 6,485.836 ↓ 2.0 2 1

(cost=1,038.77..1,038.78 rows=1 width=132) (actual time=6,485.829..6,485.836 rows=2 loops=1)

2. 0.017 6,485.828 ↓ 2.0 2 1

(cost=1,038.77..1,038.77 rows=1 width=132) (actual time=6,485.826..6,485.828 rows=2 loops=1)

• Sort Method: quicksort Memory: 25kB
3. 0.078 6,485.811 ↓ 2.0 2 1

Group (cost=1,038.49..1,038.76 rows=1 width=132) (actual time=6,485.797..6,485.811 rows=2 loops=1)

4. 0.025 6,485.733 ↓ 2.0 2 1

(cost=1,038.49..1,038.50 rows=1 width=100) (actual time=6,485.730..6,485.733 rows=2 loops=1)

• Sort Method: quicksort Memory: 25kB
5. 1.920 6,485.708 ↓ 2.0 2 1

(cost=282.59..1,038.48 rows=1 width=100) (actual time=6,400.652..6,485.708 rows=2 loops=1)

6. 0.015 6,319.156 ↓ 2.0 2 1

(cost=276.18..1,008.79 rows=1 width=12) (actual time=6,315.997..6,319.156 rows=2 loops=1)

• Output: estoque.codigo_cda
7. 0.011 6,319.111 ↓ 2.0 2 1

(cost=276.18..1,007.73 rows=1 width=20) (actual time=6,315.977..6,319.111 rows=2 loops=1)

• Output: estoque.codigo_cda, cnpj.programa_fk
• Inner Unique: true
8. 0.011 6,319.088 ↓ 2.0 2 1

(cost=276.04..1,007.43 rows=1 width=28) (actual time=6,315.963..6,319.088 rows=2 loops=1)

• Output: conta.fonte_fk, estoque.codigo_cda, cnpj.programa_fk
• Inner Unique: true
9. 0.018 6,319.065 ↓ 2.0 2 1

(cost=275.91..1,007.13 rows=1 width=36) (actual time=6,315.950..6,319.065 rows=2 loops=1)

• Output: conta.atividade_fk, conta.fonte_fk, estoque.codigo_cda, cnpj.programa_fk
• Inner Unique: true
10. 1.849 6,319.015 ↓ 2.0 2 1

(cost=275.64..1,006.58 rows=1 width=36) (actual time=6,315.925..6,319.015 rows=2 loops=1)

• Output: conta.atividade_fk, conta.fonte_fk, conta.cnpj_fk, estoque.codigo_cda
• Join Filter: (estoque.conta_fk = conta.id)
• Rows Removed by Join Filter: 1942
11. 0.048 0.048 ↑ 1.0 18 1

Index Scan using idx_conta_uf_fk_atividade_fk_conta_fk on sigest.tb_conta conta (cost=0.27..8.23 rows=18 width=32) (actual time=0.018..0.048 rows=18 loops=1)

• Output: conta.id, conta.uf_fk, conta.cnpj_fk, conta.atividade_fk, conta.fonte_fk, conta.pgpm, conta.estoque_por_preco, conta.controlar_validade, conta.id_antigo, conta.uf_antigo
• Index Cond: ((conta.uf_fk)::text = 'ES'::text)
12. 1.759 6,317.118 ↓ 10.8 108 18

(cost=275.37..995.67 rows=10 width=20) (actual time=256.523..350.951 rows=108 loops=18)

• Output: estoque.conta_fk, estoque.codigo_cda
13. 0.239 6,315.359 ↓ 10.8 108 1

(cost=275.37..995.62 rows=10 width=20) (actual time=4,617.385..6,315.359 rows=108 loops=1)

• Output: estoque.conta_fk, estoque.codigo_cda
14. 0.019 0.019 ↑ 1.0 1 1

Index Scan using idx_tb_produto_codigo on sigest.tb_produto produto (cost=0.28..2.50 rows=1 width=8) (actual time=0.015..0.019 rows=1 loops=1)

• Index Cond: ((produto.codigo)::text = '000220002'::text)
• Filter: ("substring"((produto.codigo)::text, 1, 5) = '00022'::text)
15. 13.274 6,315.101 ↓ 9.0 108 1

Bitmap Heap Scan on sigest.tb_estoque estoque (cost=275.09..993.00 rows=12 width=28) (actual time=4,617.362..6,315.101 rows=108 loops=1)

• Recheck Cond: ((estoque.produto_fk = produto.id) AND (estoque.codigo_cda IS NOT NULL))
• Filter: ((SubPlan 1) <> '0'::numeric)
• Rows Removed by Filter: 3124
• Heap Blocks: exact=703
16. 0.056 2.659 ↓ 0.0 0 1

BitmapAnd (cost=275.09..275.09 rows=12 width=0) (actual time=2.658..2.659 rows=0 loops=1)

17. 0.456 0.456 ↓ 14.0 3,279 1

Bitmap Index Scan on idx_tb_estoque_produto_fk (cost=0.00..3.28 rows=235 width=0) (actual time=0.455..0.456 rows=3,279 loops=1)

• Index Cond: (estoque.produto_fk = produto.id)
18. 2.147 2.147 ↑ 1.0 24,458 1

Bitmap Index Scan on idx_tb_estoque_codigo_cda_text (cost=0.00..265.46 rows=24,485 width=0) (actual time=2.146..2.147 rows=24,458 loops=1)

• Index Cond: (estoque.codigo_cda IS NOT NULL)
19.

SubPlan (for Bitmap Heap Scan)

20. 19.392 6,299.168 ↑ 1.0 1 3,232

(cost=58.71..58.71 rows=1 width=21) (actual time=1.945..1.949 rows=1 loops=3,232)

21. 2,453.088 6,279.776 ↑ 60.0 1 3,232

(cost=58.71..58.86 rows=60 width=21) (actual time=1.942..1.943 rows=1 loops=3,232)

• Sort Key: tb_kardex.data DESC, tb_kardex.id DESC
• Sort Method: top-N heapsort Memory: 25kB
22. 3,826.688 3,826.688 ↓ 12.2 735 3,232

Index Scan using idx_tb_kardex_estoque_fk_data_tipo_armazenagem_tipo_dif_9 on sigest.tb_kardex (cost=0.56..58.41 rows=60 width=21) (actual time=0.012..1.184 rows=735 loops=3,232)

• Index Cond: ((tb_kardex.estoque_fk = estoque.id) AND (tb_kardex.data <= '2019-08-08 23:59:59'::timestamp without time zone) AND (tb_kardex.tipo_armazenagem = true))
• Filter: tb_kardex.tipo_armazenagem
23. 0.032 0.032 ↑ 1.0 1 2

Index Only Scan using idx_cnpj_id_programa_fk on sigest.tb_cnpj cnpj (cost=0.27..0.53 rows=1 width=16) (actual time=0.015..0.016 rows=1 loops=2)

• Output: cnpj.id, cnpj.programa_fk
• Index Cond: ((cnpj.id = conta.cnpj_fk) AND (cnpj.programa_fk = 2))
• Heap Fetches: 2
24. 0.012 0.012 ↑ 1.0 1 2

• Heap Fetches: 0
25. 0.012 0.012 ↑ 1.0 1 2

Index Only Scan using pk_tb_fonte on sigest.tb_fonte fonte (cost=0.13..0.27 rows=1 width=8) (actual time=0.005..0.006 rows=1 loops=2)

• Output: fonte.id
• Index Cond: (fonte.id = conta.fonte_fk)
• Heap Fetches: 0
26. 0.030 0.030 ↑ 1.0 1 2

Seq Scan on sigest.tb_programa programa (cost=0.00..1.05 rows=1 width=8) (actual time=0.009..0.015 rows=1 loops=2)

• Output: programa.id, programa.codigo, programa.nome, programa.descricao
• Filter: (programa.id = 2)
• Rows Removed by Filter: 3
27. 164.632 164.632 ↑ 1.0 1 2

Foreign Scan on public.vw_armazem_dados_basicos view_armazem_dados_basicos (cost=6.41..29.68 rows=1 width=132) (actual time=82.313..82.316 rows=1 loops=2)