explain.depesz.com

PostgreSQL's explain analyze made readable

Result: k1Zh

Settings
# exclusive inclusive rows x rows loops node
1. 43.777 3,136.610 ↑ 1.0 1 1

Subquery Scan on foo (cost=628,519.86..659,271.28 rows=1 width=442) (actual time=2,329.738..3,136.610 rows=1 loops=1)

  • Filter: (foo.codigo = 64,467)
  • Rows Removed by Filter: 820,037
2. 658.066 3,092.833 ↑ 1.0 820,038 1

WindowAgg (cost=628,519.86..649,020.81 rows=820,038 width=442) (actual time=2,260.347..3,092.833 rows=820,038 loops=1)

3. 650.461 2,434.767 ↑ 1.0 820,038 1

Sort (cost=628,519.86..630,569.95 rows=820,038 width=443) (actual time=2,260.336..2,434.767 rows=820,038 loops=1)

  • Sort Key: (COALESCE(pvpg.codprevenda, snfpg.codsaidasnf, cr.codigo)), (CASE WHEN (pvpg.codprevenda IS NOT NULL) THEN 'Pré-venda'::text WHEN (snfpg.codsaidasnf IS NOT NULL) THEN 'Nota de Saída'::text WHEN (cr.codigo IS NOT NULL) THEN 'Conta Avulsa'::text ELSE NULL::text END), cr.datavencimento, cr.codigo
  • Sort Method: external merge Disk: 105,928kB
4. 112.091 1,784.306 ↑ 1.0 820,038 1

Gather (cost=86,900.66..217,227.27 rows=820,038 width=443) (actual time=1,175.710..1,784.306 rows=820,038 loops=1)

  • Workers Planned: 2
  • Workers Launched: 2
5. 104.045 1,672.215 ↑ 1.2 273,346 3 / 3

Hash Left Join (cost=85,900.66..134,223.47 rows=341,682 width=443) (actual time=1,169.322..1,672.215 rows=273,346 loops=3)

  • Hash Cond: (cr.tipodocumento_codigo = t.codigo)
6. 70.978 1,568.158 ↑ 1.2 273,346 3 / 3

Hash Left Join (cost=85,899.18..133,144.06 rows=341,682 width=329) (actual time=1,169.300..1,568.158 rows=273,346 loops=3)

  • Hash Cond: (cr.gruposcontas_codigo = grct.codigo)
7. 91.748 1,497.177 ↑ 1.2 273,346 3 / 3

Hash Left Join (cost=85,879.28..132,227.25 rows=341,682 width=211) (actual time=1,169.288..1,497.177 rows=273,346 loops=3)

  • Hash Cond: (cr_sit.situacoesconta_codigo = sc.codigo)
8. 69.518 1,405.414 ↑ 1.2 273,346 3 / 3

Hash Left Join (cost=85,859.61..131,301.81 rows=341,682 width=89) (actual time=1,169.268..1,405.414 rows=273,346 loops=3)

  • Hash Cond: (cr.codigo = crav.contasareceber_codigo)
9. 242.089 1,335.867 ↑ 1.2 273,346 3 / 3

Parallel Hash Left Join (cost=85,803.71..130,349.00 rows=341,682 width=81) (actual time=1,169.226..1,335.867 rows=273,346 loops=3)

  • Hash Cond: (cr.codigo = cr_sit.contasareceber_codigo)
10. 58.398 1,023.770 ↑ 1.2 273,346 3 / 3

Hash Left Join (cost=73,151.86..106,789.23 rows=341,682 width=77) (actual time=829.241..1,023.770 rows=273,346 loops=3)

  • Hash Cond: (cr.codigo = snfpg_cr.contasareceber_codigo)
11. 206.608 965.175 ↑ 1.2 273,346 3 / 3

Parallel Hash Left Join (cost=61,811.93..94,158.58 rows=341,682 width=69) (actual time=829.029..965.175 rows=273,346 loops=3)

  • Hash Cond: (cr.codigo = cr_fat.contasareceber_codigo)
12. 203.707 683.245 ↑ 1.2 273,346 3 / 3

Parallel Hash Left Join (cost=48,022.40..70,461.13 rows=341,682 width=57) (actual time=541.581..683.245 rows=273,346 loops=3)

  • Hash Cond: (cr.codigo = pvpg_cr.contasareceber_codigo)
13. 59.161 59.161 ↑ 1.2 273,346 3 / 3

Parallel Seq Scan on contasareceber cr (cost=0.00..12,056.83 rows=341,682 width=45) (actual time=0.045..59.161 rows=273,346 loops=3)

14. 46.003 420.377 ↑ 1.2 273,332 3 / 3

Parallel Hash (cost=42,082.59..42,082.59 rows=341,665 width=16) (actual time=420.377..420.377 rows=273,332 loops=3)

  • Buckets: 131,072 Batches: 16 Memory Usage: 3,488kB
15. 120.251 374.374 ↑ 1.2 273,332 3 / 3

Parallel Hash Left Join (cost=25,622.17..42,082.59 rows=341,665 width=16) (actual time=296.186..374.374 rows=273,332 loops=3)

  • Hash Cond: (pvpg.codprevenda = pv.codigo)
16. 125.169 198.263 ↑ 1.2 273,332 3 / 3

Parallel Hash Left Join (cost=8,822.38..20,260.91 rows=341,665 width=12) (actual time=115.681..198.263 rows=273,332 loops=3)

  • Hash Cond: (pvpg_cr.prevendas_pagtos_codigo = pvpg.codigo)
17. 28.719 28.719 ↑ 1.2 273,332 3 / 3

Parallel Seq Scan on prevendas_pagtos_contasareceber pvpg_cr (cost=0.00..7,045.65 rows=341,665 width=8) (actual time=0.018..28.719 rows=273,332 loops=3)

18. 25.121 44.375 ↑ 1.3 169,151 3 / 3

Parallel Hash (cost=5,353.39..5,353.39 rows=211,439 width=8) (actual time=44.375..44.375 rows=169,151 loops=3)

  • Buckets: 131,072 Batches: 8 Memory Usage: 3,584kB
19. 19.254 19.254 ↑ 1.3 169,151 3 / 3

Parallel Seq Scan on prevenda_pagto pvpg (cost=0.00..5,353.39 rows=211,439 width=8) (actual time=0.009..19.254 rows=169,151 loops=3)

20. 24.536 55.860 ↑ 1.2 161,024 3 / 3

Parallel Hash (cost=13,496.80..13,496.80 rows=201,280 width=8) (actual time=55.860..55.860 rows=161,024 loops=3)

  • Buckets: 131,072 Batches: 8 Memory Usage: 3,424kB
21. 31.324 31.324 ↑ 1.2 161,024 3 / 3

Parallel Seq Scan on prevendas pv (cost=0.00..13,496.80 rows=201,280 width=8) (actual time=0.024..31.324 rows=161,024 loops=3)

22. 42.543 75.322 ↑ 1.3 273,334 3 / 3

Parallel Hash (cost=7,849.68..7,849.68 rows=341,668 width=12) (actual time=75.322..75.322 rows=273,334 loops=3)

  • Buckets: 131,072 Batches: 16 Memory Usage: 3,488kB
23. 32.779 32.779 ↑ 1.3 273,334 3 / 3

Parallel Seq Scan on contasareceber_faturamentos cr_fat (cost=0.00..7,849.68 rows=341,668 width=12) (actual time=0.068..32.779 rows=273,334 loops=3)

24. 0.007 0.197 ↑ 64.6 35 3 / 3

Hash (cost=11,311.68..11,311.68 rows=2,260 width=12) (actual time=0.197..0.197 rows=35 loops=3)

  • Buckets: 4,096 Batches: 1 Memory Usage: 34kB
25. 0.016 0.190 ↑ 64.6 35 3 / 3

Nested Loop Left Join (cost=0.84..11,311.68 rows=2,260 width=12) (actual time=0.044..0.190 rows=35 loops=3)

26. 0.016 0.104 ↑ 64.6 35 3 / 3

Nested Loop Left Join (cost=0.42..9,943.00 rows=2,260 width=8) (actual time=0.036..0.104 rows=35 loops=3)

27. 0.018 0.018 ↑ 64.6 35 3 / 3

Seq Scan on saidasnf_pagtos_contasareceber snfpg_cr (cost=0.00..32.60 rows=2,260 width=8) (actual time=0.016..0.018 rows=35 loops=3)

28. 0.070 0.070 ↑ 1.0 1 105 / 3

Index Scan using saidasnf_pagto_pkey on saidasnf_pagto snfpg (cost=0.42..4.39 rows=1 width=8) (actual time=0.002..0.002 rows=1 loops=105)

  • Index Cond: (snfpg_cr.saidasnf_pagtos_codigo = codigo)
29. 0.070 0.070 ↑ 1.0 1 105 / 3

Index Scan using saidasnf_codigo_index on saidasnf snf (cost=0.42..0.61 rows=1 width=8) (actual time=0.002..0.002 rows=1 loops=105)

  • Index Cond: (snfpg.codsaidasnf = codigo)
30. 45.366 70.008 ↑ 1.2 273,346 3 / 3

Parallel Hash (cost=7,045.83..7,045.83 rows=341,682 width=8) (actual time=70.008..70.008 rows=273,346 loops=3)

  • Buckets: 131,072 Batches: 16 Memory Usage: 3,072kB
31. 24.642 24.642 ↑ 1.2 273,346 3 / 3

Parallel Seq Scan on contasareceber_situacao cr_sit (cost=0.00..7,045.83 rows=341,682 width=8) (actual time=0.016..24.642 rows=273,346 loops=3)

32. 0.003 0.029 ↑ 340.0 6 3 / 3

Hash (cost=30.40..30.40 rows=2,040 width=12) (actual time=0.029..0.029 rows=6 loops=3)

  • Buckets: 2,048 Batches: 1 Memory Usage: 17kB
33. 0.026 0.026 ↑ 340.0 6 3 / 3

Seq Scan on contasareceber_avulsas crav (cost=0.00..30.40 rows=2,040 width=12) (actual time=0.025..0.026 rows=6 loops=3)

34. 0.008 0.015 ↑ 71.7 6 3 / 3

Hash (cost=14.30..14.30 rows=430 width=126) (actual time=0.015..0.015 rows=6 loops=3)

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
35. 0.007 0.007 ↑ 71.7 6 3 / 3

Seq Scan on situacoescontas sc (cost=0.00..14.30 rows=430 width=126) (actual time=0.006..0.007 rows=6 loops=3)

36. 0.000 0.003 ↓ 0.0 0 3 / 3

Hash (cost=14.40..14.40 rows=440 width=122) (actual time=0.003..0.003 rows=0 loops=3)

  • Buckets: 1,024 Batches: 1 Memory Usage: 8kB
37. 0.003 0.003 ↓ 0.0 0 3 / 3

Seq Scan on gruposcontas grct (cost=0.00..14.40 rows=440 width=122) (actual time=0.003..0.003 rows=0 loops=3)

38. 0.004 0.012 ↓ 1.0 22 3 / 3

Hash (cost=1.21..1.21 rows=21 width=82) (actual time=0.012..0.012 rows=22 loops=3)

  • Buckets: 1,024 Batches: 1 Memory Usage: 10kB
39. 0.008 0.008 ↓ 1.0 22 3 / 3

Seq Scan on tipodocumento t (cost=0.00..1.21 rows=21 width=82) (actual time=0.006..0.008 rows=22 loops=3)

Planning time : 2.474 ms
Execution time : 3,217.565 ms