explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 9vQ2

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

Hash Join (cost=945.69..5,117.79 rows=11 width=46) (actual time=249.001..3,422.885 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.007 0.007 ↑ 1.0 1 1

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

4.          

CTE cte_descricao_tabela_preco

5. 0.057 0.057 ↑ 1.0 31 1

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

6.          

CTE cte_produto

7. 0.752 0.752 ↑ 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.752 rows=1,717 loops=1)

8.          

CTE cte_orgven_cliente_tabela_preco

9. 31.863 244.854 ↑ 1.0 24 1

HashAggregate (cost=641.65..641.89 rows=24 width=8) (actual time=244.846..244.854 rows=24 loops=1)

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

Initplan (forHashAggregate)

11. 0.047 0.047 ↑ 1.0 1 1

Result (cost=0.00..0.26 rows=1 width=0) (actual time=0.046..0.047 rows=1 loops=1)

12. 54.721 212.944 ↓ 58.3 63,565 1

Nested Loop (cost=0.71..635.94 rows=1,090 width=8) (actual time=0.102..212.944 rows=63,565 loops=1)

13. 11.664 11.664 ↓ 58.5 20,937 1

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

  • Index Cond: (s_codvendedor = $3)
14. 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
15. 1,043.599 2,131.806 ↓ 663.5 1,605,018 1

Nested Loop (cost=1.27..4,155.11 rows=2,419 width=55) (actual time=244.976..2,131.806 rows=1,605,018 loops=1)

16. 0.113 245.189 ↓ 22.0 22 1

Hash Join (cost=0.84..1.70 rows=1 width=76) (actual time=244.923..245.189 rows=22 loops=1)

  • Hash Cond: ((t3.u_orgvenda = t5.u_orgvenda) AND (t3.s_codtabela = t5.s_codtabela))
17. 0.181 0.181 ↑ 1.0 31 1

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

18. 0.020 244.895 ↑ 1.0 24 1

Hash (cost=0.48..0.48 rows=24 width=36) (actual time=244.895..244.895 rows=24 loops=1)

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

CTE Scan on cte_orgven_cliente_tabela_preco t5 (cost=0.00..0.48 rows=24 width=36) (actual time=244.849..244.875 rows=24 loops=1)

20. 843.018 843.018 ↑ 1.0 72,955 22

Index Scan using t_tabela_preco_idx01 on t_tabela_preco t1 (cost=0.43..3,403.61 rows=74,979 width=45) (actual time=0.042..38.319 rows=72,955 loops=22)

  • Index Cond: ((u_orgvenda = t3.u_orgvenda) AND (s_codtabela = t3.s_codtabela))
21. 0.821 3.997 ↓ 190.8 1,717 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 94kB
22. 1.194 3.176 ↓ 190.8 1,717 1

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

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

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

24. 0.002 0.011 ↑ 1.0 1 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
25. 0.009 0.009 ↑ 1.0 1 1

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