explain.depesz.com

PostgreSQL's explain analyze made readable

Result: rjKU

Settings

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 189.788 15,440.701 ↓ 1.1 58,963 1

Append (cost=418,215.96..429,379.67 rows=53,151 width=579) (actual time=13,289.287..15,440.701 rows=58,963 loops=1)

2. 6,322.409 13,474.421 ↑ 1.0 52,350 1

Sort (cost=418,215.96..418,347.00 rows=52,417 width=461) (actual time=13,289.285..13,474.421 rows=52,350 loops=1)

  • Sort Key: empresas_sucursales.nro_patronal
  • Sort Method: external merge Disk: 19864kB
3. 481.919 7,152.012 ↑ 1.0 52,350 1

Hash Left Join (cost=3,149.63..406,299.55 rows=52,417 width=461) (actual time=256.344..7,152.012 rows=52,350 loops=1)

  • Hash Cond: (empresas_sucursales.id_tipo_inscripcion = empresas_tipo_inscripcion.id_tipo_inscripcion)
4. 199.833 2,429.728 ↑ 1.0 52,350 1

Hash Left Join (cost=3,148.56..10,913.46 rows=52,417 width=441) (actual time=256.205..2,429.728 rows=52,350 loops=1)

  • Hash Cond: (empresas_sucursales.type = empresas_sucursales_types.id)
5. 269.155 2,229.879 ↑ 1.0 52,350 1

Hash Left Join (cost=3,147.51..10,191.68 rows=52,417 width=434) (actual time=256.168..2,229.879 rows=52,350 loops=1)

  • Hash Cond: (empresas_sucursales.id_activ_econ = actividad_econ.id_activ_econ)
6. 247.857 1,958.826 ↑ 1.0 52,350 1

Hash Left Join (cost=3,122.09..9,445.52 rows=52,417 width=380) (actual time=254.251..1,958.826 rows=52,350 loops=1)

  • Hash Cond: (empresas_sucursales.distrito_id = distritos.id)
7. 222.356 1,710.925 ↑ 1.0 52,350 1

Hash Left Join (cost=3,120.68..8,723.71 rows=52,417 width=369) (actual time=254.194..1,710.925 rows=52,350 loops=1)

  • Hash Cond: (empresas_sucursales.city_id = city.id)
8. 153.377 1,487.983 ↑ 1.0 52,350 1

Hash Left Join (cost=3,107.97..7,992.38 rows=52,417 width=333) (actual time=253.591..1,487.983 rows=52,350 loops=1)

  • Hash Cond: (emp.id_categoria_empresa = empresas_categorias.id_categoria_empresa)
9. 233.856 1,334.574 ↑ 1.0 52,350 1

Hash Left Join (cost=3,106.88..7,764.48 rows=52,417 width=319) (actual time=253.543..1,334.574 rows=52,350 loops=1)

  • Hash Cond: (emp.type = empresas_types.id)
10. 488.867 1,100.635 ↑ 1.0 52,350 1

Hash Join (cost=3,105.20..7,042.07 rows=52,417 width=304) (actual time=253.435..1,100.635 rows=52,350 loops=1)

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

Seq Scan on empresas_sucursales (cost=0.00..2,888.50 rows=52,420 width=239) (actual time=0.009..358.371 rows=52,352 loops=1)

  • Filter: (type = 1)
  • Rows Removed by Filter: 6652
12. 119.623 253.397 ↓ 1.0 52,209 1

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

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

Seq Scan on empresas emp (cost=0.00..2,452.64 rows=52,205 width=81) (actual time=0.013..133.774 rows=52,209 loops=1)

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

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

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

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

16. 0.022 0.032 ↑ 1.0 4 1

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

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

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

18. 0.290 0.586 ↑ 1.0 254 1

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

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

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

20. 0.022 0.044 ↑ 1.0 18 1

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

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

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

22. 0.906 1.898 ↑ 1.0 730 1

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

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

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

24. 0.004 0.016 ↑ 1.0 1 1

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

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

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

  • Filter: (id = 1)
  • Rows Removed by Filter: 2
26. 0.005 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.010 0.010 ↑ 1.0 3 1

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

28.          

SubPlan (forHash Left Join)

29. 366.450 4,240.350 ↑ 1.0 1 52,350

Limit (cost=7.53..7.53 rows=1 width=27) (actual time=0.079..0.081 rows=1 loops=52,350)

30. 785.250 3,873.900 ↑ 2.0 1 52,350

Sort (cost=7.53..7.53 rows=2 width=27) (actual time=0.074..0.074 rows=1 loops=52,350)

  • Sort Key: cambio_situacion_empresa.fecha_creacion, cambio_situacion_empresa.id_cambio_situacion_empresa
  • Sort Method: top-N heapsort Memory: 25kB
31. 523.474 3,088.650 ↑ 2.0 1 52,350

Hash Join (cost=1.57..7.52 rows=2 width=27) (actual time=0.046..0.059 rows=1 loops=52,350)

  • Hash Cond: (cambio_situacion_empresa.situacion_act = situacion_emp.id_situacion)
32. 2,565.150 2,565.150 ↑ 2.0 1 52,350

Index Scan using cambio_situacion_empresa_nro_patronal_fecha_creacion_id_cam_idx on cambio_situacion_empresa (cost=0.42..6.33 rows=2 width=20) (actual time=0.041..0.049 rows=1 loops=52,350)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
33. 0.013 0.026 ↑ 1.0 7 1

Hash (cost=1.07..1.07 rows=7 width=15) (actual time=0.026..0.026 rows=7 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
34. 0.013 0.013 ↑ 1.0 7 1

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

35. 65.276 1,776.492 ↓ 9.0 6,613 1

Sort (cost=10,499.32..10,501.16 rows=734 width=463) (actual time=1,766.071..1,776.492 rows=6,613 loops=1)

  • Sort Key: empresas_sucursales_1.nro_patronal
  • Sort Method: quicksort Memory: 4555kB
36. 102.526 1,711.216 ↓ 9.0 6,613 1

Nested Loop Left Join (cost=14.41..10,464.39 rows=734 width=463) (actual time=0.813..1,711.216 rows=6,613 loops=1)

37. 81.221 1,106.102 ↓ 9.0 6,613 1

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

38. 57.200 925.686 ↓ 9.0 6,613 1

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

39. 28.855 742.839 ↓ 9.0 6,613 1

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

  • Hash Cond: (empresas_sucursales_1.distrito_id = distritos_1.id)
40. 31.053 713.940 ↓ 9.0 6,613 1

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

  • Hash Cond: (empresas_sucursales_1.city_id = city_1.id)
41. 51.056 682.360 ↓ 9.0 6,613 1

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

42. 83.750 598.239 ↓ 9.0 6,613 1

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

43. 55.591 388.842 ↓ 9.0 6,613 1

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

44. 120.387 120.387 ↓ 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..120.387 rows=6,652 loops=1)

  • Filter: ((type <> 1) AND (type <> 1))
  • Rows Removed by Filter: 52352
45. 212.864 212.864 ↑ 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.029..0.032 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
46. 125.647 125.647 ↑ 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.015..0.019 rows=1 loops=6,613)

  • Index Cond: (emp_1.type = id)
47. 33.065 33.065 ↓ 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.004..0.005 rows=0 loops=6,613)

  • Index Cond: (emp_1.id_categoria_empresa = id_categoria_empresa)
48. 0.256 0.527 ↑ 1.0 254 1

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

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

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

50. 0.023 0.044 ↑ 1.0 18 1

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

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

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

52. 125.647 125.647 ↑ 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.016..0.019 rows=1 loops=6,613)

  • Index Cond: (empresas_sucursales_1.id_activ_econ = id_activ_econ)
53. 99.195 99.195 ↑ 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.012..0.015 rows=1 loops=6,613)

  • Index Cond: (empresas_sucursales_1.type = id)
54. 85.969 85.969 ↑ 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.010..0.013 rows=1 loops=6,613)

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

SubPlan (forNested Loop Left Join)

56. 39.678 416.619 ↑ 1.0 1 6,613

Limit (cost=7.53..7.53 rows=1 width=27) (actual time=0.061..0.063 rows=1 loops=6,613)

57. 132.260 376.941 ↑ 2.0 1 6,613

Sort (cost=7.53..7.53 rows=2 width=27) (actual time=0.057..0.057 rows=1 loops=6,613)

  • Sort Key: cambio_situacion_empresa_1.fecha_creacion, cambio_situacion_empresa_1.id_cambio_situacion_empresa
  • Sort Method: quicksort Memory: 25kB
58. 59.497 244.681 ↑ 2.0 1 6,613

Hash Join (cost=1.57..7.52 rows=2 width=27) (actual time=0.028..0.037 rows=1 loops=6,613)

  • Hash Cond: (cambio_situacion_empresa_1.situacion_act = situacion_emp_1.id_situacion)
59. 185.164 185.164 ↑ 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.33 rows=2 width=20) (actual time=0.024..0.028 rows=1 loops=6,613)

  • Index Cond: (nro_patronal = empresas_sucursales_1.nro_patronal)
60. 0.012 0.020 ↑ 1.0 7 1

Hash (cost=1.07..1.07 rows=7 width=15) (actual time=0.020..0.020 rows=7 loops=1)

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

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