explain.depesz.com

PostgreSQL's explain analyze made readable

Result: sQkR

Settings

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 0.709 21.800 ↑ 1.0 1,380 1

Hash Right Join (cost=1,980.16..2,106.30 rows=1,421 width=981) (actual time=20.460..21.800 rows=1,380 loops=1)

  • Hash Cond: (f_1.financeiro_id = f.financeiro_id)
2.          

CTE movimentacoes

3. 1.863 2.448 ↓ 1.0 585 1

GroupAggregate (cost=53.98..72.61 rows=583 width=80) (actual time=0.545..2.448 rows=585 loops=1)

  • Group Key: cm.financeiro_id
4. 0.250 0.585 ↓ 1.0 660 1

Sort (cost=53.98..55.63 rows=659 width=110) (actual time=0.515..0.585 rows=660 loops=1)

  • Sort Key: cm.financeiro_id
  • Sort Method: quicksort Memory: 73kB
5. 0.164 0.335 ↓ 1.0 660 1

Hash Left Join (cost=1.68..23.13 rows=659 width=110) (actual time=0.112..0.335 rows=660 loops=1)

  • Hash Cond: (cm.forma_pagamento_id = fp.forma_pagamento_id)
6. 0.078 0.078 ↓ 1.0 660 1

Seq Scan on conta_movimento cm (cost=0.00..19.59 rows=659 width=32) (actual time=0.008..0.078 rows=660 loops=1)

7. 0.011 0.093 ↑ 1.0 30 1

Hash (cost=1.30..1.30 rows=30 width=94) (actual time=0.092..0.093 rows=30 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 10kB
8. 0.082 0.082 ↑ 1.0 30 1

Seq Scan on forma_pagamento fp (cost=0.00..1.30 rows=30 width=94) (actual time=0.005..0.082 rows=30 loops=1)

9. 0.109 2.157 ↑ 20.2 70 1

Hash Left Join (cost=212.24..304.73 rows=1,414 width=64) (actual time=1.515..2.157 rows=70 loops=1)

  • Hash Cond: (f_1.financeiro_id = fi.financeiro_id)
  • Filter: (COALESCE((string_agg(DISTINCT (pr.nome)::text, ','::text)), (pro.nome)::text) IS NOT NULL)
  • Rows Removed by Filter: 1,310
10. 0.170 1.541 ↑ 1.0 1,380 1

Hash Left Join (cost=112.51..201.26 rows=1,421 width=52) (actual time=0.871..1.541 rows=1,380 loops=1)

  • Hash Cond: (COALESCE(v_1.operacao_propria_id, f_1.operacao_propria_id) = pro.id)
11. 0.399 1.325 ↑ 1.0 1,380 1

Hash Left Join (cost=108.42..193.36 rows=1,421 width=64) (actual time=0.811..1.325 rows=1,380 loops=1)

  • Hash Cond: (f_1.venda_id = v_1.id)
12. 0.162 0.162 ↑ 1.0 1,380 1

Seq Scan on financeiro f_1 (cost=0.00..81.21 rows=1,421 width=48) (actual time=0.024..0.162 rows=1,380 loops=1)

13. 0.196 0.764 ↑ 1.0 1,663 1

Hash (cost=87.63..87.63 rows=1,663 width=32) (actual time=0.764..0.764 rows=1,663 loops=1)

  • Buckets: 2,048 Batches: 1 Memory Usage: 95kB
14. 0.568 0.568 ↑ 1.0 1,663 1

Seq Scan on vendas v_1 (cost=0.00..87.63 rows=1,663 width=32) (actual time=0.007..0.568 rows=1,663 loops=1)

15. 0.024 0.046 ↑ 1.0 93 1

Hash (cost=2.93..2.93 rows=93 width=36) (actual time=0.046..0.046 rows=93 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 15kB
16. 0.022 0.022 ↑ 1.0 93 1

Seq Scan on produtos pro (cost=0.00..2.93 rows=93 width=36) (actual time=0.012..0.022 rows=93 loops=1)

17. 0.003 0.507 ↑ 63.0 4 1

Hash (cost=96.58..96.58 rows=252 width=48) (actual time=0.507..0.507 rows=4 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
18. 0.019 0.504 ↑ 63.0 4 1

GroupAggregate (cost=89.02..94.06 rows=252 width=48) (actual time=0.496..0.504 rows=4 loops=1)

  • Group Key: fi.financeiro_id
19. 0.008 0.485 ↑ 63.0 4 1

Sort (cost=89.02..89.65 rows=252 width=36) (actual time=0.484..0.485 rows=4 loops=1)

  • Sort Key: fi.financeiro_id
  • Sort Method: quicksort Memory: 25kB
20. 0.006 0.477 ↑ 63.0 4 1

Merge Join (cost=4.70..78.97 rows=252 width=36) (actual time=0.334..0.477 rows=4 loops=1)

  • Merge Cond: (vop.operacao_propria_id = pr.id)
21. 0.030 0.433 ↑ 246.4 5 1

Nested Loop (cost=1.11..4,348.29 rows=1,232 width=32) (actual time=0.293..0.433 rows=5 loops=1)

22. 0.000 0.317 ↑ 57.8 86 1

Nested Loop (cost=0.84..2,569.20 rows=4,972 width=32) (actual time=0.047..0.317 rows=86 loops=1)

23. 0.025 0.124 ↑ 45.8 39 1

Nested Loop (cost=0.56..1,440.58 rows=1,788 width=32) (actual time=0.037..0.124 rows=39 loops=1)

24. 0.031 0.031 ↑ 48.9 34 1

Index Scan using idx_vendas_operacao_propria_id on vendas vop (cost=0.28..301.36 rows=1,663 width=32) (actual time=0.019..0.031 rows=34 loops=1)

25. 0.068 0.068 ↑ 1.0 1 34

Index Scan using idx_vendas_produtos_vendas_id on vendas_produtos vpr (cost=0.28..0.68 rows=1 width=32) (actual time=0.002..0.002 rows=1 loops=34)

  • Index Cond: (vendas_id = vop.id)
26. 0.195 0.195 ↑ 1.5 2 39

Index Scan using idx_financeiro_item_vendas_produtos_id on financeiro_item fi (cost=0.28..0.60 rows=3 width=32) (actual time=0.004..0.005 rows=2 loops=39)

  • Index Cond: (vendas_produtos_id = vpr.vendas_produtos_id)
27. 0.086 0.086 ↓ 0.0 0 86

Index Scan using pk_financeiro on financeiro f2 (cost=0.28..0.36 rows=1 width=16) (actual time=0.001..0.001 rows=0 loops=86)

  • Index Cond: (financeiro_id = fi.financeiro_id)
  • Filter: ((fatura_numero IS NOT NULL) OR (tipo = ANY ('{fatura_fornecedor,avulso_fornecedor}'::financeiro_tipo[])))
  • Rows Removed by Filter: 0
28. 0.012 0.038 ↑ 1.1 17 1

Sort (cost=3.57..3.61 rows=19 width=36) (actual time=0.037..0.038 rows=17 loops=1)

  • Sort Key: pr.id
  • Sort Method: quicksort Memory: 26kB
29. 0.026 0.026 ↑ 1.0 19 1

Seq Scan on produtos pr (cost=0.00..3.16 rows=19 width=36) (actual time=0.022..0.026 rows=19 loops=1)

  • Filter: (tipo = 'OP'::bpchar)
  • Rows Removed by Filter: 74
30. 0.991 18.934 ↑ 1.0 1,380 1

Hash (cost=1,677.54..1,677.54 rows=1,421 width=816) (actual time=18.934..18.934 rows=1,380 loops=1)

  • Buckets: 2,048 Batches: 1 Memory Usage: 492kB
31. 1.236 17.943 ↑ 1.0 1,380 1

Hash Right Join (cost=1,657.87..1,677.54 rows=1,421 width=816) (actual time=14.637..17.943 rows=1,380 loops=1)

  • Hash Cond: (m.financeiro_id = f.financeiro_id)
32. 2.629 2.629 ↓ 1.0 585 1

CTE Scan on movimentacoes m (cost=0.00..11.66 rows=583 width=48) (actual time=0.548..2.629 rows=585 loops=1)

33. 1.444 14.078 ↑ 1.0 1,380 1

Hash (cost=1,640.11..1,640.11 rows=1,421 width=784) (actual time=14.078..14.078 rows=1,380 loops=1)

  • Buckets: 2,048 Batches: 1 Memory Usage: 489kB
34. 0.720 12.634 ↑ 1.0 1,380 1

Hash Left Join (cost=1,532.54..1,640.11 rows=1,421 width=784) (actual time=7.424..12.634 rows=1,380 loops=1)

  • Hash Cond: (f.venda_id = v.id)
35. 0.563 11.403 ↑ 1.0 1,380 1

Hash Left Join (cost=1,424.12..1,527.96 rows=1,421 width=780) (actual time=6.903..11.403 rows=1,380 loops=1)

  • Hash Cond: (f.conta_id = c.conta_id)
36. 0.565 10.823 ↑ 1.0 1,380 1

Hash Left Join (cost=1,422.16..1,522.13 rows=1,421 width=662) (actual time=6.875..10.823 rows=1,380 loops=1)

  • Hash Cond: (p.vendedor_id = ve.pessoa_id)
37. 0.681 8.734 ↑ 1.0 1,380 1

Hash Left Join (cost=1,067.04..1,163.28 rows=1,421 width=657) (actual time=5.319..8.734 rows=1,380 loops=1)

  • Hash Cond: (f.cadastrado_por = cp.pessoa_id)
38. 0.473 6.329 ↑ 1.0 1,380 1

Hash Left Join (cost=711.91..804.43 rows=1,421 width=636) (actual time=3.568..6.329 rows=1,380 loops=1)

  • Hash Cond: (f.forma_pagamento_id = ffp.forma_pagamento_id)
39. 0.852 5.842 ↑ 1.0 1,380 1

Hash Join (cost=710.24..798.91 rows=1,421 width=558) (actual time=3.541..5.842 rows=1,380 loops=1)

  • Hash Cond: (f.pessoa_id = p.pessoa_id)
40. 1.061 3.029 ↑ 1.0 1,380 1

Hash Join (cost=355.12..440.06 rows=1,421 width=464) (actual time=1.555..3.029 rows=1,380 loops=1)

  • Hash Cond: (f.empresa_id = e.pessoa_id)
41. 0.446 0.446 ↑ 1.0 1,380 1

Seq Scan on financeiro f (cost=0.00..81.21 rows=1,421 width=443) (actual time=0.004..0.446 rows=1,380 loops=1)

42. 0.809 1.522 ↑ 1.0 4,272 1

Hash (cost=301.72..301.72 rows=4,272 width=37) (actual time=1.522..1.522 rows=4,272 loops=1)

  • Buckets: 8,192 Batches: 1 Memory Usage: 353kB
43. 0.713 0.713 ↑ 1.0 4,272 1

Seq Scan on pessoa e (cost=0.00..301.72 rows=4,272 width=37) (actual time=0.004..0.713 rows=4,272 loops=1)

44. 0.758 1.961 ↑ 1.0 4,272 1

Hash (cost=301.72..301.72 rows=4,272 width=110) (actual time=1.961..1.961 rows=4,272 loops=1)

  • Buckets: 8,192 Batches: 1 Memory Usage: 483kB
45. 1.203 1.203 ↑ 1.0 4,272 1

Seq Scan on pessoa p (cost=0.00..301.72 rows=4,272 width=110) (actual time=0.008..1.203 rows=4,272 loops=1)

46. 0.006 0.014 ↑ 1.0 30 1

Hash (cost=1.30..1.30 rows=30 width=94) (actual time=0.014..0.014 rows=30 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 10kB
47. 0.008 0.008 ↑ 1.0 30 1

Seq Scan on forma_pagamento ffp (cost=0.00..1.30 rows=30 width=94) (actual time=0.006..0.008 rows=30 loops=1)

48. 0.790 1.724 ↑ 1.0 4,272 1

Hash (cost=301.72..301.72 rows=4,272 width=37) (actual time=1.724..1.724 rows=4,272 loops=1)

  • Buckets: 8,192 Batches: 1 Memory Usage: 353kB
49. 0.934 0.934 ↑ 1.0 4,272 1

Seq Scan on pessoa cp (cost=0.00..301.72 rows=4,272 width=37) (actual time=0.005..0.934 rows=4,272 loops=1)

50. 0.766 1.524 ↑ 1.0 4,272 1

Hash (cost=301.72..301.72 rows=4,272 width=37) (actual time=1.524..1.524 rows=4,272 loops=1)

  • Buckets: 8,192 Batches: 1 Memory Usage: 353kB
51. 0.758 0.758 ↑ 1.0 4,272 1

Seq Scan on pessoa ve (cost=0.00..301.72 rows=4,272 width=37) (actual time=0.006..0.758 rows=4,272 loops=1)

52. 0.008 0.017 ↑ 1.0 43 1

Hash (cost=1.43..1.43 rows=43 width=134) (actual time=0.017..0.017 rows=43 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 11kB
53. 0.009 0.009 ↑ 1.0 43 1

Seq Scan on conta c (cost=0.00..1.43 rows=43 width=134) (actual time=0.006..0.009 rows=43 loops=1)

54. 0.223 0.511 ↑ 1.0 1,663 1

Hash (cost=87.63..87.63 rows=1,663 width=20) (actual time=0.511..0.511 rows=1,663 loops=1)

  • Buckets: 2,048 Batches: 1 Memory Usage: 101kB
55. 0.288 0.288 ↑ 1.0 1,663 1

Seq Scan on vendas v (cost=0.00..87.63 rows=1,663 width=20) (actual time=0.004..0.288 rows=1,663 loops=1)