explain.depesz.com

PostgreSQL's explain analyze made readable

Result: a5b9 : Optimization for: 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; plan #u2eE

Settings

Optimization path:

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 116.444 257,865.297 ↓ 1.1 55,555 1

Unique (cost=313,790,560.99..313,794,224.13 rows=50,526 width=964) (actual time=257,663.539..257,865.297 rows=55,555 loops=1)

2. 409.565 257,748.853 ↓ 1.1 55,555 1

Sort (cost=313,790,560.99..313,790,687.31 rows=50,526 width=964) (actual time=257,663.537..257,748.853 rows=55,555 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. 95.560 257,339.288 ↓ 1.1 55,555 1

Append (cost=310,210,403.80..313,768,256.71 rows=50,526 width=964) (actual time=122,389.071..257,339.288 rows=55,555 loops=1)

4. 3,067.772 122,456.607 ↓ 1.0 49,973 1

Sort (cost=310,210,403.80..310,210,528.68 rows=49,954 width=964) (actual time=122,389.069..122,456.607 rows=49,973 loops=1)

  • Sort Key: empresas_sucursales.nro_patronal
  • Sort Method: external merge Disk: 19912kB
5. 633.440 119,388.835 ↓ 1.0 49,973 1

Hash Left Join (cost=3,088.37..310,188,355.31 rows=49,954 width=964) (actual time=111.770..119,388.835 rows=49,973 loops=1)

  • Hash Cond: (empresas_sucursales.type = empresas_sucursales_types.id)
6. 112.757 919.046 ↓ 1.0 49,973 1

Hash Left Join (cost=3,087.32..9,555.59 rows=49,954 width=940) (actual time=111.471..919.046 rows=49,973 loops=1)

  • Hash Cond: (empresas_sucursales.id_activ_econ = actividad_econ.id_activ_econ)
7. 102.353 805.060 ↓ 1.0 49,973 1

Hash Left Join (cost=3,062.57..8,844.00 rows=49,954 width=886) (actual time=110.234..805.060 rows=49,973 loops=1)

  • Hash Cond: (empresas_sucursales.distrito_id = distritos.id)
8. 106.260 702.672 ↓ 1.0 49,973 1

Hash Left Join (cost=3,061.10..8,156.04 rows=49,954 width=876) (actual time=110.189..702.672 rows=49,973 loops=1)

  • Hash Cond: (empresas_sucursales.city_id = city.id)
9. 90.293 595.949 ↓ 1.0 49,973 1

Hash Left Join (cost=3,048.45..7,459.03 rows=49,954 width=840) (actual time=109.715..595.949 rows=49,973 loops=1)

  • Hash Cond: (emp.id_categoria_empresa = empresas_categorias.id_categoria_empresa)
10. 100.835 505.639 ↓ 1.0 49,973 1

Hash Left Join (cost=3,035.30..7,253.65 rows=49,954 width=324) (actual time=109.690..505.639 rows=49,973 loops=1)

  • Hash Cond: (emp.type = empresas_types.id)
11. 203.012 404.754 ↓ 1.0 49,973 1

Hash Join (cost=3,033.71..6,645.77 rows=49,954 width=311) (actual time=109.623..404.754 rows=49,973 loops=1)

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

Seq Scan on empresas_sucursales (cost=0.00..2,612.95 rows=49,957 width=237) (actual time=0.016..92.156 rows=49,975 loops=1)

  • Filter: (type = 1)
  • Rows Removed by Filter: 5621
13. 48.670 109.586 ↓ 1.0 49,834 1

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

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

Seq Scan on empresas emp (cost=0.00..2,410.94 rows=49,822 width=82) (actual time=0.011..60.916 rows=49,834 loops=1)

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

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

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

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

17. 0.005 0.017 ↑ 35.0 4 1

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

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

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

19. 0.236 0.463 ↑ 1.0 251 1

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

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

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

21. 0.017 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
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.608 1.229 ↑ 1.0 700 1

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

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

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

25. 0.003 0.015 ↑ 1.0 1 1

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

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

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

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

SubPlan (forHash Left Join)

28. 649.649 32,282.558 ↑ 1.0 1 49,973

Aggregate (cost=1,410.13..1,410.14 rows=1 width=8) (actual time=0.645..0.646 rows=1 loops=49,973)

29. 1,049.433 31,632.909 ↑ 5.8 10 49,973

Nested Loop (cost=0.72..1,409.98 rows=58 width=8) (actual time=0.071..0.633 rows=10 loops=49,973)

30. 249.865 249.865 ↑ 1.0 1 49,973

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

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 35
31. 4,950.512 30,333.611 ↑ 5.8 10 49,973

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

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

SubPlan (forIndex Scan)

33. 2,207.226 25,383.099 ↑ 1.0 1 1,103,613

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

34. 5,518.065 23,175.873 ↑ 2.0 1 1,103,613

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

  • Sort Key: empleados_movimientos_4.fecha, empleados_movimientos_4.id
  • Sort Method: quicksort Memory: 25kB
35. 6,624.298 17,657.808 ↑ 1.0 2 1,103,613

Result (cost=0.00..9.05 rows=2 width=20) (actual time=0.010..0.016 rows=2 loops=1,103,613)

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

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

  • Index Cond: (empleado_id = empleados_3.id)
  • Rows Removed by Index Recheck: 0
37. 749.595 24,186.932 ↑ 1.0 1 49,973

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

38. 3,089.762 23,437.337 ↑ 5.8 12 49,973

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.040..0.469 rows=12 loops=49,973)

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

SubPlan (forIndex Only Scan)

40. 4,069.515 20,347.575 ↑ 1.0 1 1,356,505

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

41. 6,782.525 16,278.060 ↑ 2.0 1 1,356,505

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

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

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

  • Index Cond: (empleado_id = emplea_1.id)
  • Rows Removed by Index Recheck: 0
43. 449.757 30,633.449 ↑ 1.0 1 49,973

Aggregate (cost=1,759.76..1,759.77 rows=1 width=8) (actual time=0.612..0.613 rows=1 loops=49,973)

44. 699.622 30,183.692 ↑ 6.3 6 49,973

Nested Loop (cost=0.72..1,759.67 rows=38 width=8) (actual time=0.072..0.604 rows=6 loops=49,973)

45. 199.892 199.892 ↑ 1.0 1 49,973

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

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 35
46. 2,037.182 29,284.178 ↑ 6.3 6 49,973

Nested Loop (cost=0.43..1,752.98 rows=38 width=16) (actual time=0.065..0.586 rows=6 loops=49,973)

47. 2,818.501 23,787.148 ↑ 5.8 10 49,973

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.476 rows=10 loops=49,973)

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

SubPlan (forIndex Scan)

49. 3,310.839 20,968.647 ↑ 1.0 1 1,103,613

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

50. 4,414.452 17,657.808 ↑ 2.0 1 1,103,613

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

  • Sort Key: empleados_movimientos_6.fecha, empleados_movimientos_6.id
  • Sort Method: quicksort Memory: 25kB
51. 6,623.250 13,243.356 ↑ 1.0 2 1,103,613

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

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

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

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

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

  • 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.838 28,634.529 ↑ 1.0 1 49,973

Aggregate (cost=1,759.54..1,759.55 rows=1 width=8) (actual time=0.572..0.573 rows=1 loops=49,973)

55. 449.757 28,334.691 ↑ 6.7 3 49,973

Nested Loop (cost=0.72..1,759.49 rows=20 width=8) (actual time=0.111..0.567 rows=3 loops=49,973)

56. 199.892 199.892 ↑ 1.0 1 49,973

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

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 35
57. 1,576.493 27,685.042 ↑ 6.7 3 49,973

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

58. 2,668.582 23,637.229 ↑ 5.8 10 49,973

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

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

SubPlan (forIndex Scan)

60. 3,310.839 20,968.647 ↑ 1.0 1 1,103,613

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

61. 4,414.452 17,657.808 ↑ 2.0 1 1,103,613

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

  • Sort Key: empleados_movimientos_7.fecha, empleados_movimientos_7.id
  • Sort Method: quicksort Memory: 25kB
62. 6,623.250 13,243.356 ↑ 1.0 2 1,103,613

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

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

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

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

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

  • 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.919 2,098.866 ↑ 1.0 1 49,973

Limit (cost=7.19..7.19 rows=1 width=134) (actual time=0.041..0.042 rows=1 loops=49,973)

66. 249.865 1,948.947 ↑ 1.0 1 49,973

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

  • Sort Key: cambio_situacion_empresa_1.fecha_creacion, cambio_situacion_empresa_1.id_cambio_situacion_empresa
  • Sort Method: quicksort Memory: 25kB
67. 612.793 1,699.082 ↑ 1.0 1 49,973

Nested Loop (cost=0.00..7.18 rows=1 width=134) (actual time=0.022..0.034 rows=1 loops=49,973)

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

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.010..0.013 rows=1 loops=49,973)

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

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

70. 29.443 134,787.121 ↓ 9.8 5,582 1

Sort (cost=3,557,221.34..3,557,222.77 rows=572 width=966) (actual time=134,781.984..134,787.121 rows=5,582 loops=1)

  • Sort Key: empresas_sucursales_1.nro_patronal
  • Sort Method: quicksort Memory: 3808kB
71. 124.303 134,757.678 ↓ 9.8 5,582 1

Nested Loop Left Join (cost=27.27..3,557,195.14 rows=572 width=966) (actual time=2.558..134,757.678 rows=5,582 loops=1)

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

Nested Loop Left Join (cost=27.27..5,463.20 rows=572 width=942) (actual time=0.826..358.365 rows=5,582 loops=1)

73. 18.436 284.684 ↓ 9.8 5,582 1

Hash Left Join (cost=27.27..5,402.47 rows=572 width=888) (actual time=0.787..284.684 rows=5,582 loops=1)

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

Hash Left Join (cost=25.80..5,393.13 rows=572 width=878) (actual time=0.727..266.201 rows=5,582 loops=1)

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

Hash Left Join (cost=13.15..5,372.65 rows=572 width=842) (actual time=0.153..248.237 rows=5,582 loops=1)

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

Nested Loop Left Join (cost=0.00..5,357.29 rows=572 width=326) (actual time=0.116..235.299 rows=5,582 loops=1)

77. 35.477 166.220 ↓ 9.8 5,582 1

Nested Loop (cost=0.00..5,341.39 rows=572 width=313) (actual time=0.079..166.220 rows=5,582 loops=1)

78. 35.186 35.186 ↓ 9.8 5,621 1

Seq Scan on empresas_sucursales empresas_sucursales_1 (cost=0.00..2,751.94 rows=572 width=301) (actual time=0.023..35.186 rows=5,621 loops=1)

  • Filter: ((type <> 1) AND (type <> 1))
  • Rows Removed by Filter: 49975
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.009 0.023 ↑ 35.0 4 1

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

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

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

83. 0.248 0.562 ↑ 1.0 251 1

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

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

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

85. 0.019 0.047 ↑ 1.2 18 1

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

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

Seq Scan on distritos distritos_1 (cost=0.00..1.21 rows=21 width=18) (actual time=0.011..0.028 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.314 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.014 0.014 ↑ 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.010..0.014 rows=3 loops=1)

90.          

SubPlan (forNested Loop Left Join)

91. 117.222 6,045.306 ↑ 1.0 1 5,582

Aggregate (cost=1,410.13..1,410.14 rows=1 width=8) (actual time=1.082..1.083 rows=1 loops=5,582)

92. 200.952 5,928.084 ↑ 3.2 18 5,582

Nested Loop (cost=0.72..1,409.98 rows=58 width=8) (actual time=0.090..1.062 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..6.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. 980.146 5,688.058 ↑ 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.079..1.019 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. 641.988 4,707.912 ↑ 1.0 1 213,996

Limit (cost=9.06..9.06 rows=1 width=20) (actual time=0.021..0.022 rows=1 loops=213,996)

97. 1,069.980 4,065.924 ↑ 2.0 1 213,996

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

  • Sort Key: empleados_movimientos.fecha, empleados_movimientos.id
  • Sort Method: quicksort Memory: 25kB
98. 1,284.248 2,995.944 ↑ 1.0 2 213,996

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

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

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.008 rows=2 loops=213,962)

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

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

101. 14,948.232 112,957.352 ↓ 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.099..20.236 rows=475 loops=5,582)

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

SubPlan (forIndex Only Scan)

103. 12,251.140 98,009.120 ↑ 1.0 1 6,125,570

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

104. 36,753.420 85,757.980 ↑ 2.0 1 6,125,570

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

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

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

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

Aggregate (cost=1,759.76..1,759.77 rows=1 width=8) (actual time=1.186..1.187 rows=1 loops=5,582)

107. 133.968 6,542.104 ↑ 3.2 12 5,582

Nested Loop (cost=0.72..1,759.67 rows=38 width=8) (actual time=0.120..1.172 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..6.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. 454.634 6,369.062 ↑ 3.2 12 5,582

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

110. 626.658 4,906.578 ↑ 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.062..0.879 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. 641.988 4,279.920 ↑ 1.0 1 213,996

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

113. 1,069.980 3,637.932 ↑ 2.0 1 213,996

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

  • Sort Key: empleados_movimientos_2.fecha, empleados_movimientos_2.id
  • Sort Method: quicksort Memory: 25kB
114. 1,070.218 2,567.952 ↑ 1.0 2 213,996

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

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

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

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

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

  • 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,704.804 ↑ 1.0 1 5,582

Aggregate (cost=1,759.54..1,759.55 rows=1 width=8) (actual time=1.022..1.022 rows=1 loops=5,582)

118. 89.312 5,648.984 ↑ 3.3 6 5,582

Nested Loop (cost=0.72..1,759.49 rows=20 width=8) (actual time=0.175..1.012 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..6.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. 350.121 5,537.344 ↑ 3.3 6 5,582

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

121. 617.374 4,683.298 ↑ 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.839 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. 427.992 4,065.924 ↑ 1.0 1 213,996

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

124. 1,069.980 3,637.932 ↑ 2.0 1 213,996

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

  • Sort Key: empleados_movimientos_3.fecha, empleados_movimientos_3.id
  • Sort Method: quicksort Memory: 25kB
125. 1,284.180 2,567.952 ↑ 1.0 2 213,996

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

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

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

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

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

  • 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 340.502 ↑ 1.0 1 5,582

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

129. 33.492 323.756 ↑ 1.0 1 5,582

Sort (cost=7.19..7.19 rows=1 width=134) (actual time=0.058..0.058 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 290.264 ↑ 1.0 1 5,582

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

  • Join Filter: (cambio_situacion_empresa.situacion_act = situacion_emp.id_situacion)
  • Rows Removed by Join Filter: 8
131. 133.968 133.968 ↑ 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.019..0.024 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)