explain.depesz.com

PostgreSQL's explain analyze made readable

Result: u5Yc : Optimization for: plan #rjKU

Settings

Optimization path:

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 142.304 10,048.075 ↓ 1.1 58,964 1

Append (cost=234,236.36..242,823.79 rows=53,151 width=579) (actual time=8,257.443..10,048.075 rows=58,964 loops=1)

2. 3,072.449 8,429.550 ↑ 1.0 52,351 1

Sort (cost=234,236.36..234,367.40 rows=52,417 width=461) (actual time=8,257.440..8,429.550 rows=52,351 loops=1)

  • Sort Key: empresas_sucursales.nro_patronal
  • Sort Method: external merge Disk: 19864kB
3. 441.330 5,357.101 ↑ 1.0 52,351 1

Hash Left Join (cost=3,149.63..222,319.96 rows=52,417 width=461) (actual time=507.272..5,357.101 rows=52,351 loops=1)

  • Hash Cond: (empresas_sucursales.id_tipo_inscripcion = empresas_tipo_inscripcion.id_tipo_inscripcion)
4. 191.815 2,507.610 ↑ 1.0 52,351 1

Hash Left Join (cost=3,148.56..10,913.46 rows=52,417 width=441) (actual time=507.159..2,507.610 rows=52,351 loops=1)

  • Hash Cond: (empresas_sucursales.type = empresas_sucursales_types.id)
5. 213.765 2,315.782 ↑ 1.0 52,351 1

Hash Left Join (cost=3,147.51..10,191.68 rows=52,417 width=434) (actual time=507.129..2,315.782 rows=52,351 loops=1)

  • Hash Cond: (empresas_sucursales.id_activ_econ = actividad_econ.id_activ_econ)
6. 218.886 2,100.365 ↑ 1.0 52,351 1

Hash Left Join (cost=3,122.09..9,445.52 rows=52,417 width=380) (actual time=505.463..2,100.365 rows=52,351 loops=1)

  • Hash Cond: (empresas_sucursales.distrito_id = distritos.id)
7. 216.260 1,881.437 ↑ 1.0 52,351 1

Hash Left Join (cost=3,120.68..8,723.71 rows=52,417 width=369) (actual time=505.406..1,881.437 rows=52,351 loops=1)

  • Hash Cond: (empresas_sucursales.city_id = city.id)
8. 162.217 1,664.609 ↑ 1.0 52,351 1

Hash Left Join (cost=3,107.97..7,992.38 rows=52,417 width=333) (actual time=504.822..1,664.609 rows=52,351 loops=1)

  • Hash Cond: (emp.id_categoria_empresa = empresas_categorias.id_categoria_empresa)
9. 209.328 1,502.378 ↑ 1.0 52,351 1

Hash Left Join (cost=3,106.88..7,764.48 rows=52,417 width=319) (actual time=504.796..1,502.378 rows=52,351 loops=1)

  • Hash Cond: (emp.type = empresas_types.id)
10. 425.179 1,292.989 ↑ 1.0 52,351 1

Hash Join (cost=3,105.20..7,042.07 rows=52,417 width=304) (actual time=504.712..1,292.989 rows=52,351 loops=1)

  • Hash Cond: (empresas_sucursales.empresa_id = emp.id)
11. 363.149 363.149 ↑ 1.0 52,353 1

Seq Scan on empresas_sucursales (cost=0.00..2,888.50 rows=52,420 width=239) (actual time=0.025..363.149 rows=52,353 loops=1)

  • Filter: (type = 1)
  • Rows Removed by Filter: 6652
12. 193.979 504.661 ↓ 1.0 52,210 1

Hash (cost=2,452.64..2,452.64 rows=52,205 width=81) (actual time=504.661..504.661 rows=52,210 loops=1)

  • Buckets: 8192 Batches: 1 Memory Usage: 5856kB
13. 310.682 310.682 ↓ 1.0 52,210 1

Seq Scan on empresas emp (cost=0.00..2,452.64 rows=52,205 width=81) (actual time=0.046..310.682 rows=52,210 loops=1)

  • Filter: (((document)::text <> '0'::text) AND ((document)::text <> ''::text) AND ((document)::text <> '-'::text))
  • Rows Removed by Filter: 2
14. 0.029 0.061 ↑ 1.0 30 1

Hash (cost=1.30..1.30 rows=30 width=23) (actual time=0.061..0.061 rows=30 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 2kB
15. 0.032 0.032 ↑ 1.0 30 1

Seq Scan on empresas_types (cost=0.00..1.30 rows=30 width=23) (actual time=0.005..0.032 rows=30 loops=1)

16. 0.006 0.014 ↑ 1.0 4 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
17. 0.008 0.008 ↑ 1.0 4 1

Seq Scan on empresas_categorias (cost=0.00..1.04 rows=4 width=18) (actual time=0.004..0.008 rows=4 loops=1)

18. 0.289 0.568 ↑ 1.0 254 1

Hash (cost=9.54..9.54 rows=254 width=40) (actual time=0.568..0.568 rows=254 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 19kB
19. 0.279 0.279 ↑ 1.0 254 1

Seq Scan on city (cost=0.00..9.54 rows=254 width=40) (actual time=0.006..0.279 rows=254 loops=1)

20. 0.021 0.042 ↑ 1.0 18 1

Hash (cost=1.18..1.18 rows=18 width=19) (actual time=0.042..0.042 rows=18 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
21. 0.021 0.021 ↑ 1.0 18 1

Seq Scan on distritos (cost=0.00..1.18 rows=18 width=19) (actual time=0.006..0.021 rows=18 loops=1)

22. 0.861 1.652 ↑ 1.0 730 1

Hash (cost=16.30..16.30 rows=730 width=58) (actual time=1.652..1.652 rows=730 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 66kB
23. 0.791 0.791 ↑ 1.0 730 1

Seq Scan on actividad_econ (cost=0.00..16.30 rows=730 width=58) (actual time=0.006..0.791 rows=730 loops=1)

24. 0.005 0.013 ↑ 1.0 1 1

Hash (cost=1.04..1.04 rows=1 width=23) (actual time=0.013..0.013 rows=1 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
25. 0.008 0.008 ↑ 1.0 1 1

Seq Scan on empresas_sucursales_types (cost=0.00..1.04 rows=1 width=23) (actual time=0.007..0.008 rows=1 loops=1)

  • Filter: (id = 1)
  • Rows Removed by Filter: 2
26. 0.006 0.015 ↑ 1.0 3 1

Hash (cost=1.03..1.03 rows=3 width=24) (actual time=0.015..0.015 rows=3 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
27. 0.009 0.009 ↑ 1.0 3 1

Seq Scan on empresas_tipo_inscripcion (cost=0.00..1.03 rows=3 width=24) (actual time=0.006..0.009 rows=3 loops=1)

28.          

SubPlan (forHash Left Join)

29. 261.755 2,408.146 ↑ 1.0 1 52,351

Limit (cost=0.42..4.02 rows=1 width=27) (actual time=0.044..0.046 rows=1 loops=52,351)

30. 697.092 2,146.391 ↑ 2.0 1 52,351

Nested Loop (cost=0.42..7.62 rows=2 width=27) (actual time=0.041..0.041 rows=1 loops=52,351)

  • Join Filter: (cambio_situacion_empresa.situacion_act = situacion_emp.id_situacion)
  • Rows Removed by Join Filter: 3
31. 1,099.371 1,099.371 ↑ 2.0 1 52,351

Index Scan using cambio_situacion_empresa_nro_patronal_fecha_creacion_id_cam_idx on cambio_situacion_empresa (cost=0.42..6.32 rows=2 width=20) (actual time=0.021..0.021 rows=1 loops=52,351)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
32. 349.914 349.928 ↑ 1.4 5 43,741

Materialize (cost=0.00..1.10 rows=7 width=15) (actual time=0.002..0.008 rows=5 loops=43,741)

33. 0.014 0.014 ↑ 1.0 7 1

Seq Scan on situacion_emp (cost=0.00..1.07 rows=7 width=15) (actual time=0.006..0.014 rows=7 loops=1)

34. 42.774 1,476.221 ↓ 9.0 6,613 1

Sort (cost=7,923.04..7,924.88 rows=734 width=463) (actual time=1,469.853..1,476.221 rows=6,613 loops=1)

  • Sort Key: empresas_sucursales_1.nro_patronal
  • Sort Method: quicksort Memory: 4555kB
35. 100.890 1,433.447 ↓ 9.0 6,613 1

Nested Loop Left Join (cost=14.41..7,888.10 rows=734 width=463) (actual time=0.932..1,433.447 rows=6,613 loops=1)

36. 65.165 942.390 ↓ 9.0 6,613 1

Nested Loop Left Join (cost=14.41..4,907.68 rows=734 width=443) (actual time=0.845..942.390 rows=6,613 loops=1)

37. 52.789 797.869 ↓ 9.0 6,613 1

Nested Loop Left Join (cost=14.41..4,877.50 rows=734 width=436) (actual time=0.816..797.869 rows=6,613 loops=1)

38. 22.759 626.046 ↓ 9.0 6,613 1

Hash Left Join (cost=14.41..4,827.31 rows=734 width=382) (actual time=0.751..626.046 rows=6,613 loops=1)

  • Hash Cond: (empresas_sucursales_1.distrito_id = distritos_1.id)
39. 35.636 603.249 ↓ 9.0 6,613 1

Hash Left Join (cost=13.00..4,815.81 rows=734 width=371) (actual time=0.698..603.249 rows=6,613 loops=1)

  • Hash Cond: (empresas_sucursales_1.city_id = city_1.id)
40. 32.334 567.080 ↓ 9.0 6,613 1

Nested Loop Left Join (cost=0.29..4,793.04 rows=734 width=335) (actual time=0.148..567.080 rows=6,613 loops=1)

41. 58.438 514.907 ↓ 9.0 6,613 1

Nested Loop Left Join (cost=0.29..4,772.71 rows=734 width=321) (actual time=0.142..514.907 rows=6,613 loops=1)

42. 45.330 350.661 ↓ 9.0 6,613 1

Nested Loop (cost=0.29..4,752.39 rows=734 width=306) (actual time=0.085..350.661 rows=6,613 loops=1)

43. 72.511 72.511 ↓ 9.1 6,652 1

Seq Scan on empresas_sucursales empresas_sucursales_1 (cost=0.00..3,036.00 rows=734 width=302) (actual time=0.030..72.511 rows=6,652 loops=1)

  • Filter: ((type <> 1) AND (type <> 1))
  • Rows Removed by Filter: 52353
44. 232.820 232.820 ↑ 1.0 1 6,652

Index Scan using empresas_pk on empresas emp_1 (cost=0.29..2.33 rows=1 width=20) (actual time=0.033..0.035 rows=1 loops=6,652)

  • Index Cond: (id = empresas_sucursales_1.empresa_id)
  • Filter: (((document)::text <> '0'::text) AND ((document)::text <> ''::text) AND ((document)::text <> '-'::text))
  • Rows Removed by Filter: 0
45. 105.808 105.808 ↑ 1.0 1 6,613

Index Scan using empresas_types_id_idx on empresas_types empresas_types_1 (cost=0.00..0.02 rows=1 width=23) (actual time=0.013..0.016 rows=1 loops=6,613)

  • Index Cond: (emp_1.type = id)
46. 19.839 19.839 ↓ 0.0 0 6,613

Index Scan using empresas_categorias_id_categoria_empresa_idx on empresas_categorias empresas_categorias_1 (cost=0.00..0.02 rows=1 width=18) (actual time=0.003..0.003 rows=0 loops=6,613)

  • Index Cond: (emp_1.id_categoria_empresa = id_categoria_empresa)
47. 0.290 0.533 ↑ 1.0 254 1

Hash (cost=9.54..9.54 rows=254 width=40) (actual time=0.533..0.533 rows=254 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 19kB
48. 0.243 0.243 ↑ 1.0 254 1

Seq Scan on city city_1 (cost=0.00..9.54 rows=254 width=40) (actual time=0.006..0.243 rows=254 loops=1)

49. 0.018 0.038 ↑ 1.0 18 1

Hash (cost=1.18..1.18 rows=18 width=19) (actual time=0.038..0.038 rows=18 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
50. 0.020 0.020 ↑ 1.0 18 1

Seq Scan on distritos distritos_1 (cost=0.00..1.18 rows=18 width=19) (actual time=0.005..0.020 rows=18 loops=1)

51. 119.034 119.034 ↑ 1.0 1 6,613

Index Scan using actividad_econ_id_activ_econ_idx on actividad_econ actividad_econ_1 (cost=0.00..0.06 rows=1 width=58) (actual time=0.017..0.018 rows=1 loops=6,613)

  • Index Cond: (empresas_sucursales_1.id_activ_econ = id_activ_econ)
52. 79.356 79.356 ↑ 1.0 1 6,613

Index Scan using empresas_sucursales_types_id_idx on empresas_sucursales_types empresas_sucursales_types_1 (cost=0.00..0.03 rows=1 width=23) (actual time=0.010..0.012 rows=1 loops=6,613)

  • Index Cond: (empresas_sucursales_1.type = id)
53. 92.582 92.582 ↑ 1.0 1 6,613

Index Scan using empresas_tipo_inscripcion_id_tipo_inscripcion_idx on empresas_tipo_inscripcion empresas_tipo_inscripcion_1 (cost=0.00..0.03 rows=1 width=24) (actual time=0.009..0.014 rows=1 loops=6,613)

  • Index Cond: (empresas_sucursales_1.id_tipo_inscripcion = id_tipo_inscripcion)
54.          

SubPlan (forNested Loop Left Join)

55. 39.678 297.585 ↑ 1.0 1 6,613

Limit (cost=0.42..4.02 rows=1 width=27) (actual time=0.043..0.045 rows=1 loops=6,613)

56. 82.614 257.907 ↑ 2.0 1 6,613

Nested Loop (cost=0.42..7.62 rows=2 width=27) (actual time=0.039..0.039 rows=1 loops=6,613)

  • Join Filter: (cambio_situacion_empresa_1.situacion_act = situacion_emp_1.id_situacion)
  • Rows Removed by Join Filter: 4
57. 119.034 119.034 ↑ 2.0 1 6,613

Index Scan using cambio_situacion_empresa_nro_patronal_fecha_creacion_id_cam_idx on cambio_situacion_empresa cambio_situacion_empresa_1 (cost=0.42..6.32 rows=2 width=20) (actual time=0.018..0.018 rows=1 loops=6,613)

  • Index Cond: (nro_patronal = empresas_sucursales_1.nro_patronal)
58. 56.252 56.259 ↑ 1.4 5 6,251

Materialize (cost=0.00..1.10 rows=7 width=15) (actual time=0.001..0.009 rows=5 loops=6,251)

59. 0.007 0.007 ↑ 1.2 6 1

Seq Scan on situacion_emp situacion_emp_1 (cost=0.00..1.07 rows=7 width=15) (actual time=0.004..0.007 rows=6 loops=1)