explain.depesz.com

PostgreSQL's explain analyze made readable

Result: u2eE : Optimization for: Optimization for: Optimization for: Optimization for: Optimization for: Optimization for: Optimization for: Optimization for: plan #naM; plan #ZDSY; plan #yxz4; plan #W61u; plan #0ySG; plan #rZc; plan #Y9iQ; plan #H8QE

Settings

Optimization path:

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 119.795 252,644.465 ↓ 1.1 55,554 1

Unique (cost=313,317,222.26..313,320,885.17 rows=50,523 width=964) (actual time=252,434.763..252,644.465 rows=55,554 loops=1)

2. 433.734 252,524.670 ↓ 1.1 55,554 1

Sort (cost=313,317,222.26..313,317,348.56 rows=50,523 width=964) (actual time=252,434.759..252,524.670 rows=55,554 loops=1)

  • Sort Key: emp.document, emp.legal, emp.fantasy, empresas_sucursales.nro_patronal_ips, empresas_categorias.descripcion, empresas_sucursales.direccion, empresas_sucursales.fecha_inscrip, empresas_sucursales.activ_principal, empresas_sucursales.tel, empresas_sucursales.email, city.name, distritos.name, ((SubPlan 11)), ((SubPlan 13)), ((SubPlan 15)), ((SubPlan 17)), ((SubPlan 18)), empresas_types.name, actividad_econ.descripcion, empresas_sucursales_types.name, empresas_sucursales.nro_patronal, empresas_sucursales.id_activ_econ, empresas_sucursales.city_id, empresas_sucursales.distrito_id, empresas_sucursales.geolocation, empresas_sucursales.id_tipo_inscripcion, emp.type, emp.id_categoria_empresa
  • Sort Method: external merge Disk: 22424kB
3. 86.309 252,090.936 ↓ 1.1 55,554 1

Append (cost=309,742,213.40..313,294,918.23 rows=50,523 width=964) (actual time=120,355.281..252,090.936 rows=55,554 loops=1)

4. 2,408.605 120,419.247 ↓ 1.0 49,972 1

Sort (cost=309,742,213.40..309,742,338.28 rows=49,951 width=964) (actual time=120,355.278..120,419.247 rows=49,972 loops=1)

  • Sort Key: empresas_sucursales.nro_patronal
  • Sort Method: external merge Disk: 19912kB
5. 667.121 118,010.642 ↓ 1.0 49,972 1

Hash Left Join (cost=3,088.37..309,720,168.17 rows=49,951 width=964) (actual time=112.639..118,010.642 rows=49,972 loops=1)

  • Hash Cond: (empresas_sucursales.type = empresas_sucursales_types.id)
6. 110.368 908.745 ↓ 1.0 49,972 1

Hash Left Join (cost=3,087.32..9,555.32 rows=49,951 width=940) (actual time=112.357..908.745 rows=49,972 loops=1)

  • Hash Cond: (empresas_sucursales.id_activ_econ = actividad_econ.id_activ_econ)
7. 101.920 797.059 ↓ 1.0 49,972 1

Hash Left Join (cost=3,062.57..8,843.76 rows=49,951 width=886) (actual time=111.014..797.059 rows=49,972 loops=1)

  • Hash Cond: (empresas_sucursales.distrito_id = distritos.id)
8. 104.369 695.099 ↓ 1.0 49,972 1

Hash Left Join (cost=3,061.10..8,155.85 rows=49,951 width=876) (actual time=110.958..695.099 rows=49,972 loops=1)

  • Hash Cond: (empresas_sucursales.city_id = city.id)
9. 88.184 590.287 ↓ 1.0 49,972 1

Hash Left Join (cost=3,048.45..7,458.88 rows=49,951 width=840) (actual time=110.491..590.287 rows=49,972 loops=1)

  • Hash Cond: (emp.id_categoria_empresa = empresas_categorias.id_categoria_empresa)
10. 97.869 502.085 ↓ 1.0 49,972 1

Hash Left Join (cost=3,035.30..7,253.52 rows=49,951 width=324) (actual time=110.463..502.085 rows=49,972 loops=1)

  • Hash Cond: (emp.type = empresas_types.id)
11. 200.700 404.150 ↓ 1.0 49,972 1

Hash Join (cost=3,033.71..6,645.68 rows=49,951 width=311) (actual time=110.378..404.150 rows=49,972 loops=1)

  • Hash Cond: (empresas_sucursales.empresa_id = emp.id)
12. 93.111 93.111 ↓ 1.0 49,974 1

Seq Scan on empresas_sucursales (cost=0.00..2,612.91 rows=49,954 width=237) (actual time=0.016..93.111 rows=49,974 loops=1)

  • Filter: (type = 1)
  • Rows Removed by Filter: 5621
13. 49.097 110.339 ↓ 1.0 49,833 1

Hash (cost=2,410.94..2,410.94 rows=49,822 width=82) (actual time=110.339..110.339 rows=49,833 loops=1)

  • Buckets: 8192 Batches: 1 Memory Usage: 5570kB
14. 61.242 61.242 ↓ 1.0 49,833 1

Seq Scan on empresas emp (cost=0.00..2,410.94 rows=49,822 width=82) (actual time=0.010..61.242 rows=49,833 loops=1)

  • Filter: (((document)::text <> '0'::text) AND ((document)::text <> ''::text) AND ((document)::text <> '-'::text))
  • Rows Removed by Filter: 2
15. 0.029 0.066 ↓ 1.2 30 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 2kB
16. 0.037 0.037 ↓ 1.2 30 1

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

17. 0.005 0.018 ↑ 35.0 4 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
18. 0.013 0.013 ↑ 35.0 4 1

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

19. 0.213 0.443 ↑ 1.0 251 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 19kB
20. 0.230 0.230 ↑ 1.0 251 1

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

21. 0.022 0.040 ↑ 1.2 18 1

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

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

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

23. 0.666 1.318 ↑ 1.0 700 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 63kB
24. 0.652 0.652 ↑ 1.0 700 1

Seq Scan on actividad_econ (cost=0.00..16.00 rows=700 width=58) (actual time=0.003..0.652 rows=700 loops=1)

25. 0.003 0.016 ↑ 1.0 1 1

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

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

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

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

SubPlan (forHash Left Join)

28. 599.664 31,282.472 ↑ 1.0 1 49,972

Aggregate (cost=1,407.13..1,407.14 rows=1 width=8) (actual time=0.625..0.626 rows=1 loops=49,972)

29. 999.440 30,682.808 ↑ 5.8 10 49,972

Nested Loop (cost=0.72..1,406.98 rows=58 width=8) (actual time=0.069..0.614 rows=10 loops=49,972)

30. 299.832 299.832 ↑ 1.0 1 49,972

Index Only Scan using empresas_sucursales_nro_patronal_key on empresas_sucursales es_3 (cost=0.29..3.31 rows=1 width=4) (actual time=0.005..0.006 rows=1 loops=49,972)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 34
31. 5,104.226 29,383.536 ↑ 5.8 10 49,972

Index Scan using empleados_npatronal_id_idx on empleados empleados_3 (cost=0.43..1,403.10 rows=58 width=24) (actual time=0.061..0.588 rows=10 loops=49,972)

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

SubPlan (forIndex Scan)

33. 2,207.210 24,279.310 ↑ 1.0 1 1,103,605

Limit (cost=9.06..9.06 rows=1 width=20) (actual time=0.022..0.022 rows=1 loops=1,103,605)

34. 5,518.025 22,072.100 ↑ 2.0 1 1,103,605

Sort (cost=9.06..9.06 rows=2 width=20) (actual time=0.020..0.020 rows=1 loops=1,103,605)

  • Sort Key: empleados_movimientos_4.fecha, empleados_movimientos_4.id
  • Sort Method: quicksort Memory: 25kB
35. 5,520.645 16,554.075 ↑ 1.0 2 1,103,605

Result (cost=0.00..9.05 rows=2 width=20) (actual time=0.009..0.015 rows=2 loops=1,103,605)

  • One-Time Filter: (empleados_3.empresa_id = emp.id)
36. 11,033.430 11,033.430 ↑ 1.0 2 1,103,343

Index Scan using empleados_movimientos_empleado_id_idx on empleados_movimientos empleados_movimientos_4 (cost=0.00..9.04 rows=2 width=20) (actual time=0.007..0.010 rows=2 loops=1,103,343)

  • Index Cond: (empleado_id = empleados_3.id)
  • Rows Removed by Index Recheck: 0
37. 799.552 24,236.420 ↑ 1.0 1 49,972

Aggregate (cost=1,272.59..1,272.62 rows=1 width=16) (actual time=0.484..0.485 rows=1 loops=49,972)

38. 3,089.458 23,436.868 ↑ 5.8 12 49,972

Index Only Scan using empleados_empresa_id_id_idx on empleados emplea_1 (cost=0.43..1,271.19 rows=70 width=16) (actual time=0.039..0.469 rows=12 loops=49,972)

  • Index Cond: (empresa_id = emp.id)
  • Filter: (SubPlan 12)
  • Rows Removed by Filter: 15
  • Heap Fetches: 26038
39.          

SubPlan (forIndex Only Scan)

40. 4,069.482 20,347.410 ↑ 1.0 1 1,356,494

Limit (cost=9.05..9.06 rows=1 width=20) (actual time=0.014..0.015 rows=1 loops=1,356,494)

41. 6,782.470 16,277.928 ↑ 2.0 1 1,356,494

Sort (cost=9.05..9.06 rows=2 width=20) (actual time=0.012..0.012 rows=1 loops=1,356,494)

  • Sort Key: empleados_movimientos_5.fecha, empleados_movimientos_5.id
  • Sort Method: quicksort Memory: 25kB
42. 9,495.458 9,495.458 ↑ 1.0 2 1,356,494

Index Scan using empleados_movimientos_empleado_id_idx on empleados_movimientos empleados_movimientos_5 (cost=0.00..9.04 rows=2 width=20) (actual time=0.005..0.007 rows=2 loops=1,356,494)

  • Index Cond: (empleado_id = emplea_1.id)
  • Rows Removed by Index Recheck: 0
43. 449.748 30,333.004 ↑ 1.0 1 49,972

Aggregate (cost=1,756.76..1,756.77 rows=1 width=8) (actual time=0.606..0.607 rows=1 loops=49,972)

44. 699.608 29,883.256 ↑ 6.3 6 49,972

Nested Loop (cost=0.72..1,756.67 rows=38 width=8) (actual time=0.071..0.598 rows=6 loops=49,972)

45. 199.888 199.888 ↑ 1.0 1 49,972

Index Only Scan using empresas_sucursales_nro_patronal_key on empresas_sucursales es_4 (cost=0.29..3.31 rows=1 width=4) (actual time=0.003..0.004 rows=1 loops=49,972)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 34
46. 1,787.226 28,983.760 ↑ 6.3 6 49,972

Nested Loop (cost=0.43..1,752.98 rows=38 width=16) (actual time=0.064..0.580 rows=6 loops=49,972)

47. 2,768.205 23,736.700 ↑ 5.8 10 49,972

Index Scan using empleados_npatronal_id_idx on empleados empleados_4 (cost=0.43..1,403.10 rows=58 width=24) (actual time=0.041..0.475 rows=10 loops=49,972)

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

SubPlan (forIndex Scan)

49. 3,310.815 20,968.495 ↑ 1.0 1 1,103,605

Limit (cost=9.06..9.06 rows=1 width=20) (actual time=0.018..0.019 rows=1 loops=1,103,605)

50. 4,414.420 17,657.680 ↑ 2.0 1 1,103,605

Sort (cost=9.06..9.06 rows=2 width=20) (actual time=0.016..0.016 rows=1 loops=1,103,605)

  • Sort Key: empleados_movimientos_6.fecha, empleados_movimientos_6.id
  • Sort Method: quicksort Memory: 25kB
51. 6,623.202 13,243.260 ↑ 1.0 2 1,103,605

Result (cost=0.00..9.05 rows=2 width=20) (actual time=0.007..0.012 rows=2 loops=1,103,605)

  • One-Time Filter: (empleados_4.empresa_id = emp.id)
52. 6,620.058 6,620.058 ↑ 1.0 2 1,103,343

Index Scan using empleados_movimientos_empleado_id_idx on empleados_movimientos empleados_movimientos_6 (cost=0.00..9.04 rows=2 width=20) (actual time=0.004..0.006 rows=2 loops=1,103,343)

  • Index Cond: (empleado_id = empleados_4.id)
  • Rows Removed by Index Recheck: 0
53. 3,459.834 3,459.834 ↑ 1.0 1 494,262

Index Scan using persons_id_idx on persons persons_2 (cost=0.00..6.02 rows=1 width=8) (actual time=0.006..0.007 rows=1 loops=494,262)

  • Index Cond: (id = empleados_4.persona_id)
  • Rows Removed by Index Recheck: 0
  • Filter: ((sexo)::text = 'M'::text)
  • Rows Removed by Filter: 0
54. 299.832 28,583.984 ↑ 1.0 1 49,972

Aggregate (cost=1,756.54..1,756.55 rows=1 width=8) (actual time=0.572..0.572 rows=1 loops=49,972)

55. 449.748 28,284.152 ↑ 6.7 3 49,972

Nested Loop (cost=0.72..1,756.49 rows=20 width=8) (actual time=0.111..0.566 rows=3 loops=49,972)

56. 199.888 199.888 ↑ 1.0 1 49,972

Index Only Scan using empresas_sucursales_nro_patronal_key on empresas_sucursales es_5 (cost=0.29..3.31 rows=1 width=4) (actual time=0.003..0.004 rows=1 loops=49,972)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 34
57. 1,526.450 27,634.516 ↑ 6.7 3 49,972

Nested Loop (cost=0.43..1,752.98 rows=20 width=16) (actual time=0.104..0.553 rows=3 loops=49,972)

58. 2,668.261 23,636.756 ↑ 5.8 10 49,972

Index Scan using empleados_npatronal_id_idx on empleados empleados_5 (cost=0.43..1,403.10 rows=58 width=24) (actual time=0.041..0.473 rows=10 loops=49,972)

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

SubPlan (forIndex Scan)

60. 3,310.815 20,968.495 ↑ 1.0 1 1,103,605

Limit (cost=9.06..9.06 rows=1 width=20) (actual time=0.018..0.019 rows=1 loops=1,103,605)

61. 4,414.420 17,657.680 ↑ 2.0 1 1,103,605

Sort (cost=9.06..9.06 rows=2 width=20) (actual time=0.016..0.016 rows=1 loops=1,103,605)

  • Sort Key: empleados_movimientos_7.fecha, empleados_movimientos_7.id
  • Sort Method: quicksort Memory: 25kB
62. 6,623.202 13,243.260 ↑ 1.0 2 1,103,605

Result (cost=0.00..9.05 rows=2 width=20) (actual time=0.007..0.012 rows=2 loops=1,103,605)

  • One-Time Filter: (empleados_5.empresa_id = emp.id)
63. 6,620.058 6,620.058 ↑ 1.0 2 1,103,343

Index Scan using empleados_movimientos_empleado_id_idx on empleados_movimientos empleados_movimientos_7 (cost=0.00..9.04 rows=2 width=20) (actual time=0.004..0.006 rows=2 loops=1,103,343)

  • Index Cond: (empleado_id = empleados_5.id)
  • Rows Removed by Index Recheck: 0
64. 2,471.310 2,471.310 ↓ 0.0 0 494,262

Index Scan using persons_id_idx on persons persons_3 (cost=0.00..6.02 rows=1 width=8) (actual time=0.004..0.005 rows=0 loops=494,262)

  • Index Cond: (id = empleados_5.persona_id)
  • Rows Removed by Index Recheck: 0
  • Filter: ((sexo)::text = 'F'::text)
  • Rows Removed by Filter: 1
65. 149.916 1,998.880 ↑ 1.0 1 49,972

Limit (cost=7.19..7.19 rows=1 width=134) (actual time=0.039..0.040 rows=1 loops=49,972)

66. 199.888 1,848.964 ↑ 1.0 1 49,972

Sort (cost=7.19..7.19 rows=1 width=134) (actual time=0.037..0.037 rows=1 loops=49,972)

  • Sort Key: cambio_situacion_empresa_1.fecha_creacion, cambio_situacion_empresa_1.id_cambio_situacion_empresa
  • Sort Method: quicksort Memory: 25kB
67. 662.776 1,649.076 ↑ 1.0 1 49,972

Nested Loop (cost=0.00..7.18 rows=1 width=134) (actual time=0.020..0.033 rows=1 loops=49,972)

  • Join Filter: (cambio_situacion_empresa_1.situacion_act = situacion_emp_1.id_situacion)
  • Rows Removed by Join Filter: 7
68. 549.692 549.692 ↑ 1.0 1 49,972

Index Scan using cambio_situacion_empresa_nro_patronal_idx on cambio_situacion_empresa cambio_situacion_empresa_1 (cost=0.00..6.02 rows=1 width=20) (actual time=0.009..0.011 rows=1 loops=49,972)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
69. 436.608 436.608 ↑ 1.0 7 54,576

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

70. 29.665 131,585.380 ↓ 9.8 5,582 1

Sort (cost=3,552,073.29..3,552,074.72 rows=572 width=966) (actual time=131,580.724..131,585.380 rows=5,582 loops=1)

  • Sort Key: empresas_sucursales_1.nro_patronal
  • Sort Method: quicksort Memory: 3808kB
71. 110.190 131,555.715 ↓ 9.8 5,582 1

Nested Loop Left Join (cost=27.27..3,552,047.10 rows=572 width=966) (actual time=2.377..131,555.715 rows=5,582 loops=1)

  • Join Filter: (empresas_sucursales_1.type = empresas_sucursales_types_1.id)
  • Rows Removed by Join Filter: 11164
72. 28.372 352.255 ↓ 9.8 5,582 1

Nested Loop Left Join (cost=27.27..5,463.15 rows=572 width=942) (actual time=0.696..352.255 rows=5,582 loops=1)

73. 18.220 279.227 ↓ 9.8 5,582 1

Hash Left Join (cost=27.27..5,402.42 rows=572 width=888) (actual time=0.681..279.227 rows=5,582 loops=1)

  • Hash Cond: (empresas_sucursales_1.distrito_id = distritos_1.id)
74. 16.539 260.972 ↓ 9.8 5,582 1

Hash Left Join (cost=25.80..5,393.08 rows=572 width=878) (actual time=0.636..260.972 rows=5,582 loops=1)

  • Hash Cond: (empresas_sucursales_1.city_id = city_1.id)
75. 12.571 243.928 ↓ 9.8 5,582 1

Hash Left Join (cost=13.15..5,372.60 rows=572 width=842) (actual time=0.119..243.928 rows=5,582 loops=1)

  • Hash Cond: (emp_1.id_categoria_empresa = empresas_categorias_1.id_categoria_empresa)
76. 28.170 231.326 ↓ 9.8 5,582 1

Nested Loop Left Join (cost=0.00..5,357.25 rows=572 width=326) (actual time=0.075..231.326 rows=5,582 loops=1)

77. 33.670 164.082 ↓ 9.8 5,582 1

Nested Loop (cost=0.00..5,341.35 rows=572 width=313) (actual time=0.056..164.082 rows=5,582 loops=1)

78. 34.855 34.855 ↓ 9.8 5,621 1

Seq Scan on empresas_sucursales empresas_sucursales_1 (cost=0.00..2,751.89 rows=572 width=301) (actual time=0.025..34.855 rows=5,621 loops=1)

  • Filter: ((type <> 1) AND (type <> 1))
  • Rows Removed by Filter: 49974
79. 95.557 95.557 ↑ 1.0 1 5,621

Index Scan using empresas_id_idx on empresas emp_1 (cost=0.00..4.52 rows=1 width=20) (actual time=0.016..0.017 rows=1 loops=5,621)

  • 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
80. 39.074 39.074 ↑ 1.0 1 5,582

Index Scan using empresas_types_id_idx on empresas_types empresas_types_1 (cost=0.00..0.02 rows=1 width=21) (actual time=0.005..0.007 rows=1 loops=5,582)

  • Index Cond: (emp_1.type = id)
81. 0.006 0.031 ↑ 35.0 4 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
82. 0.025 0.025 ↑ 35.0 4 1

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

83. 0.213 0.505 ↑ 1.0 251 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 19kB
84. 0.292 0.292 ↑ 1.0 251 1

Seq Scan on city city_1 (cost=0.00..9.51 rows=251 width=40) (actual time=0.005..0.292 rows=251 loops=1)

85. 0.021 0.035 ↑ 1.2 18 1

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

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

Seq Scan on distritos distritos_1 (cost=0.00..1.21 rows=21 width=18) (actual time=0.005..0.014 rows=18 loops=1)

87. 44.656 44.656 ↑ 1.0 1 5,582

Index Scan using actividad_econ_id_activ_econ_idx on actividad_econ actividad_econ_1 (cost=0.00..0.10 rows=1 width=58) (actual time=0.006..0.008 rows=1 loops=5,582)

  • Index Cond: (empresas_sucursales_1.id_activ_econ = id_activ_econ)
88. 22.302 22.328 ↑ 1.0 3 5,582

Materialize (cost=0.00..1.04 rows=3 width=40) (actual time=0.001..0.004 rows=3 loops=5,582)

89. 0.026 0.026 ↑ 1.0 3 1

Seq Scan on empresas_sucursales_types empresas_sucursales_types_1 (cost=0.00..1.03 rows=3 width=40) (actual time=0.024..0.026 rows=3 loops=1)

90.          

SubPlan (forNested Loop Left Join)

91. 117.222 7,351.494 ↑ 1.0 1 5,582

Aggregate (cost=1,407.13..1,407.14 rows=1 width=8) (actual time=1.316..1.317 rows=1 loops=5,582)

92. 195.370 7,234.272 ↑ 3.2 18 5,582

Nested Loop (cost=0.72..1,406.98 rows=58 width=8) (actual time=0.210..1.296 rows=18 loops=5,582)

93. 39.074 39.074 ↑ 1.0 1 5,582

Index Only Scan using empresas_sucursales_nro_patronal_key on empresas_sucursales es (cost=0.29..3.31 rows=1 width=4) (actual time=0.006..0.007 rows=1 loops=5,582)

  • Index Cond: (nro_patronal = empresas_sucursales_1.nro_patronal)
  • Heap Fetches: 22
94. 1,863.996 6,999.828 ↑ 3.2 18 5,582

Index Scan using empleados_npatronal_id_idx on empleados (cost=0.43..1,403.10 rows=58 width=24) (actual time=0.199..1.254 rows=18 loops=5,582)

  • Index Cond: (npatronal = empresas_sucursales_1.nro_patronal)
  • Filter: (SubPlan 1)
  • Rows Removed by Filter: 20
95.          

SubPlan (forIndex Scan)

96. 427.986 5,135.832 ↑ 1.0 1 213,993

Limit (cost=9.06..9.06 rows=1 width=20) (actual time=0.024..0.024 rows=1 loops=213,993)

97. 1,069.965 4,707.846 ↑ 2.0 1 213,993

Sort (cost=9.06..9.06 rows=2 width=20) (actual time=0.022..0.022 rows=1 loops=213,993)

  • Sort Key: empleados_movimientos.fecha, empleados_movimientos.id
  • Sort Method: quicksort Memory: 25kB
98. 1,070.373 3,637.881 ↑ 1.0 2 213,993

Result (cost=0.00..9.05 rows=2 width=20) (actual time=0.009..0.017 rows=2 loops=213,993)

  • One-Time Filter: (empleados.empresa_id = emp_1.id)
99. 2,567.508 2,567.508 ↑ 1.0 2 213,959

Index Scan using empleados_movimientos_empleado_id_idx on empleados_movimientos (cost=0.00..9.04 rows=2 width=20) (actual time=0.006..0.012 rows=2 loops=213,959)

  • Index Cond: (empleado_id = empleados.id)
  • Rows Removed by Index Recheck: 0
100. 2,472.826 111,466.958 ↑ 1.0 1 5,582

Aggregate (cost=1,272.59..1,272.62 rows=1 width=16) (actual time=19.968..19.969 rows=1 loops=5,582)

101. 10,985.220 108,994.132 ↓ 6.8 475 5,582

Index Only Scan using empleados_empresa_id_id_idx on empleados emplea (cost=0.43..1,271.19 rows=70 width=16) (actual time=0.096..19.526 rows=475 loops=5,582)

  • Index Cond: (empresa_id = emp_1.id)
  • Filter: (SubPlan 3)
  • Rows Removed by Filter: 623
  • Heap Fetches: 144941
102.          

SubPlan (forIndex Only Scan)

103. 18,376.671 98,008.912 ↑ 1.0 1 6,125,557

Limit (cost=9.05..9.06 rows=1 width=20) (actual time=0.015..0.016 rows=1 loops=6,125,557)

104. 30,627.785 79,632.241 ↑ 2.0 1 6,125,557

Sort (cost=9.05..9.06 rows=2 width=20) (actual time=0.013..0.013 rows=1 loops=6,125,557)

  • Sort Key: empleados_movimientos_1.fecha, empleados_movimientos_1.id
  • Sort Method: quicksort Memory: 25kB
105. 49,004.456 49,004.456 ↑ 1.0 2 6,125,557

Index Scan using empleados_movimientos_empleado_id_idx on empleados_movimientos empleados_movimientos_1 (cost=0.00..9.04 rows=2 width=20) (actual time=0.005..0.008 rows=2 loops=6,125,557)

  • Index Cond: (empleado_id = emplea.id)
  • Rows Removed by Index Recheck: 0
106. 83.730 6,341.152 ↑ 1.0 1 5,582

Aggregate (cost=1,756.76..1,756.77 rows=1 width=8) (actual time=1.135..1.136 rows=1 loops=5,582)

107. 128.386 6,257.422 ↑ 3.2 12 5,582

Nested Loop (cost=0.72..1,756.67 rows=38 width=8) (actual time=0.115..1.121 rows=12 loops=5,582)

108. 39.074 39.074 ↑ 1.0 1 5,582

Index Only Scan using empresas_sucursales_nro_patronal_key on empresas_sucursales es_1 (cost=0.29..3.31 rows=1 width=4) (actual time=0.006..0.007 rows=1 loops=5,582)

  • Index Cond: (nro_patronal = empresas_sucursales_1.nro_patronal)
  • Heap Fetches: 22
109. 399.132 6,089.962 ↑ 3.2 12 5,582

Nested Loop (cost=0.43..1,752.98 rows=38 width=16) (actual time=0.105..1.091 rows=12 loops=5,582)

110. 717.907 4,783.774 ↑ 3.2 18 5,582

Index Scan using empleados_npatronal_id_idx on empleados empleados_1 (cost=0.43..1,403.10 rows=58 width=24) (actual time=0.061..0.857 rows=18 loops=5,582)

  • Index Cond: (npatronal = empresas_sucursales_1.nro_patronal)
  • Filter: (SubPlan 5)
  • Rows Removed by Filter: 20
111.          

SubPlan (forIndex Scan)

112. 427.986 4,065.867 ↑ 1.0 1 213,993

Limit (cost=9.06..9.06 rows=1 width=20) (actual time=0.019..0.019 rows=1 loops=213,993)

113. 1,069.965 3,637.881 ↑ 2.0 1 213,993

Sort (cost=9.06..9.06 rows=2 width=20) (actual time=0.017..0.017 rows=1 loops=213,993)

  • Sort Key: empleados_movimientos_2.fecha, empleados_movimientos_2.id
  • Sort Method: quicksort Memory: 25kB
114. 1,070.203 2,567.916 ↑ 1.0 2 213,993

Result (cost=0.00..9.05 rows=2 width=20) (actual time=0.007..0.012 rows=2 loops=213,993)

  • One-Time Filter: (empleados_1.empresa_id = emp_1.id)
115. 1,497.713 1,497.713 ↑ 1.0 2 213,959

Index Scan using empleados_movimientos_empleado_id_idx on empleados_movimientos empleados_movimientos_2 (cost=0.00..9.04 rows=2 width=20) (actual time=0.004..0.007 rows=2 loops=213,959)

  • Index Cond: (empleado_id = empleados_1.id)
  • Rows Removed by Index Recheck: 0
116. 907.056 907.056 ↑ 1.0 1 100,784

Index Scan using persons_id_idx on persons (cost=0.00..6.02 rows=1 width=8) (actual time=0.008..0.009 rows=1 loops=100,784)

  • Index Cond: (id = empleados_1.persona_id)
  • Rows Removed by Index Recheck: 0
  • Filter: ((sexo)::text = 'M'::text)
  • Rows Removed by Filter: 0
117. 55.820 5,582.000 ↑ 1.0 1 5,582

Aggregate (cost=1,756.54..1,756.55 rows=1 width=8) (actual time=0.999..1.000 rows=1 loops=5,582)

118. 83.730 5,526.180 ↑ 3.3 6 5,582

Nested Loop (cost=0.72..1,756.49 rows=20 width=8) (actual time=0.173..0.990 rows=6 loops=5,582)

119. 22.328 22.328 ↑ 1.0 1 5,582

Index Only Scan using empresas_sucursales_nro_patronal_key on empresas_sucursales es_2 (cost=0.29..3.31 rows=1 width=4) (actual time=0.003..0.004 rows=1 loops=5,582)

  • Index Cond: (nro_patronal = empresas_sucursales_1.nro_patronal)
  • Heap Fetches: 22
120. 327.798 5,420.122 ↑ 3.3 6 5,582

Nested Loop (cost=0.43..1,752.98 rows=20 width=16) (actual time=0.166..0.971 rows=6 loops=5,582)

121. 522.537 4,588.404 ↑ 3.2 18 5,582

Index Scan using empleados_npatronal_id_idx on empleados empleados_2 (cost=0.43..1,403.10 rows=58 width=24) (actual time=0.056..0.822 rows=18 loops=5,582)

  • Index Cond: (npatronal = empresas_sucursales_1.nro_patronal)
  • Filter: (SubPlan 7)
  • Rows Removed by Filter: 20
122.          

SubPlan (forIndex Scan)

123. 641.979 4,065.867 ↑ 1.0 1 213,993

Limit (cost=9.06..9.06 rows=1 width=20) (actual time=0.018..0.019 rows=1 loops=213,993)

124. 855.972 3,423.888 ↑ 2.0 1 213,993

Sort (cost=9.06..9.06 rows=2 width=20) (actual time=0.016..0.016 rows=1 loops=213,993)

  • Sort Key: empleados_movimientos_3.fecha, empleados_movimientos_3.id
  • Sort Method: quicksort Memory: 25kB
125. 1,284.162 2,567.916 ↑ 1.0 2 213,993

Result (cost=0.00..9.05 rows=2 width=20) (actual time=0.007..0.012 rows=2 loops=213,993)

  • One-Time Filter: (empleados_2.empresa_id = emp_1.id)
126. 1,283.754 1,283.754 ↑ 1.0 2 213,959

Index Scan using empleados_movimientos_empleado_id_idx on empleados_movimientos empleados_movimientos_3 (cost=0.00..9.04 rows=2 width=20) (actual time=0.004..0.006 rows=2 loops=213,959)

  • Index Cond: (empleado_id = empleados_2.id)
  • Rows Removed by Index Recheck: 0
127. 503.920 503.920 ↓ 0.0 0 100,784

Index Scan using persons_id_idx on persons persons_1 (cost=0.00..6.02 rows=1 width=8) (actual time=0.004..0.005 rows=0 loops=100,784)

  • Index Cond: (id = empleados_2.persona_id)
  • Rows Removed by Index Recheck: 0
  • Filter: ((sexo)::text = 'F'::text)
  • Rows Removed by Filter: 1
128. 16.746 329.338 ↑ 1.0 1 5,582

Limit (cost=7.19..7.19 rows=1 width=134) (actual time=0.058..0.059 rows=1 loops=5,582)

129. 27.910 312.592 ↑ 1.0 1 5,582

Sort (cost=7.19..7.19 rows=1 width=134) (actual time=0.056..0.056 rows=1 loops=5,582)

  • Sort Key: cambio_situacion_empresa.fecha_creacion, cambio_situacion_empresa.id_cambio_situacion_empresa
  • Sort Method: quicksort Memory: 25kB
130. 98.168 284.682 ↑ 1.0 1 5,582

Nested Loop (cost=0.00..7.18 rows=1 width=134) (actual time=0.034..0.051 rows=1 loops=5,582)

  • Join Filter: (cambio_situacion_empresa.situacion_act = situacion_emp.id_situacion)
  • Rows Removed by Join Filter: 8
131. 128.386 128.386 ↑ 1.0 1 5,582

Index Scan using cambio_situacion_empresa_nro_patronal_idx on cambio_situacion_empresa (cost=0.00..6.02 rows=1 width=20) (actual time=0.018..0.023 rows=1 loops=5,582)

  • Index Cond: (nro_patronal = empresas_sucursales_1.nro_patronal)
132. 58.128 58.128 ↑ 1.0 7 7,266

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