explain.depesz.com

PostgreSQL's explain analyze made readable

Result: Wb5

Settings
# exclusive inclusive rows x rows loops node
1. 1,253.793 3,300.553 ↓ 137,511.8 1,512,630 1

Hash Join (cost=946.31..5,117.11 rows=11 width=46) (actual time=242.139..3,300.553 rows=1,512,630 loops=1)

  • Hash Cond: ((t1.u_orgvenda = t2.u_orgvenda) AND (t1.s_codproduto = t4.s_codproduto))
2.          

CTE cte_orgven

3. 0.004 0.004 ↑ 1.0 1 1

Seq Scan on t_orgven (cost=0.00..4.01 rows=1 width=8) (actual time=0.004..0.004 rows=1 loops=1)

4.          

CTE cte_descricao_tabela_preco

5. 0.015 0.015 ↑ 1.0 31 1

Seq Scan on t_descricao_tabela_preco (cost=0.00..4.31 rows=31 width=11) (actual time=0.003..0.015 rows=31 loops=1)

6.          

CTE cte_produto

7. 0.861 0.861 ↑ 1.0 1,717 1

Seq Scan on t_produto (cost=0.00..253.17 rows=1,717 width=13) (actual time=0.005..0.861 rows=1,717 loops=1)

8. 1,000.528 2,042.071 ↓ 663.8 1,605,018 1

Nested Loop (cost=643.78..4,796.33 rows=2,418 width=55) (actual time=237.422..2,042.071 rows=1,605,018 loops=1)

9. 0.295 237.707 ↓ 22.0 22 1

Merge Join (cost=643.35..643.77 rows=1 width=48) (actual time=237.360..237.707 rows=22 loops=1)

  • Merge Cond: ((t3.u_orgvenda = z2.u_orgvenda) AND (t3.s_codtabela = z2.s_codtabela))
10. 0.075 0.111 ↑ 1.0 31 1

Sort (cost=1.39..1.47 rows=31 width=40) (actual time=0.088..0.111 rows=31 loops=1)

  • Sort Key: t3.u_orgvenda, t3.s_codtabela
  • Sort Method: quicksort Memory: 26kB
11. 0.036 0.036 ↑ 1.0 31 1

CTE Scan on cte_descricao_tabela_preco t3 (cost=0.00..0.62 rows=31 width=40) (actual time=0.005..0.036 rows=31 loops=1)

12. 0.074 237.301 ↓ 1.0 24 1

Sort (cost=641.96..642.02 rows=23 width=8) (actual time=237.264..237.301 rows=24 loops=1)

  • Sort Key: z2.u_orgvenda, z2.s_codtabela
  • Sort Method: quicksort Memory: 26kB
13. 31.814 237.227 ↓ 1.0 24 1

HashAggregate (cost=640.98..641.21 rows=23 width=8) (actual time=237.218..237.227 rows=24 loops=1)

  • Group Key: z2.u_orgvenda, z2.s_codtabela
14.          

Initplan (forHashAggregate)

15. 0.050 0.050 ↑ 1.0 1 1

Result (cost=0.00..0.26 rows=1 width=0) (actual time=0.049..0.050 rows=1 loops=1)

16. 47.206 205.363 ↓ 58.2 63,565 1

Nested Loop (cost=0.71..635.26 rows=1,093 width=8) (actual time=0.110..205.363 rows=63,565 loops=1)

17. 11.598 11.598 ↓ 58.5 20,937 1

Index Scan using t_orgven_vendedor_cliente_s_codvendedor on t_orgven_vendedor_cliente z1 (cost=0.29..219.20 rows=358 width=9) (actual time=0.083..11.598 rows=20,937 loops=1)

  • Index Cond: (s_codvendedor = $3)
18. 146.559 146.559 ↑ 1.0 3 20,937

Index Only Scan using t_orgven_cliente_tabela_preco_pkey on t_orgven_cliente_tabela_preco z2 (cost=0.41..1.13 rows=3 width=13) (actual time=0.006..0.007 rows=3 loops=20,937)

  • Index Cond: ((u_orgvenda = z1.u_orgvenda) AND (s_codcliente = z1.s_codcliente))
  • Heap Fetches: 0
19. 803.836 803.836 ↑ 1.0 72,955 22

Index Scan using t_tabela_preco_idx01 on t_tabela_preco t1 (cost=0.43..3,403.01 rows=74,955 width=45) (actual time=0.038..36.538 rows=72,955 loops=22)

  • Index Cond: ((u_orgvenda = t3.u_orgvenda) AND (s_codtabela = t3.s_codtabela))
20. 0.959 4.689 ↓ 190.8 1,717 1

Hash (cost=40.90..40.90 rows=9 width=48) (actual time=4.689..4.689 rows=1,717 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 94kB
21. 1.362 3.730 ↓ 190.8 1,717 1

Hash Join (cost=0.03..40.90 rows=9 width=48) (actual time=0.034..3.730 rows=1,717 loops=1)

  • Hash Cond: (t4.u_orgvenda = t2.u_orgvenda)
22. 2.359 2.359 ↑ 1.0 1,717 1

CTE Scan on cte_produto t4 (cost=0.00..34.34 rows=1,717 width=40) (actual time=0.009..2.359 rows=1,717 loops=1)

23. 0.003 0.009 ↑ 1.0 1 1

Hash (cost=0.02..0.02 rows=1 width=8) (actual time=0.009..0.009 rows=1 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
24. 0.006 0.006 ↑ 1.0 1 1

CTE Scan on cte_orgven t2 (cost=0.00..0.02 rows=1 width=8) (actual time=0.004..0.006 rows=1 loops=1)