explain.depesz.com

PostgreSQL's explain analyze made readable

Result: dWCQ

Settings

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 5,821.777 5,821.777 ↑ 5.0 205,446 1

CTE Scan on contas_total (cost=95,482.86..136,571.46 rows=1,027,215 width=573) (actual time=4,684.947..5,821.777 rows=205,446 loops=1)

2.          

CTE contas

3. 128.235 890.651 ↓ 1.0 205,446 1

Hash Left Join (cost=25,165.21..47,161.00 rows=205,443 width=94) (actual time=286.790..890.651 rows=205,446 loops=1)

  • Hash Cond: (cr.tipodocumento_codigo = t.codigo)
4. 33.441 762.400 ↓ 1.0 205,446 1

Hash Left Join (cost=25,163.72..43,307.45 rows=205,443 width=80) (actual time=286.740..762.400 rows=205,446 loops=1)

  • Hash Cond: (cr.gruposcontas_codigo = grct.codigo)
5. 57.606 728.945 ↓ 1.0 205,446 1

Hash Left Join (cost=25,162.63..42,535.94 rows=205,443 width=75) (actual time=286.714..728.945 rows=205,446 loops=1)

  • Hash Cond: (cr_sit.situacoesconta_codigo = sc.codigo)
6. 94.233 671.324 ↓ 1.0 205,446 1

Hash Left Join (cost=25,161.49..39,709.96 rows=205,443 width=68) (actual time=286.683..671.324 rows=205,446 loops=1)

  • Hash Cond: (cr.codigo = cr_sit.contasareceber_codigo)
7. 77.695 521.814 ↓ 1.0 205,446 1

Hash Left Join (cost=19,623.62..31,347.25 rows=205,443 width=64) (actual time=230.126..521.814 rows=205,446 loops=1)

  • Hash Cond: (cr.codigo = crav.contasareceber_codigo)
8. 62.254 391.286 ↓ 1.0 205,446 1

Hash Left Join (cost=14,672.14..23,853.06 rows=205,443 width=60) (actual time=175.900..391.286 rows=205,446 loops=1)

  • Hash Cond: (cr.codigo = pvpg_cr.contasareceber_codigo)
9. 30.742 239.935 ↓ 1.0 205,446 1

Hash Left Join (cost=6,428.25..14,558.39 rows=205,443 width=52) (actual time=86.506..239.935 rows=205,446 loops=1)

  • Hash Cond: (cr.codigo = snfpg_cr.contasareceber_codigo)
10. 105.462 204.221 ↓ 1.0 205,446 1

Hash Join (cost=5,733.47..13,091.43 rows=205,443 width=44) (actual time=81.517..204.221 rows=205,446 loops=1)

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

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

12. 45.761 80.056 ↓ 1.0 205,446 1

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

  • Buckets: 262144 Batches: 1 Memory Usage: 9271kB
13. 34.295 34.295 ↓ 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.036..34.295 rows=205,446 loops=1)

  • Filter: (contasareceber_codigo IS NOT NULL)
14. 0.090 4.972 ↑ 1.0 176 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 16kB
15. 0.085 4.882 ↑ 1.0 176 1

Nested Loop Left Join (cost=5.25..692.58 rows=176 width=12) (actual time=3.072..4.882 rows=176 loops=1)

16. 2.589 4.093 ↑ 1.0 176 1

Hash Right Join (cost=4.96..605.16 rows=176 width=8) (actual time=3.053..4.093 rows=176 loops=1)

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

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

18. 0.032 0.049 ↑ 1.0 176 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 15kB
19. 0.017 0.017 ↑ 1.0 176 1

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

20. 0.704 0.704 ↑ 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.003..0.004 rows=1 loops=176)

  • Index Cond: (snfpg.codsaidasnf = codigo)
21. 6.378 89.097 ↑ 1.0 28,064 1

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

  • Buckets: 32768 Batches: 1 Memory Usage: 1462kB
22. 31.609 82.719 ↑ 1.0 28,064 1

Hash Right Join (cost=3,859.05..7,893.09 rows=28,064 width=12) (actual time=45.290..82.719 rows=28,064 loops=1)

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

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

24. 4.563 45.100 ↑ 1.0 28,064 1

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

  • Buckets: 32768 Batches: 1 Memory Usage: 1353kB
25. 10.663 40.537 ↑ 1.0 28,064 1

Hash Left Join (cost=2,716.73..3,508.25 rows=28,064 width=8) (actual time=29.489..40.537 rows=28,064 loops=1)

  • Hash Cond: (pvpg_cr.prevendas_pagtos_codigo = pvpg.codigo)
26. 1.718 1.718 ↑ 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.008..1.718 rows=28,064 loops=1)

27. 16.111 28.156 ↑ 1.0 93,499 1

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

  • Buckets: 131072 Batches: 1 Memory Usage: 4677kB
28. 12.045 12.045 ↑ 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.018..12.045 rows=93,499 loops=1)

29. 31.561 52.833 ↑ 1.0 177,399 1

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

  • Buckets: 262144 Batches: 1 Memory Usage: 8978kB
30. 21.272 21.272 ↑ 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.010..21.272 rows=177,399 loops=1)

31. 41.604 55.277 ↑ 1.0 205,639 1

Hash (cost=2,967.39..2,967.39 rows=205,639 width=8) (actual time=55.277..55.277 rows=205,639 loops=1)

  • Buckets: 262144 Batches: 1 Memory Usage: 10081kB
32. 13.673 13.673 ↑ 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.006..13.673 rows=205,639 loops=1)

33. 0.012 0.015 ↑ 1.0 6 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
34. 0.003 0.003 ↑ 1.0 6 1

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

35. 0.009 0.014 ↑ 1.0 4 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
36. 0.005 0.005 ↑ 1.0 4 1

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

37. 0.012 0.016 ↑ 1.0 22 1

Hash (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
38. 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)

39.          

CTE contas_saldo

40. 4,280.155 4,280.155 ↓ 205.4 205,446 1

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

41.          

CTE contas_total

42. 139.087 5,563.344 ↑ 5.0 205,446 1

Hash Left Join (cost=32.50..48,311.60 rows=1,027,215 width=573) (actual time=4,684.936..5,563.344 rows=205,446 loops=1)

  • Hash Cond: (vcr.codigo = cr_saldo.contasareceber_codigo)
43. 1,026.137 1,026.137 ↓ 1.0 205,446 1

CTE Scan on contas vcr (cost=0.00..4,108.86 rows=205,443 width=501) (actual time=286.793..1,026.137 rows=205,446 loops=1)

44. 42.561 4,398.120 ↓ 205.4 205,446 1

Hash (cost=20.00..20.00 rows=1,000 width=76) (actual time=4,398.120..4,398.120 rows=205,446 loops=1)

  • Buckets: 262144 (originally 1024) Batches: 1 (originally 1) Memory Usage: 14082kB
45. 4,355.559 4,355.559 ↓ 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,251.743..4,355.559 rows=205,446 loops=1)