explain.depesz.com

PostgreSQL's explain analyze made readable

Result: PpjJ : Optimization for: Optimization for: plan #Res3; plan #xu0q

Settings

Optimization path:

# exclusive inclusive rows x rows loops node
1. 0.009 0.120 ↑ 1.0 2 1

HashAggregate (cost=79.80..79.82 rows=2 width=181) (actual time=0.119..0.120 rows=2 loops=1)

  • Group Key: c.id, c.numero, c.data_venda, c.data_embarque, c.vendedor_id, c.empresa_id, c.produto, c.produto_cancelado
2.          

CTE consulta

3. 0.001 0.104 ↓ 2.0 4 1

Append (cost=0.58..79.71 rows=2 width=181) (actual time=0.053..0.104 rows=4 loops=1)

4. 0.002 0.059 ↓ 2.0 2 1

Nested Loop (cost=0.58..37.59 rows=1 width=181) (actual time=0.052..0.059 rows=2 loops=1)

5. 0.001 0.049 ↓ 2.0 2 1

Nested Loop (cost=0.43..29.41 rows=1 width=198) (actual time=0.045..0.049 rows=2 loops=1)

6. 0.001 0.044 ↓ 2.0 2 1

Nested Loop (cost=0.28..25.22 rows=1 width=96) (actual time=0.042..0.044 rows=2 loops=1)

7. 0.003 0.037 ↑ 1.0 1 1

Nested Loop (cost=0.15..17.05 rows=1 width=72) (actual time=0.037..0.037 rows=1 loops=1)

8. 0.026 0.026 ↑ 1.0 1 1

Seq Scan on vendas v (cost=0.00..3.54 rows=1 width=72) (actual time=0.025..0.026 rows=1 loops=1)

  • Filter: ((situacao <> 'C'::bpchar) AND (pagante_id = '4298475b-8b2b-4396-9f0c-a534eed4768a'::uuid))
  • Rows Removed by Filter: 31
9. 0.008 0.008 ↑ 1.0 1 1

Index Scan using pk_empresa on empresa e (cost=0.15..8.17 rows=1 width=16) (actual time=0.008..0.008 rows=1 loops=1)

  • Index Cond: (empresa_id = v.empresa_id)
  • Filter: ((ativa)::bpchar = '1'::bpchar)
10. 0.006 0.006 ↓ 2.0 2 1

Index Scan using idx_vendas_produtos_vendas_id on vendas_produtos vp (cost=0.14..8.15 rows=1 width=40) (actual time=0.004..0.006 rows=2 loops=1)

  • Index Cond: (vendas_id = v.id)
  • Filter: (status <> 2)
11. 0.004 0.004 ↑ 1.0 1 2

Index Scan using pk_produtos on produtos (cost=0.15..4.17 rows=1 width=134) (actual time=0.002..0.002 rows=1 loops=2)

  • Index Cond: (id = vp.produto_id)
12. 0.008 0.008 ↑ 1.0 1 2

Index Only Scan using pk_pessoa on pessoa pagante (cost=0.15..8.17 rows=1 width=16) (actual time=0.004..0.004 rows=1 loops=2)

  • Index Cond: (pessoa_id = '4298475b-8b2b-4396-9f0c-a534eed4768a'::uuid)
  • Heap Fetches: 2
13. 0.002 0.044 ↓ 2.0 2 1

Nested Loop (cost=0.57..42.10 rows=1 width=181) (actual time=0.037..0.044 rows=2 loops=1)

14. 0.001 0.038 ↓ 2.0 2 1

Nested Loop (cost=0.42..33.92 rows=1 width=198) (actual time=0.033..0.038 rows=2 loops=1)

15. 0.002 0.035 ↓ 2.0 2 1

Nested Loop (cost=0.28..29.73 rows=1 width=96) (actual time=0.031..0.035 rows=2 loops=1)

16. 0.000 0.029 ↓ 2.0 2 1

Nested Loop (cost=0.14..25.56 rows=1 width=96) (actual time=0.027..0.029 rows=2 loops=1)

17. 0.001 0.025 ↑ 1.0 1 1

Nested Loop (cost=0.00..17.39 rows=1 width=56) (actual time=0.024..0.025 rows=1 loops=1)

  • Join Filter: (v_1.empresa_id = e_1.empresa_id)
18. 0.013 0.013 ↑ 2.0 1 1

Seq Scan on vendas v_1 (cost=0.00..3.45 rows=2 width=56) (actual time=0.012..0.013 rows=1 loops=1)

  • Filter: (situacao <> 'C'::bpchar)
  • Rows Removed by Filter: 31
19. 0.004 0.011 ↑ 2.0 1 1

Materialize (cost=0.00..13.88 rows=2 width=16) (actual time=0.011..0.011 rows=1 loops=1)

20. 0.007 0.007 ↑ 2.0 1 1

Seq Scan on empresa e_1 (cost=0.00..13.88 rows=2 width=16) (actual time=0.007..0.007 rows=1 loops=1)

  • Filter: ((ativa)::bpchar = '1'::bpchar)
21. 0.004 0.004 ↓ 2.0 2 1

Index Scan using idx_vendas_produtos_vendas_id on vendas_produtos vp_1 (cost=0.14..8.15 rows=1 width=56) (actual time=0.002..0.004 rows=2 loops=1)

  • Index Cond: (vendas_id = v_1.id)
  • Filter: (status <> 2)
22. 0.004 0.004 ↑ 1.0 1 2

Index Scan using idx_vendas_produtos_passageiros_vendas_produtos_id on vendas_produtos_passageiros vpp (cost=0.14..4.16 rows=1 width=32) (actual time=0.002..0.002 rows=1 loops=2)

  • Index Cond: (vendas_produtos_id = vp_1.vendas_produtos_id)
  • Filter: (pessoa_id = '4298475b-8b2b-4396-9f0c-a534eed4768a'::uuid)
23. 0.002 0.002 ↑ 1.0 1 2

Index Scan using pk_produtos on produtos produtos_1 (cost=0.15..4.17 rows=1 width=134) (actual time=0.001..0.001 rows=1 loops=2)

  • Index Cond: (id = vp_1.produto_id)
24. 0.004 0.004 ↑ 1.0 1 2

Index Only Scan using pk_pessoa on pessoa passageiro (cost=0.15..8.17 rows=1 width=16) (actual time=0.002..0.002 rows=1 loops=2)

  • Index Cond: (pessoa_id = '4298475b-8b2b-4396-9f0c-a534eed4768a'::uuid)
  • Heap Fetches: 2
25. 0.111 0.111 ↓ 2.0 4 1

CTE Scan on consulta c (cost=0.00..0.04 rows=2 width=181) (actual time=0.055..0.111 rows=4 loops=1)

Planning time : 3.605 ms