explain.depesz.com

PostgreSQL's explain analyze made readable

Result: KKIn : Optimization for: Optimization for: plan #FPuB; plan #l6Wd

Settings

Optimization path:

# exclusive inclusive rows x rows loops node
1. 4.812 147.977 ↓ 1.9 2,522 1

Sort (cost=20,760.85..20,764.17 rows=1,328 width=991) (actual time=147.476..147.977 rows=2,522 loops=1)

  • Sort Key: (date(ddo.ddo_fechaven))
  • Sort Method: quicksort Memory: 1449kB
2. 86.374 143.165 ↓ 1.9 2,522 1

Gather (cost=2,183.72..20,691.96 rows=1,328 width=991) (actual time=15.461..143.165 rows=2,522 loops=1)

  • Workers Planned: 1
  • Workers Launched: 1
3. 1.196 56.757 ↓ 1.6 1,261 2

Hash Left Join (cost=1,183.72..6,387.64 rows=781 width=365) (actual time=17.069..56.757 rows=1,261 loops=2)

  • Hash Cond: ((ubi.ubi_id = rua.ubi_id) AND (emp.emp_id = rua.emp_id))
4. 1.040 55.473 ↓ 1.6 1,261 2

Hash Left Join (cost=1,174.12..6,366.20 rows=781 width=373) (actual time=16.960..55.473 rows=1,261 loops=2)

  • Hash Cond: (ent.ent_telefono_principal = tel.tel_id)
5. 1.103 51.485 ↓ 1.6 1,261 2

Hash Left Join (cost=995.30..6,178.31 rows=781 width=368) (actual time=13.950..51.485 rows=1,261 loops=2)

  • Hash Cond: (ent.ent_direccion_principal = dir.dir_id)
6. 0.871 46.228 ↓ 1.6 1,261 2

Hash Left Join (cost=784.02..5,956.30 rows=781 width=334) (actual time=9.737..46.228 rows=1,261 loops=2)

  • Hash Cond: (cli.can_id = can.can_id)
7. 0.808 45.335 ↓ 1.6 1,261 2

Hash Left Join (cost=782.91..5,949.83 rows=781 width=331) (actual time=9.700..45.335 rows=1,261 loops=2)

  • Hash Cond: (cli.cat_id = cat.cat_id)
8. 0.983 44.495 ↓ 1.6 1,261 2

Hash Left Join (cost=781.77..5,937.95 rows=781 width=310) (actual time=9.647..44.495 rows=1,261 loops=2)

  • Hash Cond: (dcom.cco_id = cue.cco_id)
9. 10.807 43.214 ↓ 1.6 1,261 2

Nested Loop Left Join (cost=766.77..5,912.22 rows=781 width=276) (actual time=9.329..43.214 rows=1,261 loops=2)

10. 0.871 32.399 ↓ 1.6 1,261 2

Hash Left Join (cost=766.35..4,514.49 rows=781 width=276) (actual time=9.280..32.399 rows=1,261 loops=2)

  • Hash Cond: (cli.emp_id = emp.emp_id)
11. 0.766 31.144 ↓ 1.6 1,261 2

Hash Left Join (cost=650.14..4,392.91 rows=781 width=248) (actual time=8.875..31.144 rows=1,261 loops=2)

  • Hash Cond: (ccm.cti_id = cti.cti_id)
12. 0.789 30.312 ↓ 1.6 1,261 2

Hash Left Join (cost=645.61..4,377.64 rows=781 width=244) (actual time=8.789..30.312 rows=1,261 loops=2)

  • Hash Cond: (cli.ubi_id = ubi.ubi_id)
13. 0.860 29.351 ↓ 1.6 1,261 2

Hash Left Join (cost=636.67..4,357.96 rows=781 width=234) (actual time=8.593..29.351 rows=1,261 loops=2)

  • Hash Cond: (ccm.pve_id = pve.pve_id)
14. 8.917 28.423 ↓ 1.6 1,261 2

Nested Loop Left Join (cost=634.50..4,346.62 rows=781 width=226) (actual time=8.502..28.423 rows=1,261 loops=2)

15. 1.468 19.500 ↓ 1.6 1,261 2

Hash Join (cost=634.09..3,448.19 rows=781 width=174) (actual time=8.450..19.500 rows=1,261 loops=2)

  • Hash Cond: (ddo.cli_id = cli.cli_id)
16. 9.737 9.737 ↑ 1.7 1,458 2

Parallel Seq Scan on ddocumento ddo (cost=0.00..2,796.87 rows=2,514 width=78) (actual time=0.023..9.737 rows=1,458 loops=2)

  • Filter: ((NOT ddo_cancelado) AND (ddo_transacc = 1))
  • Rows Removed by Filter: 16723
17. 1.249 8.295 ↑ 1.0 1,922 2

Hash (cost=610.06..610.06 rows=1,922 width=100) (actual time=8.295..8.295 rows=1,922 loops=2)

  • Buckets: 2048 Batches: 1 Memory Usage: 259kB
18. 2.477 7.046 ↑ 1.0 1,922 2

Hash Right Join (cost=328.35..610.06 rows=1,922 width=100) (actual time=3.261..7.046 rows=1,922 loops=2)

  • Hash Cond: (ent.ent_id = cli.ent_id)
19. 1.345 1.345 ↓ 1.0 5,946 2

Seq Scan on entidad ent (cost=0.00..225.38 rows=5,938 width=40) (actual time=0.016..1.345 rows=5,946 loops=2)

20. 0.745 3.224 ↑ 1.0 1,922 2

Hash (cost=304.32..304.32 rows=1,922 width=68) (actual time=3.224..3.224 rows=1,922 loops=2)

  • Buckets: 2048 Batches: 1 Memory Usage: 197kB
21. 2.479 2.479 ↑ 1.0 1,922 2

Seq Scan on cliente cli (cost=0.00..304.32 rows=1,922 width=68) (actual time=0.021..2.479 rows=1,922 loops=2)

  • Filter: (cli_tipocli = 1)
  • Rows Removed by Filter: 4274
22. 0.006 0.006 ↑ 1.0 1 2,522

Index Scan using pk_ccomproba on ccomproba ccm (cost=0.42..1.14 rows=1 width=56) (actual time=0.006..0.006 rows=1 loops=2,522)

  • Index Cond: (ddo.ccm_id = ccm_id)
23. 0.012 0.068 ↓ 1.2 5 2

Hash (cost=2.11..2.11 rows=4 width=12) (actual time=0.068..0.068 rows=5 loops=2)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
24. 0.028 0.056 ↓ 1.2 5 2

Nested Loop Left Join (cost=0.00..2.11 rows=4 width=12) (actual time=0.051..0.056 rows=5 loops=2)

  • Join Filter: (pve.alm_id = alm.alm_id)
25. 0.023 0.023 ↓ 1.2 5 2

Seq Scan on puntoventa pve (cost=0.00..1.04 rows=4 width=12) (actual time=0.021..0.023 rows=5 loops=2)

26. 0.000 0.005 ↑ 1.0 1 10

Materialize (cost=0.00..1.01 rows=1 width=8) (actual time=0.005..0.005 rows=1 loops=10)

27. 0.015 0.015 ↑ 1.0 1 2

Seq Scan on almacen alm (cost=0.00..1.01 rows=1 width=8) (actual time=0.015..0.015 rows=1 loops=2)

28. 0.083 0.172 ↓ 1.0 268 2

Hash (cost=5.64..5.64 rows=264 width=14) (actual time=0.172..0.172 rows=268 loops=2)

  • Buckets: 1024 Batches: 1 Memory Usage: 21kB
29. 0.089 0.089 ↓ 1.0 268 2

Seq Scan on ubicacion ubi (cost=0.00..5.64 rows=264 width=14) (actual time=0.019..0.089 rows=268 loops=2)

30. 0.020 0.066 ↓ 1.0 69 2

Hash (cost=3.68..3.68 rows=68 width=8) (actual time=0.066..0.066 rows=69 loops=2)

  • Buckets: 1024 Batches: 1 Memory Usage: 11kB
31. 0.046 0.046 ↓ 1.0 69 2

Seq Scan on ctipocom cti (cost=0.00..3.68 rows=68 width=8) (actual time=0.015..0.046 rows=69 loops=2)

32. 0.048 0.384 ↓ 1.1 67 2

Hash (cost=115.44..115.44 rows=62 width=32) (actual time=0.384..0.384 rows=67 loops=2)

  • Buckets: 1024 Batches: 1 Memory Usage: 13kB
33. 0.303 0.336 ↓ 1.1 67 2

Nested Loop Left Join (cost=0.28..115.44 rows=62 width=32) (actual time=0.036..0.336 rows=67 loops=2)

34. 0.029 0.029 ↓ 1.1 67 2

Seq Scan on empleado emp (cost=0.00..1.62 rows=62 width=8) (actual time=0.017..0.029 rows=67 loops=2)

35. 0.004 0.004 ↑ 1.0 1 134

Index Scan using pk_entidad on entidad ent1 (cost=0.28..1.83 rows=1 width=32) (actual time=0.003..0.004 rows=1 loops=134)

  • Index Cond: (emp.ent_id = ent_id)
36. 0.008 0.008 ↑ 1.0 1 2,522

Index Scan using dcomproba_pkey on dcomproba dcom (cost=0.42..1.78 rows=1 width=8) (actual time=0.007..0.008 rows=1 loops=2,522)

  • Index Cond: (ddo.dco_id = dco_id)
37. 0.152 0.298 ↓ 1.0 402 2

Hash (cost=10.00..10.00 rows=400 width=38) (actual time=0.298..0.298 rows=402 loops=2)

  • Buckets: 1024 Batches: 1 Memory Usage: 37kB
38. 0.146 0.146 ↓ 1.0 402 2

Seq Scan on cuenta_contable cue (cost=0.00..10.00 rows=400 width=38) (actual time=0.023..0.146 rows=402 loops=2)

39. 0.011 0.032 ↑ 1.0 6 2

Hash (cost=1.06..1.06 rows=6 width=29) (actual time=0.032..0.032 rows=6 loops=2)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
40. 0.021 0.021 ↑ 1.0 6 2

Seq Scan on catcliente cat (cost=0.00..1.06 rows=6 width=29) (actual time=0.019..0.021 rows=6 loops=2)

41. 0.005 0.022 ↑ 1.0 5 2

Hash (cost=1.05..1.05 rows=5 width=11) (actual time=0.022..0.022 rows=5 loops=2)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
42. 0.017 0.017 ↑ 1.0 5 2

Seq Scan on canal can (cost=0.00..1.05 rows=5 width=11) (actual time=0.015..0.017 rows=5 loops=2)

43. 2.232 4.154 ↑ 1.0 6,375 2

Hash (cost=130.57..130.57 rows=6,457 width=42) (actual time=4.154..4.154 rows=6,375 loops=2)

  • Buckets: 8192 Batches: 1 Memory Usage: 507kB
44. 1.922 1.922 ↑ 1.0 6,375 2

Seq Scan on direccion dir (cost=0.00..130.57 rows=6,457 width=42) (actual time=0.017..1.922 rows=6,375 loops=2)

45. 1.650 2.948 ↑ 1.0 6,373 2

Hash (cost=98.92..98.92 rows=6,392 width=13) (actual time=2.948..2.948 rows=6,373 loops=2)

  • Buckets: 8192 Batches: 1 Memory Usage: 352kB
46. 1.298 1.298 ↑ 1.0 6,373 2

Seq Scan on telefono tel (cost=0.00..98.92 rows=6,392 width=13) (actual time=0.030..1.298 rows=6,373 loops=2)

47. 0.045 0.088 ↑ 1.9 156 2

Hash (cost=5.04..5.04 rows=304 width=8) (actual time=0.088..0.088 rows=156 loops=2)

  • Buckets: 1024 Batches: 1 Memory Usage: 15kB
48. 0.043 0.043 ↑ 1.9 156 2

Seq Scan on ruta_agente rua (cost=0.00..5.04 rows=304 width=8) (actual time=0.019..0.043 rows=156 loops=2)

49.          

SubPlan (forGather)

50. 0.002 0.022 ↑ 1.0 1 2,522

Limit (cost=2.93..8.13 rows=1 width=418) (actual time=0.021..0.022 rows=1 loops=2,522)

51.          

Initplan (forLimit)

52. 0.001 0.006 ↑ 1.0 1 2,522

Limit (cost=0.29..2.51 rows=1 width=4) (actual time=0.005..0.006 rows=1 loops=2,522)

53. 0.005 0.005 ↑ 1.0 1 2,522

Index Scan using cfactura_llave_idx on cfactura cfac (cost=0.29..2.51 rows=1 width=4) (actual time=0.005..0.005 rows=1 loops=2,522)

  • Index Cond: ((cfa_numero = ccm.ccm_numero) AND (cti_id = ccm.cti_id))
  • Filter: (pve_id = ccm.pve_id)
54. 0.004 0.014 ↑ 14.0 1 2,522

Index Scan using dfactura_llave_cabecera on dfactura dfac (cost=0.42..73.16 rows=14 width=418) (actual time=0.014..0.014 rows=1 loops=2,522)

  • Index Cond: (cfa_id = $5)
55.          

SubPlan (forIndex Scan)

56. 0.001 0.010 ↑ 1.0 1 2,521

Limit (cost=0.56..5.00 rows=1 width=15) (actual time=0.009..0.010 rows=1 loops=2,521)

57. 0.001 0.009 ↑ 1.0 1 2,521

Nested Loop (cost=0.56..5.00 rows=1 width=15) (actual time=0.009..0.009 rows=1 loops=2,521)

58. 0.003 0.003 ↑ 1.0 1 2,521

Index Scan using producto_pkey on producto pro (cost=0.28..2.50 rows=1 width=12) (actual time=0.003..0.003 rows=1 loops=2,521)

  • Index Cond: (pro_id = dfac.pro_id)
59. 0.005 0.005 ↑ 1.0 1 2,521

Index Scan using idx_cla1_codigo on clasificacion1 cla1 (cost=0.28..2.49 rows=1 width=21) (actual time=0.005..0.005 rows=1 loops=2,521)

  • Index Cond: ((cla1_codigo)::text = "left"((pro.pro_codigo)::text, 2))
60. 0.003 0.012 ↑ 1.0 1 2,522

Aggregate (cost=1.64..1.65 rows=1 width=32) (actual time=0.012..0.012 rows=1 loops=2,522)

61. 0.009 0.009 ↓ 0.0 0 2,522

Seq Scan on cliente_gestion clg (cost=0.00..1.64 rows=1 width=33) (actual time=0.009..0.009 rows=0 loops=2,522)

  • Filter: (clg_id = cli.cli_id)
  • Rows Removed by Filter: 66