explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 4SfV

Settings
# exclusive inclusive rows x rows loops node
1. 0.002 13,157.331 ↑ 50.0 1 1

Limit (cost=22.88..32,182.38 rows=50 width=582) (actual time=13,157.290..13,157.331 rows=1 loops=1)

2. 0.003 13,157.329 ↑ 4,100.0 1 1

Unique (cost=22.88..2,637,101.32 rows=4,100 width=582) (actual time=13,157.289..13,157.329 rows=1 loops=1)

3. 0.258 13,157.326 ↑ 1,366.7 3 1

Nested Loop Left Join (cost=22.88..2,637,091.07 rows=4,100 width=582) (actual time=13,157.287..13,157.326 rows=3 loops=1)

4. 0.003 13,157.041 ↑ 1,366.7 3 1

Nested Loop Left Join (cost=22.46..2,633,957.14 rows=4,100 width=557) (actual time=13,157.028..13,157.041 rows=3 loops=1)

5. 0.006 13,157.017 ↑ 1,366.7 3 1

Nested Loop Left Join (cost=22.32..2,633,050.37 rows=4,100 width=439) (actual time=13,157.008..13,157.017 rows=3 loops=1)

  • Join Filter: (v.codigo = COALESCE(pv.codvendedor, snf.codvendedor, cav.vendedores_codigo))
  • Rows Removed by Join Filter: 24
6. 0.002 13,156.990 ↑ 1,366.7 3 1

Nested Loop Left Join (cost=22.32..2,630,660.49 rows=4,100 width=430) (actual time=13,156.985..13,156.990 rows=3 loops=1)

7. 0.002 13,156.966 ↑ 4,100.0 1 1

Nested Loop Left Join (cost=22.17..2,629,498.02 rows=4,100 width=426) (actual time=13,156.963..13,156.966 rows=1 loops=1)

8. 334.667 13,156.937 ↑ 4,100.0 1 1

Nested Loop Left Join (cost=21.88..2,619,896.99 rows=4,100 width=400) (actual time=13,156.934..13,156.937 rows=1 loops=1)

  • Filter: (COALESCE(pv.codtecnico, snf.codtecnico, cat.tecnicos_codigo) = 1)
  • Rows Removed by Filter: 820004
9. 480.891 12,822.270 ↓ 1.0 820,004 1

Nested Loop Left Join (cost=21.73..2,379,201.99 rows=820,003 width=396) (actual time=0.147..12,822.270 rows=820,004 loops=1)

10. 267.110 12,341.379 ↓ 1.0 820,004 1

Nested Loop Left Join (cost=21.31..1,882,600.87 rows=820,003 width=388) (actual time=0.146..12,341.379 rows=820,004 loops=1)

11. 260.388 10,434.261 ↓ 1.0 820,004 1

Nested Loop Left Join (cost=20.89..1,438,993.63 rows=820,003 width=380) (actual time=0.143..10,434.261 rows=820,004 loops=1)

12. 482.258 9,353.869 ↓ 1.0 820,004 1

Nested Loop Left Join (cost=20.75..1,312,467.41 rows=820,003 width=302) (actual time=0.139..9,353.869 rows=820,004 loops=1)

13. 401.242 8,871.611 ↓ 1.0 820,004 1

Nested Loop Left Join (cost=20.60..1,177,122.89 rows=820,003 width=184) (actual time=0.138..8,871.611 rows=820,004 loops=1)

14. 407.683 7,650.365 ↓ 1.0 820,004 1

Merge Left Join (cost=20.45..1,041,807.64 rows=820,003 width=63) (actual time=0.134..7,650.365 rows=820,004 loops=1)

  • Merge Cond: (cr.codigo = cr_sit.contasareceber_codigo)
15. 243.027 6,694.386 ↓ 1.0 820,004 1

Merge Left Join (cost=14.72..990,881.97 rows=820,003 width=59) (actual time=0.127..6,694.386 rows=820,004 loops=1)

  • Merge Cond: (cr.codigo = crav.contasareceber_codigo)
16. 367.356 6,451.344 ↓ 1.0 820,004 1

Nested Loop Left Join (cost=14.57..988,727.71 rows=820,003 width=51) (actual time=0.114..6,451.344 rows=820,004 loops=1)

17. 312.299 4,443.980 ↓ 1.0 820,004 1

Nested Loop Left Join (cost=14.15..545,120.47 rows=820,003 width=47) (actual time=0.108..4,443.980 rows=820,004 loops=1)

18. 325.876 2,491.673 ↓ 1.0 820,004 1

Merge Join (cost=13.72..165,787.10 rows=820,003 width=47) (actual time=0.101..2,491.673 rows=820,004 loops=1)

  • Merge Cond: (cr.codigo = cr_fat.contasareceber_codigo)
19. 405.361 1,503.723 ↓ 1.0 820,039 1

Merge Left Join (cost=6.90..106,520.33 rows=820,038 width=47) (actual time=0.088..1,503.723 rows=820,039 loops=1)

  • Merge Cond: (cr.codigo = pvpg_cr.contasareceber_codigo)
20. 261.059 528.822 ↓ 1.0 820,039 1

Merge Left Join (cost=1.43..55,661.18 rows=820,038 width=43) (actual time=0.079..528.822 rows=820,039 loops=1)

  • Merge Cond: (cr.codigo = snfpg_cr.contasareceber_codigo)
21. 266.626 266.626 ↓ 1.0 820,039 1

Index Scan using contasareceber_pkey1 on contasareceber cr (cost=0.42..42,216.05 rows=820,038 width=35) (actual time=0.006..266.626 rows=820,039 loops=1)

22. 0.041 1.137 ↑ 64.6 35 1

Materialize (cost=1.00..11,366.78 rows=2,260 width=12) (actual time=0.070..1.137 rows=35 loops=1)

23. 0.038 1.096 ↑ 64.6 35 1

Nested Loop Left Join (cost=1.00..11,361.13 rows=2,260 width=12) (actual time=0.067..1.096 rows=35 loops=1)

24. 0.052 0.533 ↑ 64.6 35 1

Nested Loop Left Join (cost=0.58..9,992.46 rows=2,260 width=8) (actual time=0.037..0.533 rows=35 loops=1)

25. 0.026 0.026 ↑ 64.6 35 1

Index Only Scan using saidasnf_pagtos_contasarecebe_contasareceber_codigo_saidasn_key on saidasnf_pagtos_contasareceber snfpg_cr (cost=0.15..82.06 rows=2,260 width=8) (actual time=0.004..0.026 rows=35 loops=1)

  • Heap Fetches: 35
26. 0.455 0.455 ↑ 1.0 1 35

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

  • Index Cond: (snfpg_cr.saidasnf_pagtos_codigo = codigo)
27. 0.525 0.525 ↑ 1.0 1 35

Index Scan using saidasnf_codigo_index on saidasnf snf_1 (cost=0.42..0.61 rows=1 width=8) (actual time=0.015..0.015 rows=1 loops=35)

  • Index Cond: (snfpg.codsaidasnf = codigo)
28. 569.540 569.540 ↑ 1.0 819,997 1

Index Only Scan using prevendas_pagtos_contasareceb_contasareceber_codigo_prevend_key on prevendas_pagtos_contasareceber pvpg_cr (cost=0.42..38,560.08 rows=819,997 width=8) (actual time=0.008..569.540 rows=819,997 loops=1)

  • Heap Fetches: 819997
29. 662.074 662.074 ↓ 1.0 820,004 1

Index Only Scan using contasareceber_faturamentos_pkey on contasareceber_faturamentos cr_fat (cost=0.42..46,970.48 rows=820,003 width=4) (actual time=0.013..662.074 rows=820,004 loops=1)

  • Index Cond: (contasareceber_codigo IS NOT NULL)
  • Heap Fetches: 820004
30. 1,640.008 1,640.008 ↑ 1.0 1 820,004

Index Scan using prevenda_pagto_pkey on prevenda_pagto pvpg (cost=0.42..0.46 rows=1 width=8) (actual time=0.002..0.002 rows=1 loops=820,004)

  • Index Cond: (pvpg_cr.prevendas_pagtos_codigo = codigo)
31. 1,640.008 1,640.008 ↑ 1.0 1 820,004

Index Scan using prevendas_codigo_index on prevendas pv_1 (cost=0.42..0.54 rows=1 width=8) (actual time=0.002..0.002 rows=1 loops=820,004)

  • Index Cond: (pvpg.codprevenda = codigo)
32. 0.015 0.015 ↑ 291.4 7 1

Index Scan using contasareceber_avulsas_contasareceber_codigo_key on contasareceber_avulsas crav (cost=0.15..78.75 rows=2,040 width=12) (actual time=0.012..0.015 rows=7 loops=1)

33. 548.296 548.296 ↓ 1.0 820,039 1

Index Scan using contasareceber_situacao_pkey on contasareceber_situacao cr_sit (cost=0.42..38,625.54 rows=820,038 width=8) (actual time=0.006..548.296 rows=820,039 loops=1)

34. 820.004 820.004 ↑ 1.0 1 820,004

Index Scan using situacoescontas_pkey on situacoescontas sc (cost=0.15..0.17 rows=1 width=125) (actual time=0.001..0.001 rows=1 loops=820,004)

  • Index Cond: (cr_sit.situacoesconta_codigo = codigo)
35. 0.000 0.000 ↓ 0.0 0 820,004

Index Scan using gruposcontas_pkey on gruposcontas grct (cost=0.15..0.17 rows=1 width=122) (actual time=0.000..0.000 rows=0 loops=820,004)

  • Index Cond: (codigo = cr.gruposcontas_codigo)
36. 820.004 820.004 ↑ 1.0 1 820,004

Index Scan using tipodocumento_pkey on tipodocumento t_1 (cost=0.14..0.16 rows=1 width=82) (actual time=0.001..0.001 rows=1 loops=820,004)

  • Index Cond: (codigo = cr.tipodocumento_codigo)
37. 1,640.008 1,640.008 ↑ 1.0 1 820,004

Index Scan using prevendas_codigo_index on prevendas pv (cost=0.42..0.54 rows=1 width=12) (actual time=0.002..0.002 rows=1 loops=820,004)

  • Index Cond: (codigo = pvpg.codprevenda)
38. 0.000 0.000 ↓ 0.0 0 820,004

Index Scan using saidasnf_codigo_index on saidasnf snf (cost=0.42..0.61 rows=1 width=12) (actual time=0.000..0.000 rows=0 loops=820,004)

  • Index Cond: (codigo = snfpg.codsaidasnf)
39. 0.000 0.000 ↓ 0.0 0 820,004

Index Only Scan using contasareceber_avulsas_tecnic_contasareceber_avulsas_codigo_key on contasareceber_avulsas_tecnicos cat (cost=0.15..0.24 rows=4 width=8) (actual time=0.000..0.000 rows=0 loops=820,004)

  • Index Cond: (contasareceber_avulsas_codigo = crav.codigo)
  • Heap Fetches: 2
40. 0.027 0.027 ↑ 1.0 1 1

Index Scan using unq_clientes on clientes cli (cost=0.29..2.34 rows=1 width=30) (actual time=0.027..0.027 rows=1 loops=1)

  • Index Cond: (codigo = CASE WHEN (crav.clientes_codigo IS NOT NULL) THEN crav.clientes_codigo WHEN (pv_1.codcliente IS NOT NULL) THEN pv_1.codcliente WHEN (snf_1.codcliente IS NOT NULL) THEN snf_1.codcliente ELSE NULL::integer END)
41. 0.022 0.022 ↑ 1.3 3 1

Index Only Scan using contasareceber_avulsas_vended_contasareceber_avulsas_codigo_key on contasareceber_avulsas_vendedores cav (cost=0.15..0.24 rows=4 width=8) (actual time=0.020..0.022 rows=3 loops=1)

  • Index Cond: (contasareceber_avulsas_codigo = crav.codigo)
  • Heap Fetches: 3
42. 0.005 0.021 ↑ 4.3 9 3

Materialize (cost=0.00..2.58 rows=39 width=13) (actual time=0.006..0.007 rows=9 loops=3)

43. 0.016 0.016 ↑ 3.9 10 1

Seq Scan on vendedores v (cost=0.00..2.39 rows=39 width=13) (actual time=0.015..0.016 rows=10 loops=1)

44. 0.021 0.021 ↑ 1.0 1 3

Index Scan using tecnicos_pkey on tecnicos t (cost=0.14..0.22 rows=1 width=122) (actual time=0.007..0.007 rows=1 loops=3)

  • Index Cond: (codigo = COALESCE(pv.codtecnico, snf.codtecnico, cat.tecnicos_codigo))
45. 0.027 0.027 ↓ 0.0 0 3

Index Scan using contasareceber_pagtos_contasareceber_faturamentos_cr_codigo_idx on contasareceber_pagtos crpg (cost=0.42..0.50 rows=1 width=12) (actual time=0.009..0.009 rows=0 loops=3)

  • Index Cond: (contasareceber_faturamentos_cr_codigo = cr.codigo)
Planning time : 17.079 ms
Execution time : 13,157.528 ms