explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 7KN5 : Optimization for: plan #pCAF

Settings

Optimization path:

# exclusive inclusive rows x rows loops node
1. 77.999 3,918.645 ↓ 1.0 26,401 1

GroupAggregate (cost=2,437.94..1,277,698.35 rows=26,338 width=112) (actual time=34.693..3,918.645 rows=26,401 loops=1)

  • Group Key: pq.id_emp, pq.id_prod, pq.id_tipo_estoque
2. 29.283 38.902 ↑ 1.0 26,401 1

Sort (cost=2,437.94..2,503.94 rows=26,401 width=16) (actual time=34.346..38.902 rows=26,401 loops=1)

  • Sort Key: pq.id_emp, pq.id_prod, pq.id_tipo_estoque
  • Sort Method: quicksort Memory: 2477kB
3. 9.619 9.619 ↑ 1.0 26,401 1

Seq Scan on eq_prod_qtde pq (cost=0.00..499.01 rows=26,401 width=16) (actual time=0.055..9.619 rows=26,401 loops=1)

4.          

SubPlan (forGroupAggregate)

5. 26.401 3,590.536 ↑ 1.0 1 26,401

Aggregate (cost=23.71..23.72 rows=1 width=32) (actual time=0.136..0.136 rows=1 loops=26,401)

6. 210.764 3,564.135 ↓ 0.0 0 26,401

Hash Join (cost=10.50..23.70 rows=2 width=5) (actual time=0.135..0.135 rows=0 loops=26,401)

  • Hash Cond: (((pp.id_pedido)::text = (vp.id_pedido)::text) AND (pp.id_pdv = vp.id_pdv) AND (pp.id_emp = vp.id_emp))
7. 3,352.927 3,352.927 ↓ 0.0 0 26,401

Seq Scan on vnd_pedido_prod pp (cost=0.00..13.17 rows=4 width=50) (actual time=0.127..0.127 rows=0 loops=26,401)

  • Filter: ((id_tipo_estoque = pq.id_tipo_estoque) AND ((cnc)::text = 'NAO'::text) AND (id_prod = pq.id_prod))
  • Rows Removed by Filter: 185
8. 0.049 0.444 ↑ 1.0 59 1

Hash (cost=9.47..9.47 rows=59 width=45) (actual time=0.443..0.444 rows=59 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 13kB
9. 0.395 0.395 ↑ 1.0 59 1

Seq Scan on vnd_pedido vp (cost=0.00..9.47 rows=59 width=45) (actual time=0.033..0.395 rows=59 loops=1)

  • Filter: (((tipo)::text <> 'ORC'::text) AND ((status)::text = 'ABERTO'::text) AND ((cnc)::text = 'NAO'::text))
  • Rows Removed by Filter: 84
10. 0.000 211.208 ↑ 1.0 1 26,401

Aggregate (cost=24.67..24.68 rows=1 width=32) (actual time=0.008..0.008 rows=1 loops=26,401)

11. 211.208 211.208 ↓ 0.0 0 26,401

Nested Loop (cost=0.00..24.66 rows=1 width=32) (actual time=0.008..0.008 rows=0 loops=26,401)

  • Join Filter: (mo.id_os = moi.id_os)
12. 0.000 0.000 ↓ 0.0 0 26,401

Seq Scan on mv_os mo (cost=0.00..11.05 rows=1 width=4) (actual time=0.000..0.000 rows=0 loops=26,401)

  • Filter: (((status)::text = 'ABERTO'::text) AND (id_emp = pq.id_emp))
13. 0.000 0.000 ↓ 0.0 0

Seq Scan on mv_os_item moi (cost=0.00..13.60 rows=1 width=36) (never executed)

  • Filter: ((id_tipo_estoque = pq.id_tipo_estoque) AND (id_prod = pq.id_prod))