explain.depesz.com

PostgreSQL's explain analyze made readable

Result: twW2

Settings
# exclusive inclusive rows x rows loops node
1. 542.082 110,948.513 ↓ 1.2 49,967 1

Nested Loop (cost=3,591.85..258,450,001.56 rows=41,977 width=964) (actual time=181.688..110,948.513 rows=49,967 loops=1)

2. 0.041 0.041 ↑ 1.0 1 1

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

  • Filter: (id = 1)
  • Rows Removed by Filter: 2
3. 114.692 878.726 ↓ 1.2 49,967 1

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Seq Scan on empresas emp (cost=0.00..2,410.94 rows=49,822 width=82) (actual time=0.011..55.641 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.033 0.063 ↓ 1.2 30 1

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

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

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

14. 0.004 0.031 ↑ 35.0 4 1

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

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

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

16. 0.201 0.455 ↑ 1.1 251 1

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

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

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

18. 0.014 0.032 ↑ 1.2 18 1

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

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

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

20. 0.623 1.306 ↑ 1.0 700 1

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

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

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

22.          

SubPlan (forNested Loop)

23. 549.637 30,579.804 ↑ 1.0 1 49,967

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

24. 1,049.307 30,030.167 ↑ 5.8 10 49,967

Nested Loop (cost=4.17..1,393.46 rows=58 width=8) (actual time=0.079..0.601 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,856.874 28,731.025 ↑ 5.8 10 49,967

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

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

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

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

SubPlan (forBitmap Heap Scan)

29. 2,207.106 23,174.613 ↑ 1.0 1 1,103,553

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

30. 5,517.765 20,967.507 ↑ 2.0 1 1,103,553

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

  • Sort Key: empleados_movimientos.fecha, empleados_movimientos.id
  • Sort Method: quicksort Memory: 25kB
31. 5,520.123 15,449.742 ↑ 1.0 2 1,103,553

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

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

Index Scan using empleados_movimientos_empleado_id_idx on empleados_movimientos (cost=0.00..9.04 rows=2 width=20) (actual time=0.007..0.009 rows=2 loops=1,103,291)

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

Aggregate (cost=1,269.60..1,269.63 rows=1 width=16) (actual time=0.444..0.445 rows=1 loops=49,967)

34. 3,852.272 21,485.810 ↑ 5.8 12 49,967

Index Only Scan using empleados_empresa_id_id_idx on empleados emplea (cost=0.43..1,268.20 rows=70 width=16) (actual time=0.037..0.430 rows=12 loops=49,967)

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

SubPlan (forIndex Only Scan)

36. 2,712.852 17,633.538 ↑ 1.0 1 1,356,426

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

37. 6,782.130 14,920.686 ↑ 2.0 1 1,356,426

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

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

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

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

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

40. 649.571 27,831.619 ↑ 6.3 6 49,967

Nested Loop (cost=4.17..1,743.15 rows=38 width=8) (actual time=0.074..0.557 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. 1,880.981 26,982.180 ↑ 6.3 6 49,967

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

43. 3,075.178 22,135.381 ↑ 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.443 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.106 18,760.401 ↑ 1.0 1 1,103,553

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

47. 5,517.765 16,553.295 ↑ 2.0 1 1,103,553

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

  • Sort Key: empleados_movimientos_2.fecha, empleados_movimientos_2.id
  • Sort Method: quicksort Memory: 25kB
48. 5,519.075 11,035.530 ↑ 1.0 2 1,103,553

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

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

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

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

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

  • 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,532.477 ↑ 1.0 1 49,967

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

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

Nested Loop (cost=4.17..1,742.97 rows=20 width=8) (actual time=0.113..0.525 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,620.412 25,633.071 ↑ 6.7 3 49,967

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

55. 3,025.211 22,035.447 ↑ 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.441 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.106 18,760.401 ↑ 1.0 1 1,103,553

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

59. 5,517.765 16,553.295 ↑ 2.0 1 1,103,553

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

  • Sort Key: empleados_movimientos_3.fecha, empleados_movimientos_3.id
  • Sort Method: quicksort Memory: 25kB
60. 5,519.075 11,035.530 ↑ 1.0 2 1,103,553

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

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

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

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

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

  • 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,898.746 ↑ 1.0 1 49,967

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

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

Sort (cost=7.19..7.19 rows=1 width=134) (actual time=0.035..0.035 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. 617.595 1,548.977 ↑ 1.0 1 49,967

Nested Loop (cost=0.00..7.18 rows=1 width=134) (actual time=0.019..0.031 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.008..0.011 rows=1 loops=49,967)

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

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