explain.depesz.com

PostgreSQL's explain analyze made readable

Result: BsdO

Settings
# exclusive inclusive rows x rows loops node
1. 999.108 154,330.964 ↓ 1.0 49,997 1

Nested Loop (cost=3,023.38..435,692,313.41 rows=49,893 width=1,489) (actual time=98.397..154,330.964 rows=49,997 loops=1)

2. 0.031 0.031 ↑ 1.0 1 1

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

  • Filter: (id = 1)
  • Rows Removed by Filter: 2
3. 121.674 1,040.963 ↓ 1.0 49,997 1

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

  • Hash Cond: (empresas_sucursales.id_activ_econ = actividad_econ.id_activ_econ)
4. 109.086 918.370 ↓ 1.0 49,997 1

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

  • Hash Cond: (empresas_sucursales.distrito_id = distritos.id)
5. 116.955 809.249 ↓ 1.0 49,997 1

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

  • Hash Cond: (empresas_sucursales.city_id = city.id)
6. 94.975 691.958 ↓ 1.0 49,997 1

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

  • Hash Cond: (emp.id_categoria_empresa = empresas_categorias.id_categoria_empresa)
7. 111.408 596.957 ↓ 1.0 49,997 1

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

  • Hash Cond: (emp.type = empresas_types.id)
8. 319.016 485.498 ↓ 1.0 49,997 1

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

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

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

  • Filter: (type = 1)
  • Rows Removed by Filter: 5625
10. 49.098 95.875 ↓ 1.0 49,859 1

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

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

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

  • Filter: (((document)::text <> '0'::text) AND ((document)::text <> ''::text) AND ((document)::text <> '-'::text))
  • Rows Removed by Filter: 2
12. 0.021 0.051 ↑ 1.0 30 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 2kB
13. 0.030 0.030 ↑ 1.0 30 1

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

14. 0.005 0.026 ↑ 1.0 4 1

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

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

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

16. 0.167 0.336 ↑ 1.0 251 1

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

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

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

18. 0.013 0.035 ↑ 1.0 18 1

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

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

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

20. 0.471 0.919 ↑ 1.0 701 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 64kB
21. 0.448 0.448 ↑ 1.0 701 1

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

22.          

SubPlan (forNested Loop)

23. 549.967 48,747.075 ↑ 1.0 1 49,997

Aggregate (cost=1,859.34..1,859.35 rows=1 width=8) (actual time=0.975..0.975 rows=1 loops=49,997)

24. 1,149.931 48,197.108 ↑ 5.8 10 49,997

Nested Loop (cost=5.61..1,859.19 rows=58 width=8) (actual time=0.144..0.964 rows=10 loops=49,997)

25. 549.967 549.967 ↑ 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.010..0.011 rows=1 loops=49,997)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 49997
26. 10,112.649 46,497.210 ↑ 5.8 10 49,997

Bitmap Heap Scan on empleados (cost=5.32..1,850.31 rows=58 width=24) (actual time=0.123..0.930 rows=10 loops=49,997)

  • Recheck Cond: (npatronal = empresas_sucursales.nro_patronal)
  • Filter: (SubPlan 1)
  • Rows Removed by Filter: 12
27. 1,049.937 1,049.937 ↑ 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.021..0.021 rows=22 loops=49,997)

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

SubPlan (forBitmap Heap Scan)

29. 3,312.621 35,334.624 ↑ 1.0 1 1,104,207

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

30. 5,521.035 32,022.003 ↑ 2.0 1 1,104,207

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

  • Sort Key: empleados_movimientos.fecha, empleados_movimientos.id
  • Sort Method: top-N heapsort Memory: 25kB
31. 5,526.013 26,500.968 ↑ 1.0 2 1,104,207

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

  • One-Time Filter: (empleados.empresa_id = emp.id)
32. 20,974.955 20,974.955 ↑ 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.014..0.019 rows=2 loops=1,103,945)

  • Index Cond: (empleado_id = empleados.id)
  • Rows Removed by Index Recheck: 0
33. 849.949 28,998.260 ↑ 1.0 1 49,997

Aggregate (cost=2,210.20..2,210.23 rows=1 width=16) (actual time=0.580..0.580 rows=1 loops=49,997)

34. 5,181.362 28,148.311 ↑ 5.8 12 49,997

Bitmap Heap Scan on empleados emplea (cost=5.50..2,208.80 rows=70 width=16) (actual time=0.063..0.563 rows=12 loops=49,997)

  • Recheck Cond: (empresa_id = emp.id)
  • Filter: (SubPlan 3)
  • Rows Removed by Filter: 15
35. 1,249.925 1,249.925 ↑ 5.2 27 49,997

Bitmap Index Scan on empleados_empresa_id_npatronal_idx (cost=0.00..5.48 rows=140 width=0) (actual time=0.025..0.025 rows=27 loops=49,997)

  • Index Cond: (empresa_id = emp.id)
36.          

SubPlan (forBitmap Heap Scan)

37. 4,071.942 21,717.024 ↑ 1.0 1 1,357,314

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

38. 6,786.570 17,645.082 ↑ 2.0 1 1,357,314

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

  • Sort Key: empleados_movimientos_1.fecha, empleados_movimientos_1.id
  • Sort Method: top-N heapsort Memory: 25kB
39. 10,858.512 10,858.512 ↑ 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.006..0.008 rows=2 loops=1,357,314)

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

Aggregate (cost=2,324.97..2,324.98 rows=1 width=8) (actual time=0.839..0.840 rows=1 loops=49,997)

41. 699.958 41,597.504 ↑ 6.3 6 49,997

Nested Loop (cost=5.61..2,324.88 rows=38 width=8) (actual time=0.112..0.832 rows=6 loops=49,997)

42. 249.985 249.985 ↑ 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.004..0.005 rows=1 loops=49,997)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 49997
43. 2,269.274 40,647.561 ↑ 6.3 6 49,997

Nested Loop (cost=5.32..2,316.19 rows=38 width=16) (actual time=0.103..0.813 rows=6 loops=49,997)

44. 4,322.822 24,548.527 ↑ 5.8 10 49,997

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

  • Recheck Cond: (npatronal = empresas_sucursales.nro_patronal)
  • Filter: (SubPlan 5)
  • Rows Removed by Filter: 12
45. 349.979 349.979 ↑ 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.007..0.007 rows=22 loops=49,997)

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

SubPlan (forBitmap Heap Scan)

47. 3,312.621 19,875.726 ↑ 1.0 1 1,104,207

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

48. 4,416.828 16,563.105 ↑ 2.0 1 1,104,207

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

  • Sort Key: empleados_movimientos_2.fecha, empleados_movimientos_2.id
  • Sort Method: top-N heapsort Memory: 25kB
49. 5,522.607 12,146.277 ↑ 1.0 2 1,104,207

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

  • One-Time Filter: (empleados_1.empresa_id = emp.id)
50. 6,623.670 6,623.670 ↑ 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.004..0.006 rows=2 loops=1,103,945)

  • Index Cond: (empleado_id = empleados_1.id)
  • Rows Removed by Index Recheck: 0
51. 13,829.760 13,829.760 ↑ 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.027..0.028 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. 299.982 28,798.272 ↑ 1.0 1 49,997

Aggregate (cost=2,324.75..2,324.76 rows=1 width=8) (actual time=0.575..0.576 rows=1 loops=49,997)

53. 499.970 28,498.290 ↑ 6.7 3 49,997

Nested Loop (cost=5.61..2,324.70 rows=20 width=8) (actual time=0.128..0.570 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. 2,174.071 27,798.332 ↑ 6.7 3 49,997

Nested Loop (cost=5.32..2,316.19 rows=20 width=16) (actual time=0.119..0.556 rows=3 loops=49,997)

56. 3,472.873 23,648.581 ↑ 5.8 10 49,997

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

  • Recheck Cond: (npatronal = empresas_sucursales.nro_patronal)
  • Filter: (SubPlan 7)
  • Rows Removed by Filter: 12
57. 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)
58.          

SubPlan (forBitmap Heap Scan)

59. 3,312.621 19,875.726 ↑ 1.0 1 1,104,207

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

60. 5,521.035 16,563.105 ↑ 2.0 1 1,104,207

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

  • Sort Key: empleados_movimientos_3.fecha, empleados_movimientos_3.id
  • Sort Method: top-N heapsort Memory: 25kB
61. 5,522.345 11,042.070 ↑ 1.0 2 1,104,207

Result (cost=0.00..12.05 rows=2 width=20) (actual time=0.006..0.010 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.004..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. 149.991 3,749.775 ↑ 1.0 1 49,997

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

65. 699.958 3,599.784 ↑ 2.0 1 49,997

Sort (cost=12.92..12.93 rows=2 width=134) (actual time=0.072..0.072 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. 607.153 2,899.826 ↑ 2.0 1 49,997

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

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

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

68. 399.976 2,049.877 ↑ 2.0 1 49,997

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

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

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

  • Recheck Cond: (nro_patronal = empresas_sucursales.nro_patronal)
70. 649.961 649.961 ↑ 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.013..0.013 rows=1 loops=49,997)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)