explain.depesz.com

PostgreSQL's explain analyze made readable

Result: a1iL

Settings
# exclusive inclusive rows x rows loops node
1. 1,286.135 102,229.276 ↓ 1.0 50,019 1

Sort (cost=207,528,316.81..207,528,441.82 rows=50,001 width=964) (actual time=102,170.259..102,229.276 rows=50,019 loops=1)

  • Sort Key: empresas_sucursales.nro_patronal
  • Sort Method: external merge Disk: 19936kB
2. 626.344 100,943.141 ↓ 1.0 50,019 1

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

  • Hash Cond: (empresas_sucursales.type = empresas_sucursales_types.id)
3. 99.089 1,029.062 ↓ 1.0 50,019 1

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

  • Hash Cond: (empresas_sucursales.id_activ_econ = actividad_econ.id_activ_econ)
4. 87.984 928.179 ↓ 1.0 50,019 1

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

  • Hash Cond: (empresas_sucursales.distrito_id = distritos.id)
5. 91.983 840.150 ↓ 1.0 50,019 1

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

  • Hash Cond: (empresas_sucursales.city_id = city.id)
6. 78.499 747.468 ↓ 1.0 50,019 1

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

  • Hash Cond: (emp.id_categoria_empresa = empresas_categorias.id_categoria_empresa)
7. 89.318 668.942 ↓ 1.0 50,019 1

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

  • Hash Cond: (emp.type = empresas_types.id)
8. 157.848 579.553 ↓ 1.0 50,019 1

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

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

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

  • Filter: (type = 1)
  • Rows Removed by Filter: 5628
10. 77.652 336.987 ↓ 1.0 49,881 1

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

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

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

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

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

  • Buckets: 1024 Batches: 1 Memory Usage: 2kB
13. 0.038 0.038 ↓ 1.2 30 1

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

14. 0.006 0.027 ↑ 35.0 4 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
15. 0.021 0.021 ↑ 35.0 4 1

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

16. 0.334 0.699 ↑ 1.0 251 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 19kB
17. 0.365 0.365 ↑ 1.0 251 1

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

18. 0.019 0.045 ↑ 1.2 18 1

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

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

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

20. 0.930 1.794 ↓ 1.0 701 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 64kB
21. 0.864 0.864 ↓ 1.0 701 1

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

22. 0.002 0.020 ↑ 1.0 1 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
23. 0.018 0.018 ↑ 1.0 1 1

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

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

SubPlan (forHash Left Join)

25. 550.209 26,309.994 ↑ 1.0 1 50,019

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

26. 900.342 25,759.785 ↑ 5.8 10 50,019

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

27. 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
28. 3,615.412 24,609.348 ↑ 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.051..0.492 rows=10 loops=50,019)

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

SubPlan (forIndex Scan)

30. 2,209.888 20,993.936 ↑ 1.0 1 1,104,944

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

31. 5,524.720 18,784.048 ↑ 2.0 1 1,104,944

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

  • Sort Key: empleados_movimientos.fecha, empleados_movimientos.id
  • Sort Method: quicksort Memory: 25kB
32. 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)
33. 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
34. 700.266 20,307.714 ↑ 1.0 1 50,019

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

35. 3,308.376 19,607.448 ↑ 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.392 rows=12 loops=50,019)

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

SubPlan (forIndex Only Scan)

37. 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)

38. 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
39. 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
40. 400.152 26,710.146 ↑ 1.0 1 50,019

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

41. 650.247 26,309.994 ↑ 6.3 6 50,019

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

42. 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
43. 1,594.318 25,509.690 ↑ 6.3 6 50,019

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

44. 2,778.667 20,457.771 ↑ 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.409 rows=10 loops=50,019)

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

SubPlan (forIndex Scan)

46. 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.016..0.016 rows=1 loops=1,104,944)

47. 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
48. 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)
49. 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
50. 3,457.601 3,457.601 ↑ 1.0 1 493,943

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,943)

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

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

52. 450.171 23,959.101 ↑ 6.7 3 50,019

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

53. 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
54. 1,519.311 23,358.873 ↑ 6.7 3 50,019

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

55. 2,678.629 20,357.733 ↑ 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.407 rows=10 loops=50,019)

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

SubPlan (forIndex Scan)

57. 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.016..0.016 rows=1 loops=1,104,944)

58. 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
59. 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)
60. 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
61. 1,481.829 1,481.829 ↓ 0.0 0 493,943

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,943)

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

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

63. 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
64. 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
65. 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)
66. 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)