explain.depesz.com

PostgreSQL's explain analyze made readable

Result: nkMn

Settings
# exclusive inclusive rows x rows loops node
1. 555.108 99,837.453 ↓ 1.0 50,019 1

Hash Left Join (cost=3,088.70..207,509,276.82 rows=50,001 width=964) (actual time=176.657..99,837.453 rows=50,019 loops=1)

  • Hash Cond: (empresas_sucursales.type = empresas_sucursales_types.id)
2. 100.748 879.392 ↓ 1.0 50,019 1

Hash Left Join (cost=3,087.65..9,559.77 rows=50,001 width=940) (actual time=160.628..879.392 rows=50,019 loops=1)

  • Hash Cond: (empresas_sucursales.id_activ_econ = actividad_econ.id_activ_econ)
3. 89.209 777.028 ↓ 1.0 50,019 1

Hash Left Join (cost=3,062.90..8,847.53 rows=50,001 width=886) (actual time=158.971..777.028 rows=50,019 loops=1)

  • Hash Cond: (empresas_sucursales.distrito_id = distritos.id)
4. 93.761 687.773 ↓ 1.0 50,019 1

Hash Left Join (cost=3,061.43..8,158.96 rows=50,001 width=876) (actual time=158.891..687.773 rows=50,019 loops=1)

  • Hash Cond: (empresas_sucursales.city_id = city.id)
5. 77.845 593.367 ↓ 1.0 50,019 1

Hash Left Join (cost=3,048.78..7,461.27 rows=50,001 width=840) (actual time=158.209..593.367 rows=50,019 loops=1)

  • Hash Cond: (emp.id_categoria_empresa = empresas_categorias.id_categoria_empresa)
6. 85.998 515.492 ↓ 1.0 50,019 1

Hash Left Join (cost=3,035.63..7,255.72 rows=50,001 width=324) (actual time=158.151..515.492 rows=50,019 loops=1)

  • Hash Cond: (emp.type = empresas_types.id)
7. 188.804 429.425 ↓ 1.0 50,019 1

Hash Join (cost=3,034.04..6,647.27 rows=50,001 width=311) (actual time=158.032..429.425 rows=50,019 loops=1)

  • Hash Cond: (empresas_sucursales.empresa_id = emp.id)
8. 82.662 82.662 ↓ 1.0 50,021 1

Seq Scan on empresas_sucursales (cost=0.00..2,613.18 rows=50,004 width=237) (actual time=0.030..82.662 rows=50,021 loops=1)

  • Filter: (type = 1)
  • Rows Removed by Filter: 5628
9. 70.873 157.959 ↓ 1.0 49,881 1

Hash (cost=2,411.13..2,411.13 rows=49,833 width=82) (actual time=157.959..157.959 rows=49,881 loops=1)

  • Buckets: 8192 Batches: 1 Memory Usage: 5575kB
10. 87.086 87.086 ↓ 1.0 49,881 1

Seq Scan on empresas emp (cost=0.00..2,411.13 rows=49,833 width=82) (actual time=0.023..87.086 rows=49,881 loops=1)

  • Filter: (((document)::text <> '0'::text) AND ((document)::text <> ''::text) AND ((document)::text <> '-'::text))
  • Rows Removed by Filter: 2
11. 0.033 0.069 ↓ 1.2 30 1

Hash (cost=1.26..1.26 rows=26 width=21) (actual time=0.069..0.069 rows=30 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 2kB
12. 0.036 0.036 ↓ 1.2 30 1

Seq Scan on empresas_types (cost=0.00..1.26 rows=26 width=21) (actual time=0.010..0.036 rows=30 loops=1)

13. 0.006 0.030 ↑ 35.0 4 1

Hash (cost=11.40..11.40 rows=140 width=520) (actual time=0.030..0.030 rows=4 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
14. 0.024 0.024 ↑ 35.0 4 1

Seq Scan on empresas_categorias (cost=0.00..11.40 rows=140 width=520) (actual time=0.020..0.024 rows=4 loops=1)

15. 0.328 0.645 ↑ 1.0 251 1

Hash (cost=9.51..9.51 rows=251 width=40) (actual time=0.645..0.645 rows=251 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 19kB
16. 0.317 0.317 ↑ 1.0 251 1

Seq Scan on city (cost=0.00..9.51 rows=251 width=40) (actual time=0.010..0.317 rows=251 loops=1)

17. 0.018 0.046 ↑ 1.2 18 1

Hash (cost=1.21..1.21 rows=21 width=18) (actual time=0.046..0.046 rows=18 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
18. 0.028 0.028 ↑ 1.2 18 1

Seq Scan on distritos (cost=0.00..1.21 rows=21 width=18) (actual time=0.011..0.028 rows=18 loops=1)

19. 0.879 1.616 ↓ 1.0 701 1

Hash (cost=16.00..16.00 rows=700 width=58) (actual time=1.616..1.616 rows=701 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 64kB
20. 0.737 0.737 ↓ 1.0 701 1

Seq Scan on actividad_econ (cost=0.00..16.00 rows=700 width=58) (actual time=0.007..0.737 rows=701 loops=1)

21. 0.009 15.580 ↑ 1.0 1 1

Hash (cost=1.04..1.04 rows=1 width=40) (actual time=15.580..15.580 rows=1 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
22. 15.571 15.571 ↑ 1.0 1 1

Seq Scan on empresas_sucursales_types (cost=0.00..1.04 rows=1 width=40) (actual time=15.569..15.571 rows=1 loops=1)

  • Filter: (id = 1)
  • Rows Removed by Filter: 2
23.          

SubPlan (forHash Left Join)

24. 550.209 25,959.861 ↑ 1.0 1 50,019

Aggregate (cost=941.67..941.68 rows=1 width=8) (actual time=0.518..0.519 rows=1 loops=50,019)

25. 900.342 25,409.652 ↑ 5.8 10 50,019

Nested Loop (cost=0.72..941.52 rows=58 width=8) (actual time=0.057..0.508 rows=10 loops=50,019)

26. 250.095 250.095 ↑ 1.0 1 50,019

Index Only Scan using empresas_sucursales_nro_patronal_key on empresas_sucursales es (cost=0.29..2.31 rows=1 width=4) (actual time=0.004..0.005 rows=1 loops=50,019)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 659
27. 4,370.223 24,259.215 ↑ 5.8 10 50,019

Index Scan using empleados_npatronal_id_idx on empleados (cost=0.43..938.64 rows=58 width=24) (actual time=0.049..0.485 rows=10 loops=50,019)

  • Index Cond: (npatronal = empresas_sucursales.nro_patronal)
  • Filter: (SubPlan 1)
  • Rows Removed by Filter: 12
28.          

SubPlan (forIndex Scan)

29. 2,209.888 19,888.992 ↑ 1.0 1 1,104,944

Limit (cost=6.06..6.06 rows=1 width=20) (actual time=0.018..0.018 rows=1 loops=1,104,944)

30. 4,419.776 17,679.104 ↑ 2.0 1 1,104,944

Sort (cost=6.06..6.06 rows=2 width=20) (actual time=0.016..0.016 rows=1 loops=1,104,944)

  • Sort Key: empleados_movimientos.fecha, empleados_movimientos.id
  • Sort Method: quicksort Memory: 25kB
31. 5,526.554 13,259.328 ↑ 1.0 2 1,104,944

Result (cost=0.00..6.05 rows=2 width=20) (actual time=0.007..0.012 rows=2 loops=1,104,944)

  • One-Time Filter: (empleados.empresa_id = emp.id)
32. 7,732.774 7,732.774 ↑ 1.0 2 1,104,682

Index Scan using empleados_movimientos_empleado_id_idx on empleados_movimientos (cost=0.00..6.04 rows=2 width=20) (actual time=0.005..0.007 rows=2 loops=1,104,682)

  • Index Cond: (empleado_id = empleados.id)
  • Rows Removed by Index Recheck: 0
33. 700.266 20,207.676 ↑ 1.0 1 50,019

Aggregate (cost=852.59..852.62 rows=1 width=16) (actual time=0.403..0.404 rows=1 loops=50,019)

34. 3,208.338 19,507.410 ↑ 5.8 12 50,019

Index Only Scan using empleados_empresa_id_id_idx on empleados emplea (cost=0.43..851.19 rows=70 width=16) (actual time=0.033..0.390 rows=12 loops=50,019)

  • Index Cond: (empresa_id = emp.id)
  • Filter: (SubPlan 3)
  • Rows Removed by Filter: 15
  • Heap Fetches: 138137
35.          

SubPlan (forIndex Only Scan)

36. 2,716.512 16,299.072 ↑ 1.0 1 1,358,256

Limit (cost=6.05..6.06 rows=1 width=20) (actual time=0.012..0.012 rows=1 loops=1,358,256)

37. 6,791.280 13,582.560 ↑ 2.0 1 1,358,256

Sort (cost=6.05..6.06 rows=2 width=20) (actual time=0.010..0.010 rows=1 loops=1,358,256)

  • Sort Key: empleados_movimientos_1.fecha, empleados_movimientos_1.id
  • Sort Method: quicksort Memory: 25kB
38. 6,791.280 6,791.280 ↑ 1.0 2 1,358,256

Index Scan using empleados_movimientos_empleado_id_idx on empleados_movimientos empleados_movimientos_1 (cost=0.00..6.04 rows=2 width=20) (actual time=0.003..0.005 rows=2 loops=1,358,256)

  • Index Cond: (empleado_id = emplea.id)
  • Rows Removed by Index Recheck: 0
39. 400.152 26,460.051 ↑ 1.0 1 50,019

Aggregate (cost=1,175.30..1,175.31 rows=1 width=8) (actual time=0.528..0.529 rows=1 loops=50,019)

40. 650.247 26,059.899 ↑ 6.3 6 50,019

Nested Loop (cost=0.72..1,175.21 rows=38 width=8) (actual time=0.063..0.521 rows=6 loops=50,019)

41. 150.057 150.057 ↑ 1.0 1 50,019

Index Only Scan using empresas_sucursales_nro_patronal_key on empresas_sucursales es_1 (cost=0.29..2.31 rows=1 width=4) (actual time=0.002..0.003 rows=1 loops=50,019)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 659
42. 1,494.287 25,259.595 ↑ 6.3 6 50,019

Nested Loop (cost=0.43..1,172.52 rows=38 width=16) (actual time=0.057..0.505 rows=6 loops=50,019)

43. 2,628.610 20,307.714 ↑ 5.8 10 50,019

Index Scan using empleados_npatronal_id_idx on empleados empleados_1 (cost=0.43..938.64 rows=58 width=24) (actual time=0.036..0.406 rows=10 loops=50,019)

  • Index Cond: (npatronal = empresas_sucursales.nro_patronal)
  • Filter: (SubPlan 5)
  • Rows Removed by Filter: 12
44.          

SubPlan (forIndex Scan)

45. 2,209.888 17,679.104 ↑ 1.0 1 1,104,944

Limit (cost=6.06..6.06 rows=1 width=20) (actual time=0.015..0.016 rows=1 loops=1,104,944)

46. 5,524.720 15,469.216 ↑ 2.0 1 1,104,944

Sort (cost=6.06..6.06 rows=2 width=20) (actual time=0.014..0.014 rows=1 loops=1,104,944)

  • Sort Key: empleados_movimientos_2.fecha, empleados_movimientos_2.id
  • Sort Method: quicksort Memory: 25kB
47. 5,525.768 9,944.496 ↑ 1.0 2 1,104,944

Result (cost=0.00..6.05 rows=2 width=20) (actual time=0.005..0.009 rows=2 loops=1,104,944)

  • One-Time Filter: (empleados_1.empresa_id = emp.id)
48. 4,418.728 4,418.728 ↑ 1.0 2 1,104,682

Index Scan using empleados_movimientos_empleado_id_idx on empleados_movimientos empleados_movimientos_2 (cost=0.00..6.04 rows=2 width=20) (actual time=0.003..0.004 rows=2 loops=1,104,682)

  • Index Cond: (empleado_id = empleados_1.id)
  • Rows Removed by Index Recheck: 0
49. 3,457.594 3,457.594 ↑ 1.0 1 493,942

Index Scan using persons_id_idx on persons (cost=0.00..4.02 rows=1 width=8) (actual time=0.006..0.007 rows=1 loops=493,942)

  • Index Cond: (id = empleados_1.persona_id)
  • Rows Removed by Index Recheck: 0
  • Filter: ((sexo)::text = 'M'::text)
  • Rows Removed by Filter: 0
50. 300.114 24,009.120 ↑ 1.0 1 50,019

Aggregate (cost=1,175.08..1,175.09 rows=1 width=8) (actual time=0.479..0.480 rows=1 loops=50,019)

51. 400.152 23,709.006 ↑ 6.7 3 50,019

Nested Loop (cost=0.72..1,175.03 rows=20 width=8) (actual time=0.095..0.474 rows=3 loops=50,019)

52. 150.057 150.057 ↑ 1.0 1 50,019

Index Only Scan using empresas_sucursales_nro_patronal_key on empresas_sucursales es_2 (cost=0.29..2.31 rows=1 width=4) (actual time=0.002..0.003 rows=1 loops=50,019)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 659
53. 1,519.314 23,158.797 ↑ 6.7 3 50,019

Nested Loop (cost=0.43..1,172.52 rows=20 width=16) (actual time=0.089..0.463 rows=3 loops=50,019)

54. 2,478.553 20,157.657 ↑ 5.8 10 50,019

Index Scan using empleados_npatronal_id_idx on empleados empleados_2 (cost=0.43..938.64 rows=58 width=24) (actual time=0.036..0.403 rows=10 loops=50,019)

  • Index Cond: (npatronal = empresas_sucursales.nro_patronal)
  • Filter: (SubPlan 7)
  • Rows Removed by Filter: 12
55.          

SubPlan (forIndex Scan)

56. 2,209.888 17,679.104 ↑ 1.0 1 1,104,944

Limit (cost=6.06..6.06 rows=1 width=20) (actual time=0.015..0.016 rows=1 loops=1,104,944)

57. 5,524.720 15,469.216 ↑ 2.0 1 1,104,944

Sort (cost=6.06..6.06 rows=2 width=20) (actual time=0.014..0.014 rows=1 loops=1,104,944)

  • Sort Key: empleados_movimientos_3.fecha, empleados_movimientos_3.id
  • Sort Method: quicksort Memory: 25kB
58. 5,525.768 9,944.496 ↑ 1.0 2 1,104,944

Result (cost=0.00..6.05 rows=2 width=20) (actual time=0.005..0.009 rows=2 loops=1,104,944)

  • One-Time Filter: (empleados_2.empresa_id = emp.id)
59. 4,418.728 4,418.728 ↑ 1.0 2 1,104,682

Index Scan using empleados_movimientos_empleado_id_idx on empleados_movimientos empleados_movimientos_3 (cost=0.00..6.04 rows=2 width=20) (actual time=0.003..0.004 rows=2 loops=1,104,682)

  • Index Cond: (empleado_id = empleados_2.id)
  • Rows Removed by Index Recheck: 0
60. 1,481.826 1,481.826 ↓ 0.0 0 493,942

Index Scan using persons_id_idx on persons persons_1 (cost=0.00..4.02 rows=1 width=8) (actual time=0.003..0.003 rows=0 loops=493,942)

  • Index Cond: (id = empleados_2.persona_id)
  • Rows Removed by Index Recheck: 0
  • Filter: ((sexo)::text = 'F'::text)
  • Rows Removed by Filter: 1
61. 100.038 1,750.665 ↑ 1.0 1 50,019

Limit (cost=5.19..5.19 rows=1 width=134) (actual time=0.034..0.035 rows=1 loops=50,019)

62. 250.095 1,650.627 ↑ 1.0 1 50,019

Sort (cost=5.19..5.19 rows=1 width=134) (actual time=0.033..0.033 rows=1 loops=50,019)

  • Sort Key: cambio_situacion_empresa.fecha_creacion, cambio_situacion_empresa.id_cambio_situacion_empresa
  • Sort Method: quicksort Memory: 25kB
63. 566.404 1,400.532 ↑ 1.0 1 50,019

Nested Loop (cost=0.00..5.18 rows=1 width=134) (actual time=0.017..0.028 rows=1 loops=50,019)

  • Join Filter: (cambio_situacion_empresa.situacion_act = situacion_emp.id_situacion)
  • Rows Removed by Join Filter: 7
64. 450.171 450.171 ↑ 1.0 1 50,019

Index Scan using cambio_situacion_empresa_nro_patronal_idx on cambio_situacion_empresa (cost=0.00..4.02 rows=1 width=20) (actual time=0.007..0.009 rows=1 loops=50,019)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
65. 383.957 383.957 ↑ 1.0 7 54,851

Seq Scan on situacion_emp (cost=0.00..1.07 rows=7 width=122) (actual time=0.002..0.007 rows=7 loops=54,851)