explain.depesz.com

PostgreSQL's explain analyze made readable

Result: D6Ek

Settings
# exclusive inclusive rows x rows loops node
1. 173.510 70,792.157 ↓ 0.0 0 1

Update on altera_preco_produto (cost=0.84..8,305.67 rows=121 width=154) (actual time=70,792.157..70,792.157 rows=0 loops=1)

2. 3.083 70,618.647 ↓ 8.3 1,000 1

Nested Loop (cost=0.84..8,305.67 rows=121 width=154) (actual time=266.757..70,618.647 rows=1,000 loops=1)

3. 1.154 70,595.564 ↓ 8.3 1,000 1

Subquery Scan on dad (cost=0.42..7,994.72 rows=121 width=96) (actual time=266.745..70,595.564 rows=1,000 loops=1)

4. 0.313 70,594.410 ↓ 8.3 1,000 1

Limit (cost=0.42..7,993.51 rows=121 width=36) (actual time=266.742..70,594.410 rows=1,000 loops=1)

5. 9.235 70,594.097 ↓ 8.3 1,000 1

Nested Loop (cost=0.42..7,993.51 rows=121 width=36) (actual time=266.741..70,594.097 rows=1,000 loops=1)

6. 27.842 27.842 ↓ 86.7 120,510 1

Seq Scan on altera_preco_produto app (cost=0.00..5,316.00 rows=1,390 width=12) (actual time=0.012..27.842 rows=120,510 loops=1)

  • Filter: (app_vl_preco_custo IS NULL)
  • Rows Removed by Filter: 2947
7. 241.020 241.020 ↓ 0.0 0 120,510

Index Scan using altera_preco_pkey on altera_preco alp (cost=0.42..1.60 rows=1 width=20) (actual time=0.002..0.002 rows=0 loops=120,510)

  • Index Cond: (alp_cd_altera_preco = app.app_cd_altera_preco)
  • Filter: (alp_dt_alteracao >= '2020-02-01'::date)
  • Rows Removed by Filter: 1
8.          

SubPlan (for Nested Loop)

9. 1.000 70,316.000 ↑ 1.0 1 1,000

Limit (cost=0.58..3.72 rows=1 width=40) (actual time=70.316..70.316 rows=1 loops=1,000)

10. 7.000 70,315.000 ↑ 596.0 1 1,000

WindowAgg (cost=0.58..1,874.47 rows=596 width=40) (actual time=70.315..70.315 rows=1 loops=1,000)

11. 1,331.649 70,308.000 ↑ 298.0 2 1,000

Nested Loop (cost=0.58..1,861.06 rows=596 width=40) (actual time=58.069..70.308 rows=2 loops=1,000)

12. 32,508.000 32,508.000 ↓ 6.8 4,052 1,000

Index Scan Backward using venda_ven_cd_unidade_negocio_ven_ts_venda on venda ven (cost=0.57..663.09 rows=596 width=1,425) (actual time=0.163..32.508 rows=4,052 loops=1,000)

  • Index Cond: ((ven_cd_unidade_negocio = alp.alp_cd_unidade_negocio) AND (ven_fl_cancelada = 'N'::bpchar) AND (ven_ts_venda >= (alp.alp_dt_alteracao - '15 days'::interval)) AND (ven_ts_venda <= (alp.alp_dt_alteracao + alp.alp_tm_alteracao)))
13. 36,468.351 36,468.351 ↓ 0.0 0 4,052,039

Function Scan on jsonb_array_elements vei (cost=0.01..2.00 rows=1 width=32) (actual time=0.009..0.009 rows=0 loops=4,052,039)

  • Filter: (((value ->> 'vei_cd_produto'::text))::integer = app.app_cd_produto)
  • Rows Removed by Filter: 2
14. 20.000 20.000 ↑ 1.0 1 1,000

Index Scan using altera_preco_produto_pkey on altera_preco_produto (cost=0.42..2.57 rows=1 width=50) (actual time=0.020..0.020 rows=1 loops=1,000)

  • Index Cond: (app_cd_altera_preco_produto = dad.codigo)
Planning time : 1.667 ms
Execution time : 70,808.743 ms
Trigger times:
Trigger Name:Total time:Calls:Average time:
altera_preco_produto_custo 10.458 ms 1000 0.010 ms