explain.depesz.com

PostgreSQL's explain analyze made readable

Result: EbOZ

Settings
# exclusive inclusive rows x rows loops node
1. 914.984 148,409.383 ↓ 1.0 49,997 1

Hash Left Join (cost=3,024.43..432,575,521.23 rows=49,893 width=1,489) (actual time=100.165..148,409.383 rows=49,997 loops=1)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Seq Scan on empresas emp (cost=0.00..1,680.57 rows=49,858 width=82) (actual time=0.559..49.877 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.023 0.062 ↑ 1.0 30 1

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

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

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

13. 0.005 0.021 ↑ 1.0 4 1

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

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

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

15. 0.170 0.347 ↑ 1.0 251 1

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

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

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

17. 0.013 0.037 ↑ 1.0 18 1

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

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

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

19. 0.475 0.997 ↑ 1.0 701 1

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

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

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

21. 0.003 0.020 ↑ 1.0 1 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
22. 0.017 0.017 ↑ 1.0 1 1

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

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

SubPlan (forHash Left Join)

24. 499.970 47,647.141 ↑ 1.0 1 49,997

Aggregate (cost=1,843.72..1,843.73 rows=1 width=8) (actual time=0.953..0.953 rows=1 loops=49,997)

25. 1,099.934 47,147.171 ↑ 5.8 10 49,997

Nested Loop (cost=5.60..1,843.57 rows=58 width=8) (actual time=0.165..0.943 rows=10 loops=49,997)

26. 499.970 499.970 ↑ 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.009..0.010 rows=1 loops=49,997)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 49997
27. 8,866.997 45,547.267 ↑ 5.8 10 49,997

Bitmap Heap Scan on empleados (cost=5.31..1,834.68 rows=58 width=24) (actual time=0.146..0.911 rows=10 loops=49,997)

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

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

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

SubPlan (forBitmap Heap Scan)

30. 3,312.621 34,230.417 ↑ 1.0 1 1,104,207

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

31. 5,521.035 30,917.796 ↑ 2.0 1 1,104,207

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

  • Sort Key: empleados_movimientos.fecha, empleados_movimientos.id
  • Sort Method: top-N heapsort Memory: 25kB
32. 5,525.751 25,396.761 ↑ 1.0 2 1,104,207

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

  • One-Time Filter: (empleados.empresa_id = emp.id)
33. 19,871.010 19,871.010 ↑ 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.013..0.018 rows=2 loops=1,103,945)

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

Aggregate (cost=2,194.60..2,194.63 rows=1 width=16) (actual time=0.573..0.574 rows=1 loops=49,997)

35. 5,138.760 27,848.329 ↑ 5.8 12 49,997

Bitmap Heap Scan on empleados emplea (cost=5.49..2,193.22 rows=69 width=16) (actual time=0.084..0.557 rows=12 loops=49,997)

  • Recheck Cond: (empresa_id = emp.id)
  • Filter: (SubPlan 3)
  • Rows Removed by Filter: 15
36. 2,349.859 2,349.859 ↑ 5.1 27 49,997

Bitmap Index Scan on empleados_empresa_id_id_idx (cost=0.00..5.47 rows=139 width=0) (actual time=0.047..0.047 rows=27 loops=49,997)

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

SubPlan (forBitmap Heap Scan)

38. 4,071.942 20,359.710 ↑ 1.0 1 1,357,314

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

39. 6,786.570 16,287.768 ↑ 2.0 1 1,357,314

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

  • Sort Key: empleados_movimientos_1.fecha, empleados_movimientos_1.id
  • Sort Method: top-N heapsort Memory: 25kB
40. 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
41. 399.976 39,547.627 ↑ 1.0 1 49,997

Aggregate (cost=2,309.35..2,309.36 rows=1 width=8) (actual time=0.791..0.791 rows=1 loops=49,997)

42. 599.964 39,147.651 ↑ 6.3 6 49,997

Nested Loop (cost=5.60..2,309.26 rows=38 width=8) (actual time=0.105..0.783 rows=6 loops=49,997)

43. 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
44. 2,157.180 38,297.702 ↑ 6.3 6 49,997

Nested Loop (cost=5.31..2,300.57 rows=38 width=16) (actual time=0.096..0.766 rows=6 loops=49,997)

45. 4,227.101 23,298.602 ↑ 5.8 10 49,997

Bitmap Heap Scan on empleados empleados_1 (cost=5.31..1,834.68 rows=58 width=24) (actual time=0.046..0.466 rows=10 loops=49,997)

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

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

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

SubPlan (forBitmap Heap Scan)

48. 2,208.414 18,771.519 ↑ 1.0 1 1,104,207

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

49. 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_2.fecha, empleados_movimientos_2.id
  • Sort Method: top-N heapsort Memory: 25kB
50. 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_1.empresa_id = emp.id)
51. 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
52. 12,841.920 12,841.920 ↑ 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.026..0.026 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
53. 299.982 27,098.374 ↑ 1.0 1 49,997

Aggregate (cost=2,309.13..2,309.14 rows=1 width=8) (actual time=0.542..0.542 rows=1 loops=49,997)

54. 449.973 26,798.392 ↑ 6.7 3 49,997

Nested Loop (cost=5.60..2,309.08 rows=20 width=8) (actual time=0.120..0.536 rows=3 loops=49,997)

55. 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
56. 1,874.089 26,148.431 ↑ 6.7 3 49,997

Nested Loop (cost=5.31..2,300.57 rows=20 width=16) (actual time=0.112..0.523 rows=3 loops=49,997)

57. 3,227.161 22,298.662 ↑ 5.8 10 49,997

Bitmap Heap Scan on empleados empleados_2 (cost=5.31..1,834.68 rows=58 width=24) (actual time=0.046..0.446 rows=10 loops=49,997)

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

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

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

SubPlan (forBitmap Heap Scan)

60. 3,312.621 18,771.519 ↑ 1.0 1 1,104,207

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

61. 4,416.828 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_3.fecha, empleados_movimientos_3.id
  • Sort Method: top-N heapsort Memory: 25kB
62. 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)
63. 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
64. 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
65. 149.991 3,499.790 ↑ 1.0 1 49,997

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

66. 599.964 3,349.799 ↑ 2.0 1 49,997

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

  • Sort Key: cambio_situacion_empresa.fecha_creacion, cambio_situacion_empresa.id_cambio_situacion_empresa
  • Sort Method: quicksort Memory: 25kB
67. 557.156 2,749.835 ↑ 2.0 1 49,997

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

  • Hash Cond: (situacion_emp.id_situacion = cambio_situacion_empresa.situacion_act)
68. 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)

69. 349.979 1,949.883 ↑ 2.0 1 49,997

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

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

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

  • Recheck Cond: (nro_patronal = empresas_sucursales.nro_patronal)
71. 599.964 599.964 ↑ 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.012..0.012 rows=1 loops=49,997)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)