explain.depesz.com

PostgreSQL's explain analyze made readable

Result: Res3

Settings

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 0.021 2,205.545 ↓ 8.0 8 1

Nested Loop Left Join (cost=1,693.78..62,257.86 rows=1 width=195) (actual time=111.757..2,205.545 rows=8 loops=1)

2. 36.654 2,205.468 ↓ 8.0 8 1

Hash Left Join (cost=1,693.65..62,257.69 rows=1 width=112) (actual time=111.734..2,205.468 rows=8 loops=1)

  • Hash Cond: (vp.vendas_produtos_id = vpp.vendas_produtos_id)
  • Filter: ((pagante.pessoa_id = '9a8fdea4-a91f-4fc7-95a8-66abe6192b82'::uuid) OR (passageiro.pessoa_id = '9a8fdea4-a91f-4fc7-95a8-66abe6192b82'::uuid))
  • Rows Removed by Filter: 243722
3. 149.748 2,168.802 ↓ 10.0 243,730 1

Nested Loop Left Join (cost=1,184.05..61,656.56 rows=24,384 width=128) (actual time=3.055..2,168.802 rows=243,730 loops=1)

4. 0.000 1,287.864 ↓ 10.0 243,730 1

Nested Loop (cost=1,183.63..45,656.49 rows=24,384 width=112) (actual time=2.877..1,287.864 rows=243,730 loops=1)

5. 20.770 317.872 ↓ 10.0 243,729 1

Nested Loop (cost=1,183.21..26,182.39 rows=24,384 width=72) (actual time=2.776..317.872 rows=243,729 loops=1)

6. 0.032 0.032 ↓ 10.0 10 1

Seq Scan on empresa e (cost=0.00..1.13 rows=1 width=16) (actual time=0.020..0.032 rows=10 loops=1)

  • Filter: ((ativa)::bpchar = '1'::bpchar)
7. 274.420 297.070 ↑ 1.1 24,373 10

Bitmap Heap Scan on vendas v (cost=1,183.21..25,910.33 rows=27,093 width=72) (actual time=2.568..29.707 rows=24,373 loops=10)

  • Recheck Cond: (empresa_id = e.empresa_id)
  • Filter: (situacao <> 'C'::bpchar)
  • Rows Removed by Filter: 588
  • Heap Blocks: exact=30760
8. 22.650 22.650 ↑ 1.1 24,961 10

Bitmap Index Scan on idx_vendas_empresa_id (cost=0.00..1,176.43 rows=27,735 width=0) (actual time=2.265..2.265 rows=24,961 loops=10)

  • Index Cond: (empresa_id = e.empresa_id)
9. 974.916 974.916 ↑ 1.0 1 243,729

Index Scan using idx_vendas_produtos_vendas_id on vendas_produtos vp (cost=0.42..0.79 rows=1 width=56) (actual time=0.004..0.004 rows=1 loops=243,729)

  • Index Cond: (vendas_id = v.id)
  • Filter: (status <> 2)
10. 731.190 731.190 ↑ 1.0 1 243,730

Index Only Scan using pk_pessoa on pessoa pagante (cost=0.42..0.66 rows=1 width=16) (actual time=0.003..0.003 rows=1 loops=243,730)

  • Index Cond: (pessoa_id = v.pagante_id)
  • Heap Fetches: 243730
11. 0.001 0.012 ↓ 0.0 0 1

Hash (cost=508.85..508.85 rows=60 width=48) (actual time=0.012..0.012 rows=0 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 8kB
12. 0.000 0.011 ↓ 0.0 0 1

Nested Loop Left Join (cost=0.42..508.85 rows=60 width=48) (actual time=0.011..0.011 rows=0 loops=1)

13. 0.011 0.011 ↓ 0.0 0 1

Seq Scan on vendas_produtos_passageiros vpp (cost=0.00..10.60 rows=60 width=32) (actual time=0.011..0.011 rows=0 loops=1)

14. 0.000 0.000 ↓ 0.0 0

Index Only Scan using pk_pessoa on pessoa passageiro (cost=0.42..8.30 rows=1 width=16) (never executed)

  • Index Cond: (pessoa_id = vpp.pessoa_id)
  • Heap Fetches: 0
15. 0.056 0.056 ↑ 1.0 1 8

Index Scan using pk_produtos on produtos (cost=0.14..0.16 rows=1 width=134) (actual time=0.007..0.007 rows=1 loops=8)

  • Index Cond: (id = vp.produto_id)
Planning time : 19.956 ms