explain.depesz.com

PostgreSQL's explain analyze made readable

Result: FyDf

Settings
# exclusive inclusive rows x rows loops node
1. 0.040 252,224.982 ↑ 5.0 1 1

Nested Loop Left Join (cost=201,154,315.40..203,436,366.01 rows=5 width=2,292) (actual time=119,162.445..252,224.982 rows=1 loops=1)

2. 0.009 252,224.740 ↑ 5.0 1 1

Nested Loop Left Join (cost=201,154,315.12..203,436,270.79 rows=5 width=2,278) (actual time=119,162.220..252,224.740 rows=1 loops=1)

3. 0.009 252,224.705 ↑ 5.0 1 1

Nested Loop Left Join (cost=201,154,314.98..203,436,269.91 rows=5 width=1,766) (actual time=119,162.189..252,224.705 rows=1 loops=1)

4. 47.331 252,224.638 ↑ 5.0 1 1

Hash Right Join (cost=201,154,314.98..203,436,268.46 rows=5 width=1,751) (actual time=119,162.125..252,224.638 rows=1 loops=1)

  • Hash Cond: ("*SELECT* 1".nro_patronal = empleados.npatronal)
5. 90.339 252,177.166 ↓ 1.1 55,645 1

Append (cost=201,154,293.28..203,436,057.08 rows=50,567 width=1,037) (actual time=118,875.322..252,177.166 rows=55,645 loops=1)

6. 99.644 119,040.037 ↓ 1.0 50,051 1

Subquery Scan on *SELECT* 1 (cost=201,154,293.28..201,154,918.29 rows=50,001 width=1,037) (actual time=118,875.320..119,040.037 rows=50,051 loops=1)

7. 2,107.638 118,940.393 ↓ 1.0 50,051 1

Sort (cost=201,154,293.28..201,154,418.28 rows=50,001 width=964) (actual time=118,875.316..118,940.393 rows=50,051 loops=1)

  • Sort Key: empresas_sucursales.nro_patronal
  • Sort Method: external merge Disk: 19952kB
8. 678.353 116,832.755 ↓ 1.0 50,051 1

Hash Left Join (cost=3,088.70..201,135,253.29 rows=50,001 width=964) (actual time=108.244..116,832.755 rows=50,051 loops=1)

  • Hash Cond: (empresas_sucursales.type = empresas_sucursales_types.id)
9. 108.900 886.935 ↓ 1.0 50,051 1

Hash Left Join (cost=3,087.65..9,559.77 rows=50,001 width=940) (actual time=107.997..886.935 rows=50,051 loops=1)

  • Hash Cond: (empresas_sucursales.id_activ_econ = actividad_econ.id_activ_econ)
10. 98.874 776.829 ↓ 1.0 50,051 1

Hash Left Join (cost=3,062.90..8,847.53 rows=50,001 width=886) (actual time=106.771..776.829 rows=50,051 loops=1)

  • Hash Cond: (empresas_sucursales.distrito_id = distritos_1.id)
11. 101.525 677.921 ↓ 1.0 50,051 1

Hash Left Join (cost=3,061.43..8,158.96 rows=50,001 width=876) (actual time=106.715..677.921 rows=50,051 loops=1)

  • Hash Cond: (empresas_sucursales.city_id = city_1.id)
12. 86.534 575.894 ↓ 1.0 50,051 1

Hash Left Join (cost=3,048.78..7,461.27 rows=50,001 width=840) (actual time=106.202..575.894 rows=50,051 loops=1)

  • Hash Cond: (emp.id_categoria_empresa = empresas_categorias.id_categoria_empresa)
13. 97.005 489.343 ↓ 1.0 50,051 1

Hash Left Join (cost=3,035.63..7,255.72 rows=50,001 width=324) (actual time=106.176..489.343 rows=50,051 loops=1)

  • Hash Cond: (emp.type = empresas_types.id)
14. 192.826 392.288 ↓ 1.0 50,051 1

Hash Join (cost=3,034.04..6,647.27 rows=50,001 width=311) (actual time=106.108..392.288 rows=50,051 loops=1)

  • Hash Cond: (empresas_sucursales.empresa_id = emp.id)
15. 93.388 93.388 ↓ 1.0 50,053 1

Seq Scan on empresas_sucursales (cost=0.00..2,613.18 rows=50,004 width=237) (actual time=0.013..93.388 rows=50,053 loops=1)

  • Filter: (type = 1)
  • Rows Removed by Filter: 5633
16. 48.102 106.074 ↓ 1.0 49,913 1

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

  • Buckets: 8192 Batches: 1 Memory Usage: 5579kB
17. 57.972 57.972 ↓ 1.0 49,913 1

Seq Scan on empresas emp (cost=0.00..2,411.13 rows=49,833 width=82) (actual time=0.009..57.972 rows=49,913 loops=1)

  • Filter: (((document)::text <> '0'::text) AND ((document)::text <> ''::text) AND ((document)::text <> '-'::text))
  • Rows Removed by Filter: 2
18. 0.026 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
19. 0.024 0.024 ↓ 1.2 30 1

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

20. 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
21. 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.009..0.012 rows=4 loops=1)

22. 0.254 0.502 ↑ 1.0 251 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 19kB
23. 0.248 0.248 ↑ 1.0 251 1

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

24. 0.015 0.034 ↑ 1.2 18 1

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

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

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

26. 0.632 1.206 ↓ 1.0 702 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 64kB
27. 0.574 0.574 ↓ 1.0 702 1

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

28. 0.002 0.014 ↑ 1.0 1 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
29. 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
30.          

SubPlan (forHash Left Join)

31. 600.612 32,032.640 ↑ 1.0 1 50,051

Aggregate (cost=957.75..957.76 rows=1 width=8) (actual time=0.640..0.640 rows=1 loops=50,051)

32. 1,001.020 31,432.028 ↑ 5.9 10 50,051

Nested Loop (cost=0.72..957.60 rows=59 width=8) (actual time=0.071..0.628 rows=10 loops=50,051)

33. 250.255 250.255 ↑ 1.0 1 50,051

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

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 1098
34. 4,743.788 30,180.753 ↑ 5.9 10 50,051

Index Scan using empleados_npatronal_id_idx on empleados empleados_1 (cost=0.43..954.70 rows=59 width=24) (actual time=0.063..0.603 rows=10 loops=50,051)

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

SubPlan (forIndex Scan)

36. 3,317.865 25,436.965 ↑ 1.0 1 1,105,955

Limit (cost=6.06..6.06 rows=1 width=20) (actual time=0.022..0.023 rows=1 loops=1,105,955)

37. 4,423.820 22,119.100 ↑ 2.0 1 1,105,955

Sort (cost=6.06..6.06 rows=2 width=20) (actual time=0.020..0.020 rows=1 loops=1,105,955)

  • Sort Key: empleados_movimientos_3.fecha, empleados_movimientos_3.id
  • Sort Method: quicksort Memory: 25kB
38. 17,695.280 17,695.280 ↑ 1.0 2 1,105,955

Result (cost=0.00..6.05 rows=2 width=20) (actual time=0.010..0.016 rows=2 loops=1,105,955)

  • One-Time Filter: (empleados_1.empresa_id = emp.id)
  • -> 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.007..0.010 row (...)
  • Index Cond: (empleado_id = empleados_1.id)
  • Rows Removed by Index Recheck: 0
39. 750.765 23,824.276 ↑ 1.0 1 50,051

Aggregate (cost=854.68..854.71 rows=1 width=16) (actual time=0.475..0.476 rows=1 loops=50,051)

40. 4,038.915 23,073.511 ↑ 5.8 12 50,051

Index Only Scan using empleados_empresa_id_id_idx on empleados emplea (cost=0.43..853.28 rows=70 width=16) (actual time=0.039..0.461 rows=12 loops=50,051)

  • Index Cond: (empresa_id = emp.id)
  • Filter: (SubPlan 7)
  • Rows Removed by Filter: 15
  • Heap Fetches: 99610
41.          

SubPlan (forIndex Only Scan)

42. 2,719.228 19,034.596 ↑ 1.0 1 1,359,614

Limit (cost=6.05..6.06 rows=1 width=20) (actual time=0.014..0.014 rows=1 loops=1,359,614)

43. 16,315.368 16,315.368 ↑ 2.0 1 1,359,614

Sort (cost=6.05..6.06 rows=2 width=20) (actual time=0.012..0.012 rows=1 loops=1,359,614)

  • Sort Key: empleados_movimientos_4.fecha, empleados_movimientos_4.id
  • Sort Method: quicksort Memory: 25kB
  • -> Index Scan using empleados_movimientos_empleado_id_idx on empleados_movimientos empleados_movimientos_4 (cost=0.00..6.04 rows=2 width=20) (actual time=0.005..0.007 rows=2 loops=13 (...)
  • Index Cond: (empleado_id = emplea.id)
  • Rows Removed by Index Recheck: 0
44. 450.459 29,530.090 ↑ 1.0 1 50,051

Aggregate (cost=1,102.49..1,102.50 rows=1 width=8) (actual time=0.589..0.590 rows=1 loops=50,051)

45. 650.663 29,079.631 ↑ 6.5 6 50,051

Nested Loop (cost=1.14..1,102.39 rows=39 width=8) (actual time=0.069..0.581 rows=6 loops=50,051)

46. 200.204 200.204 ↑ 1.0 1 50,051

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.003..0.004 rows=1 loops=50,051)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 1097
47. 1,346.406 28,228.764 ↑ 6.5 6 50,051

Nested Loop (cost=0.85..1,099.70 rows=39 width=16) (actual time=0.063..0.564 rows=6 loops=50,051)

48. 3,516.678 23,423.868 ↑ 5.9 10 50,051

Index Scan using empleados_npatronal_id_idx on empleados empleados_2 (cost=0.43..954.70 rows=59 width=24) (actual time=0.040..0.468 rows=10 loops=50,051)

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

SubPlan (forIndex Scan)

50. 2,211.910 19,907.190 ↑ 1.0 1 1,105,955

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

51. 5,529.775 17,695.280 ↑ 2.0 1 1,105,955

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

  • Sort Key: empleados_movimientos_5.fecha, empleados_movimientos_5.id
  • Sort Method: quicksort Memory: 25kB
52. 12,165.505 12,165.505 ↑ 1.0 2 1,105,955

Result (cost=0.00..6.05 rows=2 width=20) (actual time=0.006..0.011 rows=2 loops=1,105,955)

  • One-Time Filter: (empleados_2.empresa_id = emp.id)
  • -> Index Scan using empleados_movimientos_empleado_id_idx on empleados_movimientos empleados_movimientos_5 (cost=0.00..6.04 rows=2 width=20) (actual time=0.004..0.0 (...)
  • Index Cond: (empleado_id = empleados_2.id)
  • Rows Removed by Index Recheck: 0
53. 3,458.490 3,458.490 ↑ 1.0 1 494,070

Index Only Scan using persons_id_sexo_idx on persons persons_1 (cost=0.42..2.45 rows=1 width=8) (actual time=0.006..0.007 rows=1 loops=494,070)

  • Index Cond: ((id = empleados_2.persona_id) AND (sexo = 'M'::text))
  • Heap Fetches: 30898
54. 300.306 27,828.356 ↑ 1.0 1 50,051

Aggregate (cost=1,102.25..1,102.26 rows=1 width=8) (actual time=0.556..0.556 rows=1 loops=50,051)

55. 450.459 27,528.050 ↑ 6.7 3 50,051

Nested Loop (cost=1.14..1,102.20 rows=20 width=8) (actual time=0.107..0.550 rows=3 loops=50,051)

56. 150.153 150.153 ↑ 1.0 1 50,051

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

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 1097
57. 1,083.271 26,927.438 ↑ 6.7 3 50,051

Nested Loop (cost=0.85..1,099.70 rows=20 width=16) (actual time=0.101..0.538 rows=3 loops=50,051)

58. 3,466.627 23,373.817 ↑ 5.9 10 50,051

Index Scan using empleados_npatronal_id_idx on empleados empleados_3 (cost=0.43..954.70 rows=59 width=24) (actual time=0.040..0.467 rows=10 loops=50,051)

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

SubPlan (forIndex Scan)

60. 2,211.910 19,907.190 ↑ 1.0 1 1,105,955

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

61. 5,529.775 17,695.280 ↑ 2.0 1 1,105,955

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

  • Sort Key: empleados_movimientos_6.fecha, empleados_movimientos_6.id
  • Sort Method: quicksort Memory: 25kB
62. 12,165.505 12,165.505 ↑ 1.0 2 1,105,955

Result (cost=0.00..6.05 rows=2 width=20) (actual time=0.006..0.011 rows=2 loops=1,105,955)

  • One-Time Filter: (empleados_3.empresa_id = emp.id)
  • -> Index Scan using empleados_movimientos_empleado_id_idx on empleados_movimientos empleados_movimientos_6 (cost=0.00..6.04 rows=2 width=20) (actual time=0.004..0.0 (...)
  • Index Cond: (empleado_id = empleados_3.id)
  • Rows Removed by Index Recheck: 0
63. 2,470.350 2,470.350 ↓ 0.0 0 494,070

Index Only Scan using persons_id_sexo_idx on persons persons_2 (cost=0.42..2.45 rows=1 width=8) (actual time=0.004..0.005 rows=0 loops=494,070)

  • Index Cond: ((id = empleados_3.persona_id) AND (sexo = 'F'::text))
  • Heap Fetches: 17648
64. 150.153 2,052.091 ↑ 1.0 1 50,051

Limit (cost=5.19..5.19 rows=1 width=134) (actual time=0.040..0.041 rows=1 loops=50,051)

65. 200.204 1,901.938 ↑ 1.0 1 50,051

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

  • Sort Key: cambio_situacion_empresa.fecha_creacion, cambio_situacion_empresa.id_cambio_situacion_empresa
  • Sort Method: top-N heapsort Memory: 25kB
66. 666.176 1,701.734 ↑ 1.0 1 50,051

Nested Loop (cost=0.00..5.18 rows=1 width=134) (actual time=0.021..0.034 rows=1 loops=50,051)

  • Join Filter: (cambio_situacion_empresa.situacion_act = situacion_emp.id_situacion)
  • Rows Removed by Join Filter: 7
67. 650.663 650.663 ↑ 1.0 1 50,051

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

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
68. 384.895 384.895 ↑ 1.0 7 54,985

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

69. 10.731 133,046.790 ↓ 9.9 5,594 1

Subquery Scan on *SELECT* 2 (cost=2,281,131.72..2,281,138.79 rows=566 width=1,038) (actual time=133,031.185..133,046.790 rows=5,594 loops=1)

70. 29.309 133,036.059 ↓ 9.9 5,594 1

Sort (cost=2,281,131.72..2,281,133.13 rows=566 width=965) (actual time=133,031.181..133,036.059 rows=5,594 loops=1)

  • Sort Key: empresas_sucursales_1.nro_patronal
  • Sort Method: quicksort Memory: 3819kB
71. 108.671 133,006.750 ↓ 9.9 5,594 1

Nested Loop Left Join (cost=27.56..2,281,105.84 rows=566 width=965) (actual time=2.353..133,006.750 rows=5,594 loops=1)

  • Join Filter: (empresas_sucursales_1.type = empresas_sucursales_types_1.id)
  • Rows Removed by Join Filter: 11188
72. 26.052 353.843 ↓ 9.9 5,594 1

Nested Loop Left Join (cost=27.56..4,389.81 rows=566 width=941) (actual time=0.681..353.843 rows=5,594 loops=1)

73. 17.997 283.039 ↓ 9.9 5,594 1

Hash Left Join (cost=27.56..4,344.24 rows=566 width=887) (actual time=0.654..283.039 rows=5,594 loops=1)

  • Hash Cond: (empresas_sucursales_1.distrito_id = distritos_2.id)
74. 16.121 265.005 ↓ 9.9 5,594 1

Hash Left Join (cost=26.09..4,334.99 rows=566 width=877) (actual time=0.604..265.005 rows=5,594 loops=1)

  • Hash Cond: (empresas_sucursales_1.city_id = city_2.id)
75. 12.721 248.384 ↓ 9.9 5,594 1

Hash Left Join (cost=13.44..4,314.59 rows=566 width=841) (actual time=0.089..248.384 rows=5,594 loops=1)

  • Hash Cond: (emp_1.id_categoria_empresa = empresas_categorias_1.id_categoria_empresa)
76. 29.212 235.649 ↓ 9.9 5,594 1

Nested Loop Left Join (cost=0.29..4,299.25 rows=566 width=325) (actual time=0.060..235.649 rows=5,594 loops=1)

77. 24.957 167.279 ↓ 9.9 5,594 1

Nested Loop (cost=0.29..4,283.57 rows=566 width=312) (actual time=0.033..167.279 rows=5,594 loops=1)

78. 35.295 35.295 ↓ 10.0 5,633 1

Seq Scan on empresas_sucursales empresas_sucursales_1 (cost=0.00..2,752.21 rows=566 width=300) (actual time=0.012..35.295 rows=5,633 loops=1)

  • Filter: ((type <> 1) AND (type <> 1))
  • Rows Removed by Filter: 50053
79. 107.027 107.027 ↑ 1.0 1 5,633

Index Scan using empresas_id_document_id_categoria_empresa_idx on empresas emp_1 (cost=0.29..2.70 rows=1 width=20) (actual time=0.018..0.019 rows=1 loops=5,633)

  • 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.158 39.158 ↑ 1.0 1 5,594

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

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

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

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

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

83. 0.253 0.500 ↑ 1.0 251 1

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

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

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

85. 0.020 0.037 ↑ 1.2 18 1

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

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

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

87. 44.752 44.752 ↑ 1.0 1 5,594

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

  • Index Cond: (empresas_sucursales_1.id_activ_econ = id_activ_econ)
88. 22.359 22.376 ↑ 1.0 3 5,594

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

89. 0.017 0.017 ↑ 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.013..0.017 rows=3 loops=1)

90.          

SubPlan (forNested Loop Left Join)

91. 111.880 6,723.988 ↑ 1.0 1 5,594

Aggregate (cost=957.75..957.76 rows=1 width=8) (actual time=1.201..1.202 rows=1 loops=5,594)

92. 195.790 6,612.108 ↑ 3.3 18 5,594

Nested Loop (cost=0.72..957.60 rows=59 width=8) (actual time=0.211..1.182 rows=18 loops=5,594)

93. 699.250 699.250 ↑ 1.0 1 5,594

Index Only Scan using empresas_sucursales_nro_patronal_key on empresas_sucursales es_3 (cost=0.29..2.31 rows=1 width=4) (actual time=0.124..0.125 rows=1 loops=5,594)

  • Index Cond: (nro_patronal = empresas_sucursales_1.nro_patronal)
  • Heap Fetches: 399
94. 1,207.780 5,717.068 ↑ 3.3 18 5,594

Index Scan using empleados_npatronal_id_idx on empleados empleados_4 (cost=0.43..954.70 rows=59 width=24) (actual time=0.082..1.022 rows=18 loops=5,594)

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

SubPlan (forIndex Scan)

96. 429.456 4,509.288 ↑ 1.0 1 214,728

Limit (cost=6.06..6.06 rows=1 width=20) (actual time=0.021..0.021 rows=1 loops=214,728)

97. 1,073.640 4,079.832 ↑ 2.0 1 214,728

Sort (cost=6.06..6.06 rows=2 width=20) (actual time=0.019..0.019 rows=1 loops=214,728)

  • Sort Key: empleados_movimientos_7.fecha, empleados_movimientos_7.id
  • Sort Method: quicksort Memory: 25kB
98. 3,006.192 3,006.192 ↑ 1.0 2 214,728

Result (cost=0.00..6.05 rows=2 width=20) (actual time=0.009..0.014 rows=2 loops=214,728)

  • One-Time Filter: (empleados_4.empresa_id = emp_1.id)
  • -> Index Scan using empleados_movimientos_empleado_id_idx on empleados_movimientos empleados_movimientos_7 (cost=0.00..6.04 rows=2 width=20) (actual time=0.006..0.009 row (...)
  • Index Cond: (empleado_id = empleados_4.id)
  • Rows Removed by Index Recheck: 0
99. 2,444.578 113,619.734 ↑ 1.0 1 5,594

Aggregate (cost=854.68..854.71 rows=1 width=16) (actual time=20.310..20.311 rows=1 loops=5,594)

100. 12,704.532 111,175.156 ↓ 6.8 476 5,594

Index Only Scan using empleados_empresa_id_id_idx on empleados emplea_1 (cost=0.43..853.28 rows=70 width=16) (actual time=0.100..19.874 rows=476 loops=5,594)

  • Index Cond: (empresa_id = emp_1.id)
  • Filter: (SubPlan 16)
  • Rows Removed by Filter: 624
  • Heap Fetches: 452312
101.          

SubPlan (forIndex Only Scan)

102. 12,308.828 98,470.624 ↑ 1.0 1 6,154,414

Limit (cost=6.05..6.06 rows=1 width=20) (actual time=0.015..0.016 rows=1 loops=6,154,414)

103. 86,161.796 86,161.796 ↑ 2.0 1 6,154,414

Sort (cost=6.05..6.06 rows=2 width=20) (actual time=0.014..0.014 rows=1 loops=6,154,414)

  • Sort Key: empleados_movimientos_8.fecha, empleados_movimientos_8.id
  • Sort Method: quicksort Memory: 25kB
  • -> Index Scan using empleados_movimientos_empleado_id_idx on empleados_movimientos empleados_movimientos_8 (cost=0.00..6.04 rows=2 width=20) (actual time=0.005..0.008 rows=2 loops=61 (...)
  • Index Cond: (empleado_id = emplea_1.id)
  • Rows Removed by Index Recheck: 0
104. 83.910 6,338.002 ↑ 1.0 1 5,594

Aggregate (cost=1,102.49..1,102.50 rows=1 width=8) (actual time=1.132..1.133 rows=1 loops=5,594)

105. 123.068 6,254.092 ↑ 3.2 12 5,594

Nested Loop (cost=1.14..1,102.39 rows=39 width=8) (actual time=0.118..1.118 rows=12 loops=5,594)

106. 39.158 39.158 ↑ 1.0 1 5,594

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

  • Index Cond: (nro_patronal = empresas_sucursales_1.nro_patronal)
  • Heap Fetches: 399
107. 365.793 6,091.866 ↑ 3.2 12 5,594

Nested Loop (cost=0.85..1,099.70 rows=39 width=16) (actual time=0.108..1.089 rows=12 loops=5,594)

108. 736.602 4,816.434 ↑ 3.3 18 5,594

Index Scan using empleados_npatronal_id_idx on empleados empleados_5 (cost=0.43..954.70 rows=59 width=24) (actual time=0.060..0.861 rows=18 loops=5,594)

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

SubPlan (forIndex Scan)

110. 429.456 4,079.832 ↑ 1.0 1 214,728

Limit (cost=6.06..6.06 rows=1 width=20) (actual time=0.019..0.019 rows=1 loops=214,728)

111. 1,073.640 3,650.376 ↑ 2.0 1 214,728

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

  • Sort Key: empleados_movimientos_9.fecha, empleados_movimientos_9.id
  • Sort Method: quicksort Memory: 25kB
112. 2,576.736 2,576.736 ↑ 1.0 2 214,728

Result (cost=0.00..6.05 rows=2 width=20) (actual time=0.007..0.012 rows=2 loops=214,728)

  • One-Time Filter: (empleados_5.empresa_id = emp_1.id)
  • -> Index Scan using empleados_movimientos_empleado_id_idx on empleados_movimientos empleados_movimientos_9 (cost=0.00..6.04 rows=2 width=20) (actual time=0.004..0.0 (...)
  • Index Cond: (empleado_id = empleados_5.id)
  • Rows Removed by Index Recheck: 0
113. 909.639 909.639 ↑ 1.0 1 101,071

Index Only Scan using persons_id_sexo_idx on persons persons_3 (cost=0.42..2.45 rows=1 width=8) (actual time=0.009..0.009 rows=1 loops=101,071)

  • Index Cond: ((id = empleados_5.persona_id) AND (sexo = 'M'::text))
  • Heap Fetches: 6121
114. 55.940 5,504.496 ↑ 1.0 1 5,594

Aggregate (cost=1,102.25..1,102.26 rows=1 width=8) (actual time=0.983..0.984 rows=1 loops=5,594)

115. 83.910 5,448.556 ↑ 2.9 7 5,594

Nested Loop (cost=1.14..1,102.20 rows=20 width=8) (actual time=0.170..0.974 rows=7 loops=5,594)

116. 22.376 22.376 ↑ 1.0 1 5,594

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

  • Index Cond: (nro_patronal = empresas_sucursales_1.nro_patronal)
  • Heap Fetches: 399
117. 233.053 5,342.270 ↑ 2.9 7 5,594

Nested Loop (cost=0.85..1,099.70 rows=20 width=16) (actual time=0.163..0.955 rows=7 loops=5,594)

118. 524.030 4,603.862 ↑ 3.3 18 5,594

Index Scan using empleados_npatronal_id_idx on empleados empleados_6 (cost=0.43..954.70 rows=59 width=24) (actual time=0.056..0.823 rows=18 loops=5,594)

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

SubPlan (forIndex Scan)

120. 644.184 4,079.832 ↑ 1.0 1 214,728

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

121. 858.912 3,435.648 ↑ 2.0 1 214,728

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

  • Sort Key: empleados_movimientos_10.fecha, empleados_movimientos_10.id
  • Sort Method: quicksort Memory: 25kB
122. 2,576.736 2,576.736 ↑ 1.0 2 214,728

Result (cost=0.00..6.05 rows=2 width=20) (actual time=0.007..0.012 rows=2 loops=214,728)

  • One-Time Filter: (empleados_6.empresa_id = emp_1.id)
  • -> Index Scan using empleados_movimientos_empleado_id_idx on empleados_movimientos empleados_movimientos_10 (cost=0.00..6.04 rows=2 width=20) (actual time=0.004..0. (...)
  • Index Cond: (empleado_id = empleados_6.id)
  • Rows Removed by Index Recheck: 0
123. 505.355 505.355 ↓ 0.0 0 101,071

Index Only Scan using persons_id_sexo_idx on persons persons_4 (cost=0.42..2.45 rows=1 width=8) (actual time=0.004..0.005 rows=0 loops=101,071)

  • Index Cond: ((id = empleados_6.persona_id) AND (sexo = 'F'::text))
  • Heap Fetches: 3763
124. 16.782 335.640 ↑ 1.0 1 5,594

Limit (cost=5.19..5.19 rows=1 width=134) (actual time=0.059..0.060 rows=1 loops=5,594)

125. 33.564 318.858 ↑ 1.0 1 5,594

Sort (cost=5.19..5.19 rows=1 width=134) (actual time=0.057..0.057 rows=1 loops=5,594)

  • Sort Key: cambio_situacion_empresa_1.fecha_creacion, cambio_situacion_empresa_1.id_cambio_situacion_empresa
  • Sort Method: quicksort Memory: 25kB
126. 226.758 285.294 ↑ 1.0 1 5,594

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

  • Join Filter: (cambio_situacion_empresa_1.situacion_act = situacion_emp_1.id_situacion)
  • Rows Removed by Join Filter: 8
  • -> Index Scan using cambio_situacion_empresa_nro_patronal_idx on cambio_situacion_empresa cambio_situacion_empresa_1 (cost=0.00..4.02 rows=1 width=20) (actual time=0.019..0.024 rows=1 loops= (...)
  • Index Cond: (nro_patronal = empresas_sucursales_1.nro_patronal)
127. 58.536 58.536 ↑ 1.0 7 7,317

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=7,317)

128. 0.005 0.141 ↑ 1.0 1 1

Hash (cost=21.68..21.68 rows=1 width=722) (actual time=0.141..0.141 rows=1 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
129. 0.006 0.136 ↑ 1.0 1 1

Nested Loop Left Join (cost=1.28..21.68 rows=1 width=722) (actual time=0.119..0.136 rows=1 loops=1)

130. 0.003 0.124 ↑ 1.0 1 1

Nested Loop Left Join (cost=1.13..21.51 rows=1 width=210) (actual time=0.111..0.124 rows=1 loops=1)

131. 0.005 0.104 ↑ 1.0 1 1

Nested Loop Left Join (cost=1.13..21.48 rows=1 width=182) (actual time=0.093..0.104 rows=1 loops=1)

132. 0.003 0.095 ↑ 1.0 1 1

Nested Loop Left Join (cost=0.99..21.32 rows=1 width=176) (actual time=0.087..0.095 rows=1 loops=1)

133. 0.005 0.088 ↑ 1.0 1 1

Nested Loop (cost=0.85..21.15 rows=1 width=144) (actual time=0.082..0.088 rows=1 loops=1)

134. 0.006 0.049 ↑ 1.0 1 1

Nested Loop (cost=0.85..8.90 rows=1 width=124) (actual time=0.046..0.049 rows=1 loops=1)

135. 0.030 0.030 ↑ 1.0 1 1

Index Scan using persons_docs_valor_idx on persons_docs (cost=0.42..4.45 rows=1 width=16) (actual time=0.030..0.030 rows=1 loops=1)

  • Index Cond: ((valor)::text = '5119588'::text)
  • Filter: ((valor)::text ~~ '5119588'::text)
136. 0.013 0.013 ↑ 1.0 1 1

Index Scan using persons_id_sexo_idx on persons (cost=0.42..4.45 rows=1 width=108) (actual time=0.012..0.013 rows=1 loops=1)

  • Index Cond: (id = persons_docs.person_id)
137. 0.019 0.034 ↑ 1.0 1 1

Index Scan using empleados_personas_indx on empleados (cost=0.00..12.24 rows=1 width=36) (actual time=0.033..0.034 rows=1 loops=1)

  • Index Cond: (persona_id = persons.id)
  • Filter: ((SubPlan 4) = 'Activo'::text)
138.          

SubPlan (forIndex Scan)

139. 0.015 0.015 ↑ 2.0 1 1

Index Scan using empleados_movimientos_empleado_id_idx on empleados_movimientos empleados_movimientos_2 (cost=0.00..6.05 rows=2 width=8) (actual time=0.013..0.015 rows=1 loops=1)

  • Index Cond: (empleado_id = empleados.id)
140. 0.004 0.004 ↑ 1.0 1 1

Index Scan using city_id_distrito_id_idx on city (cost=0.14..0.16 rows=1 width=40) (actual time=0.003..0.004 rows=1 loops=1)

  • Index Cond: (persons.city_id = id)
141. 0.004 0.004 ↑ 1.0 1 1

Index Scan using distritos_pkey on distritos (cost=0.14..0.16 rows=1 width=18) (actual time=0.003..0.004 rows=1 loops=1)

  • Index Cond: (persons.distrito_id = id)
142. 0.017 0.017 ↑ 1.0 1 1

Index Scan using persons_estado_civil_type_id_idx on persons_estado_civil_type (cost=0.00..0.02 rows=1 width=36) (actual time=0.016..0.017 rows=1 loops=1)

  • Index Cond: (persons.estado_civil = id)
143. 0.006 0.006 ↑ 1.0 1 1

Index Scan using persons_indigenas_types_pkey on persons_indigenas_types (cost=0.14..0.16 rows=1 width=520) (actual time=0.005..0.006 rows=1 loops=1)

  • Index Cond: (persons.esindigena = id_persons_indigenas_types)
144. 0.058 0.058 ↑ 1.0 1 1

Index Scan using empleado_cargo_id_idx on empleado_cargo (cost=0.00..0.28 rows=1 width=31) (actual time=0.057..0.058 rows=1 loops=1)

  • Index Cond: (empleados.cargo_id = id)
145. 0.026 0.026 ↑ 1.0 1 1

Index Scan using empleado_categoria_pkey on empleado_categoria (cost=0.14..0.17 rows=1 width=520) (actual time=0.025..0.026 rows=1 loops=1)

  • Index Cond: (empleados.id_categoria = id_empleado_categoria)
146. 0.030 0.030 ↑ 1.0 1 1

Index Scan using persona_profesion_pkey on persona_profesion (cost=0.28..0.30 rows=1 width=30) (actual time=0.029..0.030 rows=1 loops=1)

  • Index Cond: (persons.id_profesion = id_persona_profesion)
147.          

SubPlan (forNested Loop Left Join)

148. 0.069 0.069 ↑ 2.0 1 1

Index Only Scan using empleados_movimientos_empleado_id_tipo_fecha_key on empleados_movimientos (cost=0.43..4.47 rows=2 width=8) (actual time=0.068..0.069 rows=1 loops=1)

  • Index Cond: ((empleado_id = empleados.id) AND (tipo = 1))
  • Heap Fetches: 0
149. 0.022 0.022 ↑ 2.0 1 1

Index Scan using empleados_movimientos_empleado_id_idx on empleados_movimientos empleados_movimientos_1 (cost=0.00..6.05 rows=2 width=8) (actual time=0.020..0.022 rows=1 loops=1)

  • Index Cond: (empleado_id = empleados.id)
150. 0.010 0.081 ↑ 1.0 1 1

Aggregate (cost=8.20..8.21 rows=1 width=516) (actual time=0.080..0.081 rows=1 loops=1)

151. 0.009 0.071 ↑ 1.0 1 1

Nested Loop (cost=0.14..8.19 rows=1 width=516) (actual time=0.065..0.071 rows=1 loops=1)

152. 0.039 0.039 ↑ 1.0 1 1

Index Scan using persons_discapacidades_person_id_idx on persons_discapacidades x (cost=0.00..4.02 rows=1 width=4) (actual time=0.038..0.039 rows=1 loops=1)

  • Index Cond: (person_id = empleados.persona_id)
153. 0.023 0.023 ↑ 1.0 1 1

Index Scan using persons_discap_types_pkey on persons_discap_types (cost=0.14..4.17 rows=1 width=520) (actual time=0.021..0.023 rows=1 loops=1)

  • Index Cond: (persons_discap_types_id = x.tipo_discapacidad_id)