explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 9g96

Settings
# exclusive inclusive rows x rows loops node
1. 0.008 2,353.685 ↓ 10.0 10 1

Limit (cost=66.37..1,245.14 rows=1 width=862) (actual time=0.567..2,353.685 rows=10 loops=1)

2. 19.328 2,353.677 ↓ 10.0 10 1

Nested Loop (cost=66.37..1,245.14 rows=1 width=862) (actual time=0.566..2,353.677 rows=10 loops=1)

  • Join Filter: ((preco.produto_id)::text = (promo.produto_id)::text)
  • Rows Removed by Join Filter: 100,090
3. 0.019 0.109 ↓ 10.0 10 1

Subquery Scan on promo (cost=1.50..1.52 rows=1 width=174) (actual time=0.062..0.109 rows=10 loops=1)

  • Filter: (promo.promocao = 1)
4. 0.021 0.090 ↓ 10.0 10 1

Unique (cost=1.50..1.50 rows=1 width=802) (actual time=0.060..0.090 rows=10 loops=1)

5. 0.033 0.069 ↓ 11.0 11 1

Sort (cost=1.50..1.50 rows=1 width=802) (actual time=0.059..0.069 rows=11 loops=1)

  • Sort Key: preco_promo.produto_id, preco_promo.precobase
  • Sort Method: quicksort Memory: 25kB
6. 0.036 0.036 ↓ 11.0 11 1

Seq Scan on preco_promocional preco_promo (cost=0.00..1.49 rows=1 width=802) (actual time=0.022..0.036 rows=11 loops=1)

  • Filter: (((COALESCE(filial_id, '1'::character varying))::text = '1'::text) AND ((COALESCE(cliente_id, '1'::character varying))::text = '1'::text) AND ((COALESCE(regiao_id, '1'::character varying))::text = '1'::text) AND ((COALESCE(atividade_id, '1'::character varying))::text = '1'::text) AND ((COALESCE(supervisor_id, '1'::character varying))::text = '1'::text) AND ((COALESCE(praca_id, '4'::character varying))::text = '4'::text) AND ((COALESCE(rede_id, '16'::character varying))::text = '16'::text) AND ((COALESCE(representante_id, '999'::character varying))::text = '999'::text) AND (aplicacallcenter = 1))
  • Rows Removed by Filter: 4
7. 80.647 2,334.240 ↓ 61.0 10,010 10

Hash Left Join (cost=64.87..1,241.58 rows=164 width=778) (actual time=0.053..233.424 rows=10,010 loops=10)

  • Hash Cond: ((produto.id)::text = (produto_agregado.produto_id)::text)
8. 84.509 2,253.570 ↓ 61.0 10,010 10

Hash Left Join (cost=45.19..1,221.46 rows=164 width=770) (actual time=0.048..225.357 rows=10,010 loops=10)

  • Hash Cond: ((produto.id)::text = (produto_similar.produto_id)::text)
9. 137.920 2,169.040 ↓ 61.0 10,010 10

Nested Loop (cost=25.50..1,201.34 rows=164 width=762) (actual time=0.043..216.904 rows=10,010 loops=10)

  • Join Filter: ((preco.produto_id)::text = (produto.id)::text)
10. 134.720 1,630.720 ↓ 61.0 10,010 10

Nested Loop (cost=25.21..1,124.76 rows=164 width=279) (actual time=0.035..163.072 rows=10,010 loops=10)

11. 73.924 995.500 ↓ 60.7 10,010 10

Hash Join (cost=24.92..1,039.21 rows=165 width=180) (actual time=0.026..99.550 rows=10,010 loops=10)

  • Hash Cond: ((figura_tributaria_filial_produto.figuratributaria_id)::text = (figura_tributaria.id)::text)
12. 115.490 921.560 ↓ 20.3 10,010 10

Nested Loop (cost=8.59..1,021.56 rows=494 width=94) (actual time=0.022..92.156 rows=10,010 loops=10)

13. 78.975 205.470 ↓ 20.0 10,010 10

Hash Join (cost=8.17..679.53 rows=500 width=162) (actual time=0.010..20.547 rows=10,010 loops=10)

  • Hash Cond: ((estoque.filial_id)::text = (filial.filialretira_id)::text)
14. 126.470 126.470 ↑ 1.0 20,020 10

Seq Scan on estoque (cost=0.00..613.25 rows=20,020 width=84) (actual time=0.005..12.647 rows=20,020 loops=10)

  • Filter: (ncr >= 2)
15. 0.012 0.025 ↑ 1.0 1 1

Hash (cost=8.16..8.16 rows=1 width=156) (actual time=0.025..0.025 rows=1 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
16. 0.013 0.013 ↑ 1.0 1 1

Index Scan using filial_pkey on filial (cost=0.14..8.16 rows=1 width=156) (actual time=0.012..0.013 rows=1 loops=1)

  • Index Cond: ((id)::text = '1'::text)
17. 600.600 600.600 ↑ 1.0 1 100,100

Index Scan using figura_tributaria_filial_produto_chave_uk on figura_tributaria_filial_produto (cost=0.42..0.68 rows=1 width=12) (actual time=0.006..0.006 rows=1 loops=100,100)

  • Index Cond: (((filial_id)::text = '1'::text) AND ((produto_id)::text = (estoque.produto_id)::text) AND ((chave_tributaria)::text = 'RS-1'::text))
  • Filter: (ncr >= 1)
18. 0.008 0.016 ↑ 18.1 7 1

Hash (cost=14.75..14.75 rows=127 width=166) (actual time=0.016..0.016 rows=7 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
19. 0.008 0.008 ↑ 18.1 7 1

Seq Scan on figura_tributaria (cost=0.00..14.75 rows=127 width=166) (actual time=0.005..0.008 rows=7 loops=1)

  • Filter: (ncr >= 1)
20. 500.500 500.500 ↑ 1.0 1 100,100

Index Scan using preco_uk on preco (cost=0.29..0.52 rows=1 width=99) (actual time=0.005..0.005 rows=1 loops=100,100)

  • Index Cond: (((tabelapreco)::text = '101'::text) AND ((produto_id)::text = (estoque.produto_id)::text))
  • Filter: (ncr >= 5)
21. 400.400 400.400 ↑ 1.0 1 100,100

Index Scan using produto_pkey on produto (cost=0.29..0.45 rows=1 width=483) (actual time=0.004..0.004 rows=1 loops=100,100)

  • Index Cond: ((id)::text = (estoque.produto_id)::text)
  • Filter: (ncr >= 4)
22. 0.007 0.021 ↑ 115.0 1 1

Hash (cost=18.25..18.25 rows=115 width=86) (actual time=0.021..0.021 rows=1 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
23. 0.001 0.014 ↑ 115.0 1 1

Subquery Scan on produto_similar (cost=15.95..18.25 rows=115 width=86) (actual time=0.014..0.014 rows=1 loops=1)

24. 0.008 0.013 ↑ 115.0 1 1

HashAggregate (cost=15.95..17.10 rows=115 width=86) (actual time=0.013..0.013 rows=1 loops=1)

  • Group Key: produto_similar_1.produto_id
25. 0.005 0.005 ↑ 35.0 4 1

Seq Scan on produto_similar produto_similar_1 (cost=0.00..15.25 rows=140 width=78) (actual time=0.004..0.005 rows=4 loops=1)

  • Filter: (ncr >= 1)
26. 0.008 0.023 ↑ 38.3 3 1

Hash (cost=18.25..18.25 rows=115 width=86) (actual time=0.023..0.023 rows=3 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
27. 0.001 0.015 ↑ 38.3 3 1

Subquery Scan on produto_agregado (cost=15.95..18.25 rows=115 width=86) (actual time=0.013..0.015 rows=3 loops=1)

28. 0.009 0.014 ↑ 38.3 3 1

HashAggregate (cost=15.95..17.10 rows=115 width=86) (actual time=0.012..0.014 rows=3 loops=1)

  • Group Key: produto_agregado_1.produto_id
29. 0.005 0.005 ↑ 15.6 9 1

Seq Scan on produto_agregado produto_agregado_1 (cost=0.00..15.25 rows=140 width=78) (actual time=0.003..0.005 rows=9 loops=1)

  • Filter: (ncr >= 1)
Planning time : 23.805 ms
Execution time : 2,354.134 ms