explain.depesz.com

PostgreSQL's explain analyze made readable

Result: mEGP

Settings
# exclusive inclusive rows x rows loops node
1. 804.269 135,372.959 ↓ 1.0 49,997 1

Hash Left Join (cost=3,024.43..410,874,016.14 rows=49,893 width=1,489) (actual time=106.631..135,372.959 rows=49,997 loops=1)

  • Hash Cond: (empresas_sucursales.type = empresas_sucursales_types.id)
2. 104.042 926.693 ↓ 1.0 49,997 1

Hash Left Join (cost=3,023.38..13,446.55 rows=49,893 width=1,465) (actual time=106.056..926.693 rows=49,997 loops=1)

  • Hash Cond: (empresas_sucursales.id_activ_econ = actividad_econ.id_activ_econ)
3. 93.618 821.721 ↓ 1.0 49,997 1

Hash Left Join (cost=2,998.61..12,735.77 rows=49,893 width=1,411) (actual time=105.107..821.721 rows=49,997 loops=1)

  • Hash Cond: (empresas_sucursales.distrito_id = distritos.id)
4. 101.105 728.064 ↓ 1.0 49,997 1

Hash Left Join (cost=2,997.21..12,048.73 rows=49,893 width=1,379) (actual time=105.055..728.064 rows=49,997 loops=1)

  • Hash Cond: (empresas_sucursales.city_id = city.id)
5. 82.335 626.611 ↓ 1.0 49,997 1

Hash Left Join (cost=2,988.56..11,356.55 rows=49,893 width=1,343) (actual time=104.694..626.611 rows=49,997 loops=1)

  • Hash Cond: (emp.id_categoria_empresa = empresas_categorias.id_categoria_empresa)
6. 93.362 544.256 ↓ 1.0 49,997 1

Hash Left Join (cost=2,987.47..11,163.70 rows=49,893 width=827) (actual time=104.657..544.256 rows=49,997 loops=1)

  • Hash Cond: (emp.type = empresas_types.id)
7. 277.565 450.838 ↓ 1.0 49,997 1

Hash Join (cost=2,985.79..10,476.00 rows=49,893 width=311) (actual time=104.580..450.838 rows=49,997 loops=1)

  • Hash Cond: (empresas_sucursales.empresa_id = emp.id)
8. 69.194 69.194 ↓ 1.0 49,999 1

Seq Scan on empresas_sucursales (cost=0.00..2,594.31 rows=49,896 width=237) (actual time=0.034..69.194 rows=49,999 loops=1)

  • Filter: (type = 1)
  • Rows Removed by Filter: 5625
9. 51.239 104.079 ↓ 1.0 49,859 1

Hash (cost=1,680.57..1,680.57 rows=49,858 width=82) (actual time=104.079..104.079 rows=49,859 loops=1)

  • Buckets: 1024 Batches: 8 Memory Usage: 713kB
10. 52.840 52.840 ↓ 1.0 49,859 1

Seq Scan on empresas emp (cost=0.00..1,680.57 rows=49,858 width=82) (actual time=0.020..52.840 rows=49,859 loops=1)

  • Filter: (((document)::text <> '0'::text) AND ((document)::text <> ''::text) AND ((document)::text <> '-'::text))
  • Rows Removed by Filter: 2
11. 0.022 0.056 ↑ 1.0 30 1

Hash (cost=1.30..1.30 rows=30 width=524) (actual time=0.056..0.056 rows=30 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 2kB
12. 0.034 0.034 ↑ 1.0 30 1

Seq Scan on empresas_types (cost=0.00..1.30 rows=30 width=524) (actual time=0.018..0.034 rows=30 loops=1)

13. 0.005 0.020 ↑ 1.0 4 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
14. 0.015 0.015 ↑ 1.0 4 1

Seq Scan on empresas_categorias (cost=0.00..1.04 rows=4 width=520) (actual time=0.013..0.015 rows=4 loops=1)

15. 0.174 0.348 ↑ 1.0 251 1

Hash (cost=5.51..5.51 rows=251 width=40) (actual time=0.348..0.348 rows=251 loops=1)

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

Seq Scan on city (cost=0.00..5.51 rows=251 width=40) (actual time=0.004..0.174 rows=251 loops=1)

17. 0.013 0.039 ↑ 1.0 18 1

Hash (cost=1.18..1.18 rows=18 width=40) (actual time=0.039..0.039 rows=18 loops=1)

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

Seq Scan on distritos (cost=0.00..1.18 rows=18 width=40) (actual time=0.016..0.026 rows=18 loops=1)

19. 0.469 0.930 ↑ 1.0 701 1

Hash (cost=16.01..16.01 rows=701 width=58) (actual time=0.930..0.930 rows=701 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 64kB
20. 0.461 0.461 ↑ 1.0 701 1

Seq Scan on actividad_econ (cost=0.00..16.01 rows=701 width=58) (actual time=0.006..0.461 rows=701 loops=1)

21. 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
22. 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.013..0.013 rows=1 loops=1)

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

SubPlan (forHash Left Join)

24. 499.970 43,697.378 ↑ 1.0 1 49,997

Aggregate (cost=1,859.35..1,859.36 rows=1 width=8) (actual time=0.873..0.874 rows=1 loops=49,997)

25. 1,049.937 43,197.408 ↑ 5.9 10 49,997

Nested Loop (cost=5.61..1,859.21 rows=59 width=8) (actual time=0.127..0.864 rows=10 loops=49,997)

26. 449.973 449.973 ↑ 1.0 1 49,997

Index Only Scan using empresas_sucursales_nro_patronal_key on empresas_sucursales es (cost=0.29..8.31 rows=1 width=4) (actual time=0.008..0.009 rows=1 loops=49,997)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 49997
27. 8,775.549 41,697.498 ↑ 5.9 10 49,997

Bitmap Heap Scan on empleados (cost=5.32..1,850.31 rows=59 width=24) (actual time=0.110..0.834 rows=10 loops=49,997)

  • Recheck Cond: (npatronal = empresas_sucursales.nro_patronal)
  • Filter: (SubPlan 1)
  • Rows Removed by Filter: 12
28. 899.946 899.946 ↑ 5.3 22 49,997

Bitmap Index Scan on empleados_npatronal_id_idx (cost=0.00..5.30 rows=117 width=0) (actual time=0.018..0.018 rows=22 loops=49,997)

  • Index Cond: (npatronal = empresas_sucursales.nro_patronal)
29.          

SubPlan (forBitmap Heap Scan)

30. 3,312.621 32,022.003 ↑ 1.0 1 1,104,207

Limit (cost=12.06..12.06 rows=1 width=20) (actual time=0.029..0.029 rows=1 loops=1,104,207)

31. 5,521.035 28,709.382 ↑ 2.0 1 1,104,207

Sort (cost=12.06..12.06 rows=2 width=20) (actual time=0.026..0.026 rows=1 loops=1,104,207)

  • Sort Key: empleados_movimientos.fecha, empleados_movimientos.id
  • Sort Method: top-N heapsort Memory: 25kB
32. 4,421.282 23,188.347 ↑ 1.0 2 1,104,207

Result (cost=0.00..12.05 rows=2 width=20) (actual time=0.015..0.021 rows=2 loops=1,104,207)

  • One-Time Filter: (empleados.empresa_id = emp.id)
33. 18,767.065 18,767.065 ↑ 1.0 2 1,103,945

Index Scan using empleados_movimientos_empleado_id_idx on empleados_movimientos (cost=0.00..12.04 rows=2 width=20) (actual time=0.012..0.017 rows=2 loops=1,103,945)

  • Index Cond: (empleado_id = empleados.id)
  • Rows Removed by Index Recheck: 0
34. 599.964 23,548.587 ↑ 1.0 1 49,997

Aggregate (cost=1,696.68..1,696.71 rows=1 width=16) (actual time=0.470..0.471 rows=1 loops=49,997)

35. 3,946.227 22,948.623 ↑ 5.8 12 49,997

Index Only Scan using empleados_empresa_id_id_idx on empleados emplea (cost=0.43..1,695.28 rows=70 width=16) (actual time=0.046..0.459 rows=12 loops=49,997)

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

SubPlan (forIndex Only Scan)

37. 4,071.942 19,002.396 ↑ 1.0 1 1,357,314

Limit (cost=12.06..12.06 rows=1 width=20) (actual time=0.014..0.014 rows=1 loops=1,357,314)

38. 5,429.256 14,930.454 ↑ 2.0 1 1,357,314

Sort (cost=12.06..12.06 rows=2 width=20) (actual time=0.011..0.011 rows=1 loops=1,357,314)

  • Sort Key: empleados_movimientos_1.fecha, empleados_movimientos_1.id
  • Sort Method: quicksort Memory: 25kB
39. 9,501.198 9,501.198 ↑ 1.0 2 1,357,314

Index Scan using empleados_movimientos_empleado_id_idx on empleados_movimientos empleados_movimientos_1 (cost=0.00..12.05 rows=2 width=20) (actual time=0.005..0.007 rows=2 loops=1,357,314)

  • Index Cond: (empleado_id = emplea.id)
  • Rows Removed by Index Recheck: 0
40. 399.976 37,347.759 ↑ 1.0 1 49,997

Aggregate (cost=2,333.02..2,333.03 rows=1 width=8) (actual time=0.746..0.747 rows=1 loops=49,997)

41. 599.964 36,947.783 ↑ 6.5 6 49,997

Nested Loop (cost=5.61..2,332.92 rows=39 width=8) (actual time=0.099..0.739 rows=6 loops=49,997)

42. 199.988 199.988 ↑ 1.0 1 49,997

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

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 49997
43. 2,245.074 36,147.831 ↑ 6.5 6 49,997

Nested Loop (cost=5.32..2,324.23 rows=39 width=16) (actual time=0.091..0.723 rows=6 loops=49,997)

44. 4,081.383 22,048.677 ↑ 5.9 10 49,997

Bitmap Heap Scan on empleados empleados_1 (cost=5.32..1,850.31 rows=59 width=24) (actual time=0.044..0.441 rows=10 loops=49,997)

  • Recheck Cond: (npatronal = empresas_sucursales.nro_patronal)
  • Filter: (SubPlan 5)
  • Rows Removed by Filter: 12
45. 299.982 299.982 ↑ 5.3 22 49,997

Bitmap Index Scan on empleados_npatronal_id_idx (cost=0.00..5.30 rows=117 width=0) (actual time=0.006..0.006 rows=22 loops=49,997)

  • Index Cond: (npatronal = empresas_sucursales.nro_patronal)
46.          

SubPlan (forBitmap Heap Scan)

47. 2,208.414 17,667.312 ↑ 1.0 1 1,104,207

Limit (cost=12.06..12.06 rows=1 width=20) (actual time=0.016..0.016 rows=1 loops=1,104,207)

48. 5,521.035 15,458.898 ↑ 2.0 1 1,104,207

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

  • Sort Key: empleados_movimientos_2.fecha, empleados_movimientos_2.id
  • Sort Method: top-N heapsort Memory: 25kB
49. 4,418.138 9,937.863 ↑ 1.0 2 1,104,207

Result (cost=0.00..12.05 rows=2 width=20) (actual time=0.006..0.009 rows=2 loops=1,104,207)

  • One-Time Filter: (empleados_1.empresa_id = emp.id)
50. 5,519.725 5,519.725 ↑ 1.0 2 1,103,945

Index Scan using empleados_movimientos_empleado_id_idx on empleados_movimientos empleados_movimientos_2 (cost=0.00..12.04 rows=2 width=20) (actual time=0.003..0.005 rows=2 loops=1,103,945)

  • Index Cond: (empleado_id = empleados_1.id)
  • Rows Removed by Index Recheck: 0
51. 11,854.080 11,854.080 ↑ 1.0 1 493,920

Index Scan using persons_id_idx on persons (cost=0.00..8.02 rows=1 width=8) (actual time=0.024..0.024 rows=1 loops=493,920)

  • Index Cond: (id = empleados_1.persona_id)
  • Rows Removed by Index Recheck: 0
  • Filter: ((sexo)::text = 'M'::text)
  • Rows Removed by Filter: 0
52. 249.985 25,798.452 ↑ 1.0 1 49,997

Aggregate (cost=2,332.78..2,332.79 rows=1 width=8) (actual time=0.516..0.516 rows=1 loops=49,997)

53. 449.973 25,548.467 ↑ 6.7 3 49,997

Nested Loop (cost=5.61..2,332.73 rows=20 width=8) (actual time=0.114..0.511 rows=3 loops=49,997)

54. 199.988 199.988 ↑ 1.0 1 49,997

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

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 49997
55. 1,624.104 24,898.506 ↑ 6.7 3 49,997

Nested Loop (cost=5.32..2,324.23 rows=20 width=16) (actual time=0.106..0.498 rows=3 loops=49,997)

56. 3,381.425 21,298.722 ↑ 5.9 10 49,997

Bitmap Heap Scan on empleados empleados_2 (cost=5.32..1,850.31 rows=59 width=24) (actual time=0.044..0.426 rows=10 loops=49,997)

  • Recheck Cond: (npatronal = empresas_sucursales.nro_patronal)
  • Filter: (SubPlan 7)
  • Rows Removed by Filter: 12
57. 249.985 249.985 ↑ 5.3 22 49,997

Bitmap Index Scan on empleados_npatronal_id_idx (cost=0.00..5.30 rows=117 width=0) (actual time=0.005..0.005 rows=22 loops=49,997)

  • Index Cond: (npatronal = empresas_sucursales.nro_patronal)
58.          

SubPlan (forBitmap Heap Scan)

59. 3,312.621 17,667.312 ↑ 1.0 1 1,104,207

Limit (cost=12.06..12.06 rows=1 width=20) (actual time=0.016..0.016 rows=1 loops=1,104,207)

60. 4,416.828 14,354.691 ↑ 2.0 1 1,104,207

Sort (cost=12.06..12.06 rows=2 width=20) (actual time=0.013..0.013 rows=1 loops=1,104,207)

  • Sort Key: empleados_movimientos_3.fecha, empleados_movimientos_3.id
  • Sort Method: top-N heapsort Memory: 25kB
61. 4,418.138 9,937.863 ↑ 1.0 2 1,104,207

Result (cost=0.00..12.05 rows=2 width=20) (actual time=0.006..0.009 rows=2 loops=1,104,207)

  • One-Time Filter: (empleados_2.empresa_id = emp.id)
62. 5,519.725 5,519.725 ↑ 1.0 2 1,103,945

Index Scan using empleados_movimientos_empleado_id_idx on empleados_movimientos empleados_movimientos_3 (cost=0.00..12.04 rows=2 width=20) (actual time=0.003..0.005 rows=2 loops=1,103,945)

  • Index Cond: (empleado_id = empleados_2.id)
  • Rows Removed by Index Recheck: 0
63. 1,975.680 1,975.680 ↓ 0.0 0 493,920

Index Scan using persons_id_idx on persons persons_1 (cost=0.00..8.02 rows=1 width=8) (actual time=0.004..0.004 rows=0 loops=493,920)

  • Index Cond: (id = empleados_2.persona_id)
  • Rows Removed by Index Recheck: 0
  • Filter: ((sexo)::text = 'F'::text)
  • Rows Removed by Filter: 1
64. 199.988 3,249.805 ↑ 1.0 1 49,997

Limit (cost=12.92..12.93 rows=1 width=134) (actual time=0.064..0.065 rows=1 loops=49,997)

65. 549.967 3,049.817 ↑ 2.0 1 49,997

Sort (cost=12.92..12.93 rows=2 width=134) (actual time=0.061..0.061 rows=1 loops=49,997)

  • Sort Key: cambio_situacion_empresa.fecha_creacion, cambio_situacion_empresa.id_cambio_situacion_empresa
  • Sort Method: quicksort Memory: 25kB
66. 497.628 2,499.850 ↑ 2.0 1 49,997

Hash Join (cost=11.79..12.91 rows=2 width=134) (actual time=0.047..0.050 rows=1 loops=49,997)

  • Hash Cond: (situacion_emp.id_situacion = cambio_situacion_empresa.situacion_act)
67. 202.330 202.330 ↑ 1.0 7 40,466

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

68. 349.979 1,799.892 ↑ 2.0 1 49,997

Hash (cost=11.76..11.76 rows=2 width=20) (actual time=0.036..0.036 rows=1 loops=49,997)

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
69. 899.946 1,449.913 ↑ 2.0 1 49,997

Bitmap Heap Scan on cambio_situacion_empresa (cost=4.02..11.76 rows=2 width=20) (actual time=0.024..0.029 rows=1 loops=49,997)

  • Recheck Cond: (nro_patronal = empresas_sucursales.nro_patronal)
70. 549.967 549.967 ↑ 2.0 1 49,997

Bitmap Index Scan on cambio_situacion_empresa_nro_patronal_idx (cost=0.00..4.01 rows=2 width=0) (actual time=0.011..0.011 rows=1 loops=49,997)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)