explain.depesz.com

PostgreSQL's explain analyze made readable

Result: Lu53

Settings
# exclusive inclusive rows x rows loops node
1. 58.207 965.413 ↓ 17.1 4,850 1

GroupAggregate (cost=45,689.33..45,751.51 rows=283 width=142) (actual time=879.057..965.413 rows=4,850 loops=1)

  • Group Key: "*SELECT* 1".empresa, "*SELECT* 1".codigocatalogoproduto, "*SELECT* 1".codigocatalogovendedor
2. 111.551 907.206 ↓ 3.5 9,753 1

Sort (cost=45,689.33..45,696.40 rows=2,826 width=142) (actual time=879.014..907.206 rows=9,753 loops=1)

  • Sort Key: "*SELECT* 1".empresa, "*SELECT* 1".codigocatalogoproduto, "*SELECT* 1".codigocatalogovendedor
  • Sort Method: quicksort Memory: 1146kB
3. 56.401 795.655 ↓ 3.5 9,753 1

Append (cost=21,203.32..45,527.34 rows=2,826 width=142) (actual time=225.438..795.655 rows=9,753 loops=1)

4. 28.227 396.608 ↓ 3.4 4,794 1

Subquery Scan on *SELECT* 1 (cost=21,203.32..21,358.61 rows=1,402 width=142) (actual time=225.431..396.608 rows=4,794 loops=1)

5. 40.993 368.381 ↓ 3.4 4,794 1

Finalize GroupAggregate (cost=21,203.32..21,344.59 rows=1,402 width=143) (actual time=225.423..368.381 rows=4,794 loops=1)

  • Group Key: a.codigocatalogoproduto, b.codigocatalogovendedor, b.cancelado
6. 158.160 327.388 ↓ 6.4 5,311 1

Gather Merge (cost=21,203.32..21,316.75 rows=825 width=43) (actual time=225.368..327.388 rows=5,311 loops=1)

  • Workers Planned: 1
  • Workers Launched: 1
7. 26.685 169.228 ↓ 3.2 2,656 2 / 2

Partial GroupAggregate (cost=20,203.31..20,223.93 rows=825 width=43) (actual time=129.779..169.228 rows=2,656 loops=2)

  • Group Key: a.codigocatalogoproduto, b.codigocatalogovendedor, b.cancelado
8. 46.801 142.543 ↓ 5.1 4,219 2 / 2

Sort (cost=20,203.31..20,205.37 rows=825 width=16) (actual time=129.555..142.543 rows=4,219 loops=2)

  • Sort Key: a.codigocatalogoproduto, b.codigocatalogovendedor, b.cancelado
  • Sort Method: quicksort Memory: 534kB
  • Worker 0: Sort Method: quicksort Memory: 102kB
9. 32.903 95.742 ↓ 5.1 4,219 2 / 2

Nested Loop (cost=84.29..20,163.34 rows=825 width=16) (actual time=1.167..95.742 rows=4,219 loops=2)

10. 6.060 6.706 ↑ 1.4 891 2 / 2

Parallel Bitmap Heap Scan on pedidoserp b (cost=83.86..5,727.69 rows=1,246 width=25) (actual time=0.800..6.706 rows=891 loops=2)

  • Recheck Cond: ((fkempresa = 1) AND (dataemissao >= '2019-08-01'::date) AND (dataemissao <= '2019-08-31'::date))
  • Filter: ((NOT cancelado) AND (NOT excluido))
  • Heap Blocks: exact=173
11. 0.645 0.645 ↑ 1.2 1,782 1 / 2

Bitmap Index Scan on idx_vendedor_movimentacao_cancelado_pedidoserp (cost=0.00..83.33 rows=2,119 width=0) (actual time=1.288..1.291 rows=1,782 loops=1)

  • Index Cond: ((fkempresa = 1) AND (dataemissao >= '2019-08-01'::date) AND (dataemissao <= '2019-08-31'::date) AND (excluido = false) AND (cancelado = false))
12. 56.133 56.133 ↓ 2.5 5 1,782 / 2

Index Scan using idx_fkempresa_codigocatalogopedidoerp_pedidoerpitens on pedidoerpitens a (cost=0.43..11.57 rows=2 width=31) (actual time=0.026..0.063 rows=5 loops=1,782)

  • Index Cond: ((fkempresa = 1) AND ((codigocatalogopedidoerp)::text = (b.codigocatalogo)::text) AND (excluido = false))
  • Filter: (NOT excluido)
13. 0.012 0.409 ↑ 3.0 1 1

Subquery Scan on *SELECT* 2 (cost=160.99..161.09 rows=3 width=142) (actual time=0.398..0.409 rows=1 loops=1)

14. 0.019 0.397 ↑ 3.0 1 1

GroupAggregate (cost=160.99..161.06 rows=3 width=143) (actual time=0.391..0.397 rows=1 loops=1)

  • Group Key: a_1.codigocatalogoproduto, b_1.codigocatalogovendedor, b_1.cancelado
15. 0.053 0.378 ↑ 3.0 1 1

Sort (cost=160.99..160.99 rows=3 width=16) (actual time=0.372..0.378 rows=1 loops=1)

  • Sort Key: a_1.codigocatalogoproduto, b_1.codigocatalogovendedor, b_1.cancelado
  • Sort Method: quicksort Memory: 25kB
16. 0.024 0.325 ↑ 3.0 1 1

Nested Loop (cost=0.85..160.96 rows=3 width=16) (actual time=0.268..0.325 rows=1 loops=1)

17. 0.234 0.234 ↑ 5.0 1 1

Index Scan using idx_vendedor_movimentacao_cancelado_pedidoserp on pedidoserp b_1 (cost=0.42..101.14 rows=5 width=25) (actual time=0.190..0.234 rows=1 loops=1)

  • Index Cond: ((fkempresa = 1) AND (dataemissao >= '2019-08-01'::date) AND (dataemissao <= '2019-08-31'::date) AND (excluido = false) AND (cancelado = true))
  • Filter: (cancelado AND (NOT excluido))
18. 0.067 0.067 ↑ 2.0 1 1

Index Scan using idx_fkempresa_codigocatalogopedidoerp_pedidoerpitens on pedidoerpitens a_1 (cost=0.43..11.94 rows=2 width=31) (actual time=0.061..0.067 rows=1 loops=1)

  • Index Cond: ((fkempresa = 1) AND ((codigocatalogopedidoerp)::text = (b_1.codigocatalogo)::text) AND (excluido = false))
  • Filter: (NOT excluido)
19. 29.754 333.611 ↓ 3.8 4,756 1

Subquery Scan on *SELECT* 3 (cost=22,914.74..23,054.41 rows=1,261 width=143) (actual time=162.272..333.611 rows=4,756 loops=1)

20. 43.714 303.857 ↓ 3.8 4,756 1

Finalize GroupAggregate (cost=22,914.74..23,041.80 rows=1,261 width=151) (actual time=162.265..303.857 rows=4,756 loops=1)

  • Group Key: a_2.fkempresa, a_2.codigocatalogoproduto, b_2.codigocatalogovendedor
21. 110.331 260.143 ↓ 7.4 5,527 1

Gather Merge (cost=22,914.74..23,016.77 rows=742 width=51) (actual time=162.204..260.143 rows=5,527 loops=1)

  • Workers Planned: 1
  • Workers Launched: 1
22. 26.996 149.812 ↓ 3.7 2,764 2 / 2

Partial GroupAggregate (cost=21,914.73..21,933.28 rows=742 width=51) (actual time=109.359..149.812 rows=2,764 loops=2)

  • Group Key: a_2.fkempresa, a_2.codigocatalogoproduto, b_2.codigocatalogovendedor
23. 45.822 122.816 ↓ 5.6 4,186 2 / 2

Sort (cost=21,914.73..21,916.59 rows=742 width=24) (actual time=109.293..122.816 rows=4,186 loops=2)

  • Sort Key: a_2.codigocatalogoproduto, b_2.codigocatalogovendedor
  • Sort Method: quicksort Memory: 688kB
  • Worker 0: Sort Method: quicksort Memory: 207kB
24. 32.831 76.994 ↓ 5.6 4,186 2 / 2

Nested Loop (cost=63.72..21,879.35 rows=742 width=24) (actual time=0.502..76.994 rows=4,186 loops=2)

25. 4.651 4.915 ↑ 1.3 892 2 / 2

Parallel Bitmap Heap Scan on notasfiscais b_2 (cost=63.29..5,220.94 rows=1,161 width=27) (actual time=0.360..4.915 rows=892 loops=2)

  • Recheck Cond: ((fkempresa = 1) AND (dataemissao >= '2019-08-01'::date) AND (dataemissao <= '2019-08-31'::date))
  • Filter: (NOT excluido)
  • Heap Blocks: exact=51
26. 0.264 0.264 ↑ 1.1 1,784 1 / 2

Bitmap Index Scan on idx_empresa_dataemissao_excluido_notafiscal (cost=0.00..62.80 rows=1,974 width=0) (actual time=0.526..0.528 rows=1,784 loops=1)

  • Index Cond: ((fkempresa = 1) AND (dataemissao >= '2019-08-01'::date) AND (dataemissao <= '2019-08-31'::date) AND (excluido = false))
27. 39.248 39.248 ↓ 1.7 5 1,784 / 2

Index Scan using idx_fkempresa_codigocatalogonotafiscal_notafiscalitens on notafiscalitens a_2 (cost=0.43..14.32 rows=3 width=33) (actual time=0.023..0.044 rows=5 loops=1,784)

  • Index Cond: ((fkempresa = 1) AND ((codigocatalogonotafiscal)::text = (b_2.codigocatalogo)::text))
  • Filter: (NOT excluido)
28. 1.193 8.626 ↓ 1.3 202 1

Subquery Scan on *SELECT* 4 (cost=933.49..939.09 rows=160 width=139) (actual time=5.358..8.626 rows=202 loops=1)

29. 1.508 7.433 ↓ 1.3 202 1

GroupAggregate (cost=933.49..937.49 rows=160 width=147) (actual time=5.351..7.433 rows=202 loops=1)

  • Group Key: a_3.fkempresa, a_3.codigocatalogoproduto, b_3.codigocatalogovendedor
30. 1.843 5.925 ↓ 1.3 209 1

Sort (cost=933.49..933.89 rows=160 width=20) (actual time=5.325..5.925 rows=209 loops=1)

  • Sort Key: a_3.codigocatalogoproduto, b_3.codigocatalogovendedor
  • Sort Method: quicksort Memory: 41kB
31. 1.727 4.082 ↓ 1.3 209 1

Nested Loop (cost=5.78..927.64 rows=160 width=20) (actual time=0.219..4.082 rows=209 loops=1)

32. 0.289 0.395 ↑ 1.1 70 1

Bitmap Heap Scan on devolucoes b_3 (cost=5.49..126.00 rows=79 width=30) (actual time=0.138..0.395 rows=70 loops=1)

  • Recheck Cond: ((fkempresa = 1) AND (dataemissao >= '2019-08-01'::date) AND (dataemissao <= '2019-08-31'::date))
  • Filter: (NOT excluido)
  • Heap Blocks: exact=2
33. 0.106 0.106 ↑ 1.1 70 1

Bitmap Index Scan on idx_vendedor_movimentacao_devolucao (cost=0.00..5.47 rows=79 width=0) (actual time=0.103..0.106 rows=70 loops=1)

  • Index Cond: ((fkempresa = 1) AND (dataemissao >= '2019-08-01'::date) AND (dataemissao <= '2019-08-31'::date) AND (excluido = false))
34. 1.960 1.960 ↓ 1.5 3 70

Index Scan using idx_fkempresa_codigocatalogonotafiscal_devolucaoitens on devolucaoitens a_3 (cost=0.29..10.13 rows=2 width=36) (actual time=0.017..0.028 rows=3 loops=70)

  • Index Cond: ((fkempresa = 1) AND ((codigocatalogonotafiscal)::text = (b_3.codigocatalogo)::text) AND (excluido = false))
  • Filter: (NOT excluido)
Planning time : 13.592 ms
Execution time : 982.340 ms