# Result: Zyd8 : Optimization for: Optimization for: plan #dWCQ; plan #b2SW

Settings

### Optimization path:

# exclusive inclusive rows x rows loops node
1. 5,537.380 5,537.380 ↓ 1.0 205,446 1

CTE Scan on contas (cost=51,312.14..59,529.86 rows=205,443 width=577) (actual time=4,829.133..5,537.380 rows=205,446 loops=1)

2.

CTE contas_saldo

3. 4,122.680 4,122.680 ↓ 205.4 205,446 1

Function Scan on contasareceber_saldo (cost=0.26..10.26 rows=1,000 width=76) (actual time=4,091.011..4,122.680 rows=205,446 loops=1)

4.

CTE contas

5. 147.962 5,261.610 ↓ 1.0 205,446 1

(cost=33,978.07..51,301.89 rows=205,443 width=166) (actual time=4,829.124..5,261.610 rows=205,446 loops=1)

• Hash Cond: (cr.tipodocumento_codigo = t.codigo)
6. 31.239 5,113.632 ↓ 1.0 205,446 1

(cost=33,976.57..45,907.51 rows=205,443 width=152) (actual time=4,829.097..5,113.632 rows=205,446 loops=1)

• Hash Cond: (cr.gruposcontas_codigo = grct.codigo)
7. 48.842 5,082.382 ↓ 1.0 205,446 1

(cost=33,975.48..45,136.00 rows=205,443 width=147) (actual time=4,829.083..5,082.382 rows=205,446 loops=1)

• Hash Cond: (cr_sit.situacoesconta_codigo = sc.codigo)
8. 76.785 5,033.527 ↓ 1.0 205,446 1

(cost=33,974.35..42,310.03 rows=205,443 width=140) (actual time=4,829.058..5,033.527 rows=205,446 loops=1)

• Hash Cond: (cr.codigo = crav.contasareceber_codigo)
9. 113.558 4,909.749 ↓ 1.0 205,446 1

(cost=29,022.87..34,815.84 rows=205,443 width=136) (actual time=4,780.920..4,909.749 rows=205,446 loops=1)

• Hash Cond: (cr_sit.contasareceber_codigo = cr.codigo)
10. 16.387 16.387 ↑ 1.0 205,639 1

Seq Scan on contasareceber_situacao cr_sit (cost=0.00..2,967.39 rows=205,639 width=8) (actual time=0.021..16.387 rows=205,639 loops=1)

11. 81.273 4,779.804 ↓ 1.0 205,446 1

(cost=26,454.83..26,454.83 rows=205,443 width=132) (actual time=4,779.804..4,779.804 rows=205,446 loops=1)

• Buckets: 262144 Batches: 1 Memory Usage: 24234kB
12. 99.291 4,698.531 ↓ 1.0 205,446 1

(cost=26,421.09..26,454.83 rows=205,443 width=132) (actual time=4,503.519..4,698.531 rows=205,446 loops=1)

• Hash Cond: (cr_saldo.contasareceber_codigo = cr.codigo)
13. 4,187.842 4,187.842 ↓ 205.4 205,446 1

CTE Scan on contas_saldo cr_saldo (cost=0.00..20.00 rows=1,000 width=76) (actual time=4,091.015..4,187.842 rows=205,446 loops=1)

14. 77.196 411.398 ↓ 1.0 205,446 1

(cost=23,853.06..23,853.06 rows=205,443 width=60) (actual time=411.398..411.398 rows=205,446 loops=1)

• Buckets: 262144 Batches: 1 Memory Usage: 19423kB
15. 55.143 334.202 ↓ 1.0 205,446 1

(cost=14,672.14..23,853.06 rows=205,443 width=60) (actual time=138.687..334.202 rows=205,446 loops=1)

• Hash Cond: (cr.codigo = pvpg_cr.contasareceber_codigo)
16. 27.595 206.054 ↓ 1.0 205,446 1

(cost=6,428.25..14,558.39 rows=205,443 width=52) (actual time=65.539..206.054 rows=205,446 loops=1)

• Hash Cond: (cr.codigo = snfpg_cr.contasareceber_codigo)
17. 101.142 175.028 ↓ 1.0 205,446 1

(cost=5,733.47..13,091.43 rows=205,443 width=44) (actual time=62.099..175.028 rows=205,446 loops=1)

• Hash Cond: (cr.codigo = cr_fat.contasareceber_codigo)
18. 12.928 12.928 ↑ 1.0 205,639 1

Seq Scan on contasareceber cr (cost=0.00..4,532.39 rows=205,639 width=44) (actual time=0.007..12.928 rows=205,639 loops=1)

19. 35.365 60.958 ↓ 1.0 205,446 1

(cost=3,165.43..3,165.43 rows=205,443 width=4) (actual time=60.958..60.958 rows=205,446 loops=1)

• Buckets: 262144 Batches: 1 Memory Usage: 9271kB
20. 25.593 25.593 ↓ 1.0 205,446 1

Seq Scan on contasareceber_faturamentos cr_fat (cost=0.00..3,165.43 rows=205,443 width=4) (actual time=0.014..25.593 rows=205,446 loops=1)

• Filter: (contasareceber_codigo IS NOT NULL)
21. 0.037 3.431 ↑ 1.0 176 1

(cost=692.58..692.58 rows=176 width=12) (actual time=3.431..3.431 rows=176 loops=1)

• Buckets: 1024 Batches: 1 Memory Usage: 16kB
22. 0.112 3.394 ↑ 1.0 176 1

(cost=5.25..692.58 rows=176 width=12) (actual time=2.334..3.394 rows=176 loops=1)

23. 1.958 3.106 ↑ 1.0 176 1

(cost=4.96..605.16 rows=176 width=8) (actual time=2.322..3.106 rows=176 loops=1)

• Hash Cond: (snfpg.codigo = snfpg_cr.saidasnf_pagtos_codigo)
24. 1.107 1.107 ↑ 1.0 22,122 1

Seq Scan on saidasnf_pagto snfpg (cost=0.00..377.22 rows=22,122 width=8) (actual time=0.002..1.107 rows=22,122 loops=1)

25. 0.023 0.041 ↑ 1.0 176 1

(cost=2.76..2.76 rows=176 width=8) (actual time=0.041..0.041 rows=176 loops=1)

• Buckets: 1024 Batches: 1 Memory Usage: 15kB
26. 0.018 0.018 ↑ 1.0 176 1

Seq Scan on saidasnf_pagtos_contasareceber snfpg_cr (cost=0.00..2.76 rows=176 width=8) (actual time=0.002..0.018 rows=176 loops=1)

27. 0.176 0.176 ↑ 1.0 1 176

Index Scan using saidasnf_codigo_index on saidasnf snf (cost=0.29..0.49 rows=1 width=8) (actual time=0.001..0.001 rows=1 loops=176)

• Index Cond: (snfpg.codsaidasnf = codigo)
28. 7.590 73.005 ↑ 1.0 28,064 1

(cost=7,893.09..7,893.09 rows=28,064 width=12) (actual time=73.005..73.005 rows=28,064 loops=1)

• Buckets: 32768 Batches: 1 Memory Usage: 1462kB
29. 20.571 65.415 ↑ 1.0 28,064 1

(cost=3,859.05..7,893.09 rows=28,064 width=12) (actual time=39.505..65.415 rows=28,064 loops=1)

• Hash Cond: (pv.codigo = pvpg.codprevenda)
30. 5.478 5.478 ↑ 1.0 91,560 1

Seq Scan on prevendas pv (cost=0.00..3,295.60 rows=91,560 width=8) (actual time=0.002..5.478 rows=91,560 loops=1)

31. 4.433 39.366 ↑ 1.0 28,064 1

(cost=3,508.25..3,508.25 rows=28,064 width=8) (actual time=39.366..39.366 rows=28,064 loops=1)

• Buckets: 32768 Batches: 1 Memory Usage: 1353kB
32. 9.881 34.933 ↑ 1.0 28,064 1

(cost=2,716.73..3,508.25 rows=28,064 width=8) (actual time=24.208..34.933 rows=28,064 loops=1)

• Hash Cond: (pvpg_cr.prevendas_pagtos_codigo = pvpg.codigo)
33. 1.560 1.560 ↑ 1.0 28,064 1

Seq Scan on prevendas_pagtos_contasareceber pvpg_cr (cost=0.00..405.64 rows=28,064 width=8) (actual time=0.002..1.560 rows=28,064 loops=1)

34. 14.553 23.492 ↑ 1.0 93,499 1

(cost=1,547.99..1,547.99 rows=93,499 width=8) (actual time=23.492..23.492 rows=93,499 loops=1)

• Buckets: 131072 Batches: 1 Memory Usage: 4677kB
35. 8.939 8.939 ↑ 1.0 93,499 1

Seq Scan on prevenda_pagto pvpg (cost=0.00..1,547.99 rows=93,499 width=8) (actual time=0.003..8.939 rows=93,499 loops=1)

36. 29.885 46.993 ↑ 1.0 177,399 1

(cost=2,733.99..2,733.99 rows=177,399 width=8) (actual time=46.993..46.993 rows=177,399 loops=1)

• Buckets: 262144 Batches: 1 Memory Usage: 8978kB
37. 17.108 17.108 ↑ 1.0 177,399 1

Seq Scan on contasareceber_avulsas crav (cost=0.00..2,733.99 rows=177,399 width=8) (actual time=0.006..17.108 rows=177,399 loops=1)

38. 0.011 0.013 ↑ 1.0 6 1

(cost=1.06..1.06 rows=6 width=15) (actual time=0.013..0.013 rows=6 loops=1)

• Buckets: 1024 Batches: 1 Memory Usage: 9kB
39. 0.002 0.002 ↑ 1.0 6 1

Seq Scan on situacoescontas sc (cost=0.00..1.06 rows=6 width=15) (actual time=0.002..0.002 rows=6 loops=1)

40. 0.009 0.011 ↑ 1.0 4 1

(cost=1.04..1.04 rows=4 width=13) (actual time=0.011..0.011 rows=4 loops=1)

• Buckets: 1024 Batches: 1 Memory Usage: 9kB
41. 0.002 0.002 ↑ 1.0 4 1

Seq Scan on gruposcontas grct (cost=0.00..1.04 rows=4 width=13) (actual time=0.002..0.002 rows=4 loops=1)

42. 0.012 0.016 ↑ 1.0 22 1

(cost=1.22..1.22 rows=22 width=18) (actual time=0.016..0.016 rows=22 loops=1)

• Buckets: 1024 Batches: 1 Memory Usage: 10kB
43. 0.004 0.004 ↑ 1.0 22 1

Seq Scan on tipodocumento t (cost=0.00..1.22 rows=22 width=18) (actual time=0.002..0.004 rows=22 loops=1)