explain.depesz.com

PostgreSQL's explain analyze made readable

Result: OgJI

Settings
# exclusive inclusive rows x rows loops node
1. 555.048 112,433.498 ↓ 1.2 49,967 1

Nested Loop (cost=3,591.85..258,575,607.13 rows=41,977 width=964) (actual time=263.571..112,433.498 rows=49,967 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. 112.170 951.679 ↓ 1.2 49,967 1

Hash Left Join (cost=3,591.85..8,952.96 rows=41,977 width=940) (actual time=263.108..951.679 rows=49,967 loops=1)

  • Hash Cond: (empresas_sucursales.id_activ_econ = actividad_econ.id_activ_econ)
4. 95.514 837.870 ↓ 1.2 49,967 1

Hash Left Join (cost=3,567.10..8,351.02 rows=41,977 width=886) (actual time=261.438..837.870 rows=49,967 loops=1)

  • Hash Cond: (empresas_sucursales.distrito_id = distritos.id)
5. 104.340 742.306 ↓ 1.2 49,967 1

Hash Left Join (cost=3,565.63..7,772.69 rows=41,977 width=876) (actual time=261.359..742.306 rows=49,967 loops=1)

  • Hash Cond: (empresas_sucursales.city_id = city.id)
6. 86.226 637.403 ↓ 1.2 49,967 1

Hash Left Join (cost=3,552.69..7,184.77 rows=41,977 width=840) (actual time=260.766..637.403 rows=49,967 loops=1)

  • Hash Cond: (emp.id_categoria_empresa = empresas_categorias.id_categoria_empresa)
7. 198.222 551.132 ↓ 1.2 49,967 1

Hash Join (cost=3,539.54..7,010.10 rows=41,977 width=324) (actual time=260.683..551.132 rows=49,967 loops=1)

  • Hash Cond: (empresas_sucursales.empresa_id = emp.id)
8. 92.368 92.368 ↑ 1.0 49,969 1

Seq Scan on empresas_sucursales (cost=0.00..2,612.82 rows=50,053 width=237) (actual time=0.016..92.368 rows=49,969 loops=1)

  • Filter: (type = 1)
  • Rows Removed by Filter: 5621
9. 76.368 260.542 ↓ 1.2 49,828 1

Hash (cost=3,017.22..3,017.22 rows=41,786 width=95) (actual time=260.542..260.542 rows=49,828 loops=1)

  • Buckets: 8192 Batches: 1 Memory Usage: 5999kB
10. 93.668 184.174 ↓ 1.2 49,828 1

Hash Join (cost=1.58..3,017.22 rows=41,786 width=95) (actual time=0.116..184.174 rows=49,828 loops=1)

  • Hash Cond: (emp.type = empresas_types.id)
11. 90.428 90.428 ↓ 1.0 49,828 1

Seq Scan on empresas emp (cost=0.00..2,410.94 rows=49,822 width=82) (actual time=0.024..90.428 rows=49,828 loops=1)

  • Filter: (((document)::text <> '0'::text) AND ((document)::text <> ''::text) AND ((document)::text <> '-'::text))
  • Rows Removed by Filter: 2
12. 0.037 0.078 ↓ 1.2 30 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 2kB
13. 0.041 0.041 ↓ 1.2 30 1

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

14. 0.007 0.045 ↑ 35.0 4 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
15. 0.038 0.038 ↑ 35.0 4 1

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

16. 0.301 0.563 ↑ 1.1 251 1

Hash (cost=9.64..9.64 rows=264 width=40) (actual time=0.563..0.563 rows=251 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 19kB
17. 0.262 0.262 ↑ 1.1 251 1

Seq Scan on city (cost=0.00..9.64 rows=264 width=40) (actual time=0.008..0.262 rows=251 loops=1)

18. 0.025 0.050 ↑ 1.2 18 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
19. 0.025 0.025 ↑ 1.2 18 1

Seq Scan on distritos (cost=0.00..1.21 rows=21 width=18) (actual time=0.009..0.025 rows=18 loops=1)

20. 0.883 1.639 ↑ 1.0 700 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 63kB
21. 0.756 0.756 ↑ 1.0 700 1

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

22.          

SubPlan (forNested Loop)

23. 599.604 30,929.573 ↑ 1.0 1 49,967

Aggregate (cost=1,393.61..1,393.62 rows=1 width=8) (actual time=0.618..0.619 rows=1 loops=49,967)

24. 999.340 30,329.969 ↑ 5.8 10 49,967

Nested Loop (cost=4.17..1,393.46 rows=58 width=8) (actual time=0.082..0.607 rows=10 loops=49,967)

25. 249.835 249.835 ↑ 1.0 1 49,967

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

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 171
26. 4,052.969 29,080.794 ↑ 5.8 10 49,967

Bitmap Heap Scan on empleados (cost=3.88..1,389.58 rows=58 width=24) (actual time=0.073..0.582 rows=10 loops=49,967)

  • Recheck Cond: (npatronal = empresas_sucursales.nro_patronal)
  • Filter: (SubPlan 1)
  • Rows Removed by Filter: 12
27. 749.505 749.505 ↑ 5.3 22 49,967

Bitmap Index Scan on empleados_npatronal_idx (cost=0.00..3.87 rows=116 width=0) (actual time=0.015..0.015 rows=22 loops=49,967)

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

SubPlan (forBitmap Heap Scan)

29. 3,310.680 24,278.320 ↑ 1.0 1 1,103,560

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

30. 4,414.240 20,967.640 ↑ 2.0 1 1,103,560

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

  • Sort Key: empleados_movimientos.fecha, empleados_movimientos.id
  • Sort Method: quicksort Memory: 25kB
31. 6,623.718 16,553.400 ↑ 1.0 2 1,103,560

Result (cost=0.00..9.05 rows=2 width=20) (actual time=0.009..0.015 rows=2 loops=1,103,560)

  • One-Time Filter: (empleados.empresa_id = emp.id)
32. 9,929.682 9,929.682 ↑ 1.0 2 1,103,298

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.009 rows=2 loops=1,103,298)

  • Index Cond: (empleado_id = empleados.id)
  • Rows Removed by Index Recheck: 0
33. 699.538 22,535.117 ↑ 1.0 1 49,967

Aggregate (cost=1,272.59..1,272.62 rows=1 width=16) (actual time=0.451..0.451 rows=1 loops=49,967)

34. 2,845.475 21,835.579 ↑ 5.8 12 49,967

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.038..0.437 rows=12 loops=49,967)

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

SubPlan (forIndex Only Scan)

36. 2,712.872 18,990.104 ↑ 1.0 1 1,356,436

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

37. 8,138.616 16,277.232 ↑ 2.0 1 1,356,436

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

  • Sort Key: empleados_movimientos_1.fecha, empleados_movimientos_1.id
  • Sort Method: quicksort Memory: 25kB
38. 8,138.616 8,138.616 ↑ 1.0 2 1,356,436

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.004..0.006 rows=2 loops=1,356,436)

  • Index Cond: (empleado_id = emplea.id)
  • Rows Removed by Index Recheck: 0
39. 449.703 28,581.124 ↑ 1.0 1 49,967

Aggregate (cost=1,743.24..1,743.25 rows=1 width=8) (actual time=0.571..0.572 rows=1 loops=49,967)

40. 649.571 28,131.421 ↑ 6.3 6 49,967

Nested Loop (cost=4.17..1,743.15 rows=38 width=8) (actual time=0.075..0.563 rows=6 loops=49,967)

41. 199.868 199.868 ↑ 1.0 1 49,967

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

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 171
42. 2,030.894 27,281.982 ↑ 6.3 6 49,967

Nested Loop (cost=3.88..1,739.46 rows=38 width=16) (actual time=0.069..0.546 rows=6 loops=49,967)

43. 3,224.960 22,285.282 ↑ 5.8 10 49,967

Bitmap Heap Scan on empleados empleados_1 (cost=3.88..1,389.58 rows=58 width=24) (actual time=0.046..0.446 rows=10 loops=49,967)

  • Recheck Cond: (npatronal = empresas_sucursales.nro_patronal)
  • Filter: (SubPlan 5)
  • Rows Removed by Filter: 12
44. 299.802 299.802 ↑ 5.3 22 49,967

Bitmap Index Scan on empleados_npatronal_idx (cost=0.00..3.87 rows=116 width=0) (actual time=0.006..0.006 rows=22 loops=49,967)

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

SubPlan (forBitmap Heap Scan)

46. 2,207.120 18,760.520 ↑ 1.0 1 1,103,560

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

47. 5,517.800 16,553.400 ↑ 2.0 1 1,103,560

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

  • Sort Key: empleados_movimientos_2.fecha, empleados_movimientos_2.id
  • Sort Method: quicksort Memory: 25kB
48. 5,519.110 11,035.600 ↑ 1.0 2 1,103,560

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

  • One-Time Filter: (empleados_1.empresa_id = emp.id)
49. 5,516.490 5,516.490 ↑ 1.0 2 1,103,298

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.003..0.005 rows=2 loops=1,103,298)

  • Index Cond: (empleado_id = empleados_1.id)
  • Rows Removed by Index Recheck: 0
50. 2,965.806 2,965.806 ↑ 1.0 1 494,301

Index Scan using persons_id_idx on persons (cost=0.00..6.02 rows=1 width=8) (actual time=0.006..0.006 rows=1 loops=494,301)

  • Index Cond: (id = empleados_1.persona_id)
  • Rows Removed by Index Recheck: 0
  • Filter: ((sexo)::text = 'M'::text)
  • Rows Removed by Filter: 0
51. 299.802 26,932.213 ↑ 1.0 1 49,967

Aggregate (cost=1,743.02..1,743.03 rows=1 width=8) (actual time=0.538..0.539 rows=1 loops=49,967)

52. 399.736 26,632.411 ↑ 6.7 3 49,967

Nested Loop (cost=4.17..1,742.97 rows=20 width=8) (actual time=0.114..0.533 rows=3 loops=49,967)

53. 199.868 199.868 ↑ 1.0 1 49,967

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

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 171
54. 1,770.321 26,032.807 ↑ 6.7 3 49,967

Nested Loop (cost=3.88..1,739.46 rows=20 width=16) (actual time=0.108..0.521 rows=3 loops=49,967)

55. 3,274.927 22,285.282 ↑ 5.8 10 49,967

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

  • Recheck Cond: (npatronal = empresas_sucursales.nro_patronal)
  • Filter: (SubPlan 7)
  • Rows Removed by Filter: 12
56. 249.835 249.835 ↑ 5.3 22 49,967

Bitmap Index Scan on empleados_npatronal_idx (cost=0.00..3.87 rows=116 width=0) (actual time=0.005..0.005 rows=22 loops=49,967)

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

SubPlan (forBitmap Heap Scan)

58. 2,207.120 18,760.520 ↑ 1.0 1 1,103,560

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

59. 4,414.240 16,553.400 ↑ 2.0 1 1,103,560

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

  • Sort Key: empleados_movimientos_3.fecha, empleados_movimientos_3.id
  • Sort Method: quicksort Memory: 25kB
60. 6,622.670 12,139.160 ↑ 1.0 2 1,103,560

Result (cost=0.00..9.05 rows=2 width=20) (actual time=0.006..0.011 rows=2 loops=1,103,560)

  • One-Time Filter: (empleados_2.empresa_id = emp.id)
61. 5,516.490 5,516.490 ↑ 1.0 2 1,103,298

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.003..0.005 rows=2 loops=1,103,298)

  • Index Cond: (empleado_id = empleados_2.id)
  • Rows Removed by Index Recheck: 0
62. 1,977.204 1,977.204 ↓ 0.0 0 494,301

Index Scan using persons_id_idx on persons persons_1 (cost=0.00..6.02 rows=1 width=8) (actual time=0.004..0.004 rows=0 loops=494,301)

  • Index Cond: (id = empleados_2.persona_id)
  • Rows Removed by Index Recheck: 0
  • Filter: ((sexo)::text = 'F'::text)
  • Rows Removed by Filter: 1
63. 149.901 1,948.713 ↑ 1.0 1 49,967

Limit (cost=7.19..7.19 rows=1 width=134) (actual time=0.038..0.039 rows=1 loops=49,967)

64. 199.868 1,798.812 ↑ 1.0 1 49,967

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

  • Sort Key: cambio_situacion_empresa.fecha_creacion, cambio_situacion_empresa.id_cambio_situacion_empresa
  • Sort Method: quicksort Memory: 25kB
65. 667.541 1,598.944 ↑ 1.0 1 49,967

Nested Loop (cost=0.00..7.18 rows=1 width=134) (actual time=0.020..0.032 rows=1 loops=49,967)

  • Join Filter: (cambio_situacion_empresa.situacion_act = situacion_emp.id_situacion)
  • Rows Removed by Join Filter: 7
66. 549.637 549.637 ↑ 1.0 1 49,967

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.009..0.011 rows=1 loops=49,967)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
67. 381.766 381.766 ↑ 1.0 7 54,538

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