explain.depesz.com

PostgreSQL's explain analyze made readable

Result: agQs

Settings
# exclusive inclusive rows x rows loops node
1. 82,149.385 109,003.957 ↓ 1.0 4,975 1

Hash Left Join (cost=1,872.42..195,278.96 rows=4,779 width=2,491) (actual time=456.763..109,003.957 rows=4,975 loops=1)

  • Hash Cond: (p.marca = m.codigoreduzido)
2. 9.541 4,840.141 ↓ 1.0 4,975 1

Hash Left Join (cost=1,870.09..83,303.30 rows=4,779 width=806) (actual time=238.130..4,840.141 rows=4,975 loops=1)

  • Hash Cond: (s.status = sv.chave)
3. 9.752 4,830.568 ↓ 1.0 4,975 1

Hash Left Join (cost=1,869.03..83,287.34 rows=4,779 width=798) (actual time=238.039..4,830.568 rows=4,975 loops=1)

  • Hash Cond: (fj.regiao = r.codigoreduzido)
4. 12.334 4,820.765 ↓ 1.0 4,975 1

Hash Left Join (cost=1,867.15..83,271.73 rows=4,779 width=784) (actual time=237.978..4,820.765 rows=4,975 loops=1)

  • Hash Cond: (p.familia = f.codigoreduzido)
5. 430.529 4,808.365 ↓ 1.0 4,975 1

Hash Left Join (cost=1,864.84..83,256.22 rows=4,779 width=778) (actual time=237.894..4,808.365 rows=4,975 loops=1)

  • Hash Cond: (CASE WHEN (ps.chaveiop IS NULL) THEN 0 WHEN (ps.quantidadevenda = (ps.faltaentregar)::numeric) THEN q.estagio ELSE fp_pegaestagiodata(iop.chave, (SubPlan 5)) END = est.chave)
6. 10.961 4,253.794 ↓ 1.0 4,975 1

Hash Left Join (cost=1,863.53..81,067.39 rows=4,779 width=769) (actual time=236.979..4,253.794 rows=4,975 loops=1)

  • Hash Cond: (q.setorproducao = sp.codigoreduzido)
7. 297.147 4,242.592 ↓ 1.0 4,975 1

Nested Loop Left Join (cost=1,852.79..81,043.95 rows=4,779 width=767) (actual time=236.723..4,242.592 rows=4,975 loops=1)

8. 10.557 3,895.695 ↓ 1.0 4,975 1

Hash Left Join (cost=1,843.51..34,291.40 rows=4,779 width=744) (actual time=236.645..3,895.695 rows=4,975 loops=1)

  • Hash Cond: (COALESCE(et.rota, fj.rota) = ro.codigoreduzido)
9. 12.403 3,885.030 ↓ 1.0 4,975 1

Hash Left Join (cost=1,837.46..34,272.54 rows=4,779 width=740) (actual time=236.522..3,885.030 rows=4,975 loops=1)

  • Hash Cond: (COALESCE(et.cidade, fj.cidade) = c.cidade)
10. 10.137 3,871.918 ↓ 1.0 4,975 1

Hash Left Join (cost=1,812.74..34,235.21 rows=4,779 width=727) (actual time=235.790..3,871.918 rows=4,975 loops=1)

  • Hash Cond: (s.enderecoentrega = et.chave)
11. 13.838 3,854.846 ↓ 1.0 4,975 1

Nested Loop Left Join (cost=1,578.12..33,988.04 rows=4,779 width=723) (actual time=228.801..3,854.846 rows=4,975 loops=1)

12. 15.906 3,771.358 ↓ 1.0 4,975 1

Nested Loop Left Join (cost=1,577.83..32,295.59 rows=4,779 width=723) (actual time=228.780..3,771.358 rows=4,975 loops=1)

13. 14.658 3,680.827 ↓ 1.0 4,975 1

Nested Loop Left Join (cost=1,577.41..30,162.49 rows=4,779 width=392) (actual time=228.737..3,680.827 rows=4,975 loops=1)

14. 10.013 3,591.544 ↓ 1.0 4,975 1

Hash Left Join (cost=1,576.98..28,009.25 rows=4,779 width=379) (actual time=228.728..3,591.544 rows=4,975 loops=1)

  • Hash Cond: (ps.local = l.chave)
15. 32.374 3,581.493 ↓ 1.0 4,975 1

Nested Loop Left Join (cost=1,575.76..27,990.16 rows=4,779 width=363) (actual time=228.674..3,581.493 rows=4,975 loops=1)

16. 7.753 3,514.294 ↓ 1.0 4,975 1

Hash Left Join (cost=1,575.46..26,212.27 rows=4,779 width=231) (actual time=228.639..3,514.294 rows=4,975 loops=1)

  • Hash Cond: (ps.sequencialcto = sel.chave)
17. 23.190 3,506.491 ↓ 1.0 4,975 1

Nested Loop (cost=1,567.15..26,186.03 rows=4,779 width=227) (actual time=228.570..3,506.491 rows=4,975 loops=1)

18. 4.073 3,428.719 ↑ 2.0 827 1

Nested Loop Left Join (cost=1,566.72..22,998.82 rows=1,619 width=132) (actual time=228.473..3,428.719 rows=827 loops=1)

19. 1.786 3,416.376 ↑ 2.0 827 1

Hash Left Join (cost=1,566.44..22,482.49 rows=1,619 width=111) (actual time=228.450..3,416.376 rows=827 loops=1)

  • Hash Cond: (s.usuario = u.chave)
20. 2,793.452 3,414.504 ↑ 2.0 827 1

Hash Left Join (cost=1,562.97..22,474.51 rows=1,619 width=107) (actual time=228.349..3,414.504 rows=827 loops=1)

  • Hash Cond: (s.fisicajuridica = fj.fisicajuridica)
  • Filter: (sem_acento((COALESCE(fj.nome, s.nomecliente))::text) ~* '^levi pereira'::text)
  • Rows Removed by Filter: 322285
21. 398.680 398.680 ↑ 1.0 323,112 1

Seq Scan on saidas s (cost=0.00..20,055.80 rows=323,785 width=51) (actual time=0.030..398.680 rows=323,112 loops=1)

  • Filter: (tiposaida = '0'::smallint)
  • Rows Removed by Filter: 232549
22. 8.391 222.372 ↑ 1.0 11,682 1

Hash (cost=1,414.10..1,414.10 rows=11,910 width=60) (actual time=222.372..222.372 rows=11,682 loops=1)

  • Buckets: 16384 Batches: 1 Memory Usage: 1113kB
23. 213.981 213.981 ↑ 1.0 11,682 1

Seq Scan on fisicajuridica fj (cost=0.00..1,414.10 rows=11,910 width=60) (actual time=0.032..213.981 rows=11,682 loops=1)

24. 0.040 0.086 ↑ 1.0 65 1

Hash (cost=2.65..2.65 rows=65 width=12) (actual time=0.086..0.086 rows=65 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 11kB
25. 0.046 0.046 ↑ 1.0 65 1

Seq Scan on usuarios u (cost=0.00..2.65 rows=65 width=12) (actual time=0.024..0.046 rows=65 loops=1)

26. 8.270 8.270 ↑ 1.0 1 827

Index Scan using fisicajuridica_pkey on fisicajuridica vi (cost=0.29..0.32 rows=1 width=29) (actual time=0.010..0.010 rows=1 loops=827)

  • Index Cond: (fisicajuridica = s.vendedori)
27. 54.582 54.582 ↑ 4.5 6 827

Index Scan using idx_ps_sai on produtossaida ps (cost=0.43..1.70 rows=27 width=95) (actual time=0.055..0.066 rows=6 loops=827)

  • Index Cond: (saida = s.saida)
28. 0.001 0.050 ↓ 0.0 0 1

Hash (cost=8.30..8.30 rows=1 width=4) (actual time=0.050..0.050 rows=0 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 8kB
29. 0.049 0.049 ↓ 0.0 0 1

Index Only Scan using idx_selecoes2 on selecoes sel (cost=0.28..8.30 rows=1 width=4) (actual time=0.049..0.049 rows=0 loops=1)

  • Index Cond: ((username = ("current_user"())::text) AND (tabela = 'v_itensvenda'::text) AND (formulario = 'frmpedidovenda'::text) AND (grid = 'gridporitem'::text))
  • Heap Fetches: 0
30. 34.825 34.825 ↑ 1.0 1 4,975

Index Scan using produtos_pkey on produtos p (cost=0.30..0.37 rows=1 width=136) (actual time=0.007..0.007 rows=1 loops=4,975)

  • Index Cond: (chave = ps.produto)
31. 0.017 0.038 ↑ 1.0 10 1

Hash (cost=1.10..1.10 rows=10 width=24) (actual time=0.038..0.038 rows=10 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
32. 0.021 0.021 ↑ 1.0 10 1

Seq Scan on localizacoes l (cost=0.00..1.10 rows=10 width=24) (actual time=0.018..0.021 rows=10 loops=1)

33. 74.625 74.625 ↑ 1.0 1 4,975

Index Scan using produtoslote_pkey on produtoslote pl (cost=0.42..0.45 rows=1 width=17) (actual time=0.015..0.015 rows=1 loops=4,975)

  • Index Cond: (chave = ps.chavelote)
34. 74.625 74.625 ↑ 1.0 1 4,975

Index Scan using itensop_pkey on itensop iop (cost=0.42..0.45 rows=1 width=331) (actual time=0.015..0.015 rows=1 loops=4,975)

  • Index Cond: (chave = ps.chaveiop)
35. 69.650 69.650 ↑ 1.0 1 4,975

Index Scan using idx_op_chave on ordemproducao op (cost=0.29..0.35 rows=1 width=8) (actual time=0.014..0.014 rows=1 loops=4,975)

  • Index Cond: (chave = iop.op)
36. 2.234 6.935 ↑ 1.0 6,788 1

Hash (cost=148.72..148.72 rows=6,872 width=12) (actual time=6.935..6.935 rows=6,788 loops=1)

  • Buckets: 8192 Batches: 1 Memory Usage: 327kB
37. 4.701 4.701 ↑ 1.0 6,788 1

Seq Scan on enderecoentrega et (cost=0.00..148.72 rows=6,872 width=12) (actual time=0.031..4.701 rows=6,788 loops=1)

38. 0.337 0.709 ↑ 1.0 743 1

Hash (cost=15.43..15.43 rows=743 width=25) (actual time=0.709..0.709 rows=743 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 50kB
39. 0.372 0.372 ↑ 1.0 743 1

Seq Scan on cidades c (cost=0.00..15.43 rows=743 width=25) (actual time=0.028..0.372 rows=743 loops=1)

40. 0.052 0.108 ↑ 1.0 180 1

Hash (cost=3.80..3.80 rows=180 width=4) (actual time=0.108..0.108 rows=180 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 15kB
41. 0.056 0.056 ↑ 1.0 180 1

Seq Scan on rotas ro (cost=0.00..3.80 rows=180 width=4) (actual time=0.020..0.056 rows=180 loops=1)

42. 0.000 49.750 ↑ 1.0 1 4,975

Index Scan using qualidade_pcp_pkey on qualidade_pcp q (cost=9.28..9.78 rows=1 width=27) (actual time=0.010..0.010 rows=1 loops=4,975)

  • Index Cond: (chave = (SubPlan 4))
43.          

SubPlan (for Index Scan)

44. 19.900 258.700 ↑ 1.0 1 4,975

Aggregate (cost=8.85..8.86 rows=1 width=4) (actual time=0.052..0.052 rows=1 loops=4,975)

45. 238.800 238.800 ↑ 1.6 5 4,975

Index Scan using idx_qualidade_pcp_itemop on qualidade_pcp (cost=0.42..8.83 rows=8 width=4) (actual time=0.017..0.048 rows=5 loops=4,975)

  • Index Cond: (itemop = iop.chave)
46. 0.123 0.241 ↑ 1.0 344 1

Hash (cost=6.44..6.44 rows=344 width=10) (actual time=0.241..0.241 rows=344 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 23kB
47. 0.118 0.118 ↑ 1.0 344 1

Seq Scan on setorproducao sp (cost=0.00..6.44 rows=344 width=10) (actual time=0.030..0.118 rows=344 loops=1)

48. 0.015 0.042 ↑ 1.0 14 1

Hash (cost=1.14..1.14 rows=14 width=17) (actual time=0.042..0.042 rows=14 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
49. 0.027 0.027 ↑ 1.0 14 1

Seq Scan on estagios est (cost=0.00..1.14 rows=14 width=17) (actual time=0.024..0.027 rows=14 loops=1)

50.          

SubPlan (for Hash Left Join)

51. 23.250 124.000 ↑ 1.0 1 7,750

Aggregate (cost=8.45..8.46 rows=1 width=8) (actual time=0.015..0.016 rows=1 loops=7,750)

52. 100.750 100.750 ↑ 1.0 1 7,750

Index Scan using idx_prodentre_ps on produtosentrega produtosentrega_1 (cost=0.42..8.44 rows=1 width=8) (actual time=0.012..0.013 rows=1 loops=7,750)

  • Index Cond: (lctosaida = ps.sequencialcto)
53. 0.026 0.066 ↑ 1.0 58 1

Hash (cost=1.58..1.58 rows=58 width=14) (actual time=0.066..0.066 rows=58 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 11kB
54. 0.040 0.040 ↑ 1.0 58 1

Seq Scan on familia f (cost=0.00..1.58 rows=58 width=14) (actual time=0.023..0.040 rows=58 loops=1)

55. 0.027 0.051 ↑ 1.0 39 1

Hash (cost=1.39..1.39 rows=39 width=22) (actual time=0.051..0.051 rows=39 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 11kB
56. 0.024 0.024 ↑ 1.0 39 1

Seq Scan on regiao r (cost=0.00..1.39 rows=39 width=22) (actual time=0.013..0.024 rows=39 loops=1)

57. 0.018 0.032 ↑ 1.0 3 1

Hash (cost=1.03..1.03 rows=3 width=12) (actual time=0.031..0.032 rows=3 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
58. 0.014 0.014 ↑ 1.0 3 1

Seq Scan on statusvenda sv (cost=0.00..1.03 rows=3 width=12) (actual time=0.013..0.014 rows=3 loops=1)

59. 0.028 0.056 ↑ 1.0 59 1

Hash (cost=1.59..1.59 rows=59 width=13) (actual time=0.056..0.056 rows=59 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 11kB
60. 0.028 0.028 ↑ 1.0 59 1

Seq Scan on marcas m (cost=0.00..1.59 rows=59 width=13) (actual time=0.012..0.028 rows=59 loops=1)

61.          

SubPlan (for Hash Left Join)

62. 19.900 79.600 ↑ 1.0 1 4,975

Aggregate (cost=8.45..8.46 rows=1 width=8) (actual time=0.015..0.016 rows=1 loops=4,975)

63. 59.700 59.700 ↑ 1.0 1 4,975

Index Scan using idx_prodentre_ps on produtosentrega (cost=0.42..8.44 rows=1 width=8) (actual time=0.011..0.012 rows=1 loops=4,975)

  • Index Cond: (lctosaida = ps.sequencialcto)
64. 21,840.250 21,840.250 ↑ 1.0 1 4,975

Seq Scan on estagios (cost=0.00..4.69 rows=1 width=32) (actual time=3.561..4.390 rows=1 loops=4,975)

  • Filter: (chave = CASE WHEN (p.enxertado AND (iop.cp_dataenxertia IS NULL)) THEN 0 ELSE cpc_estagioprevisto(iop.*) END)
  • Rows Removed by Filter: 13
65. 14.925 94.525 ↑ 1.0 1 4,975

Aggregate (cost=8.44..8.45 rows=1 width=8) (actual time=0.019..0.019 rows=1 loops=4,975)

66. 79.600 79.600 ↓ 0.0 0 4,975

Index Scan using idx_tp_logstatusvenda_new_status_pedido on tp_logstatusvenda (cost=0.42..8.44 rows=1 width=8) (actual time=0.015..0.016 rows=0 loops=4,975)

  • Index Cond: (((new_status = 1) = true) AND (pedido = s.saida))
  • Filter: (new_status = 1)
Planning time : 3,181.732 ms
Execution time : 109,046.087 ms