explain.depesz.com

PostgreSQL's explain analyze made readable

Result: wMIH

Settings
# exclusive inclusive rows x rows loops node
1. 622.727 115,689.412 ↑ 1.0 49,965 1

Nested Loop (cost=3,087.70..308,153,920.56 rows=50,050 width=964) (actual time=122.206..115,689.412 rows=49,965 loops=1)

2. 0.027 0.027 ↑ 1.0 1 1

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

  • Filter: (id = 1)
  • Rows Removed by Filter: 2
3. 106.186 846.668 ↑ 1.0 49,965 1

Hash Left Join (cost=3,087.70..9,592.13 rows=50,050 width=940) (actual time=121.813..846.668 rows=49,965 loops=1)

  • Hash Cond: (empresas_sucursales.id_activ_econ = actividad_econ.id_activ_econ)
4. 94.628 739.158 ↑ 1.0 49,965 1

Hash Left Join (cost=3,062.95..8,879.19 rows=50,050 width=886) (actual time=120.467..739.158 rows=49,965 loops=1)

  • Hash Cond: (empresas_sucursales.distrito_id = distritos.id)
5. 99.430 644.493 ↑ 1.0 49,965 1

Hash Left Join (cost=3,061.48..8,189.91 rows=50,050 width=876) (actual time=120.415..644.493 rows=49,965 loops=1)

  • Hash Cond: (empresas_sucursales.city_id = city.id)
6. 85.182 544.549 ↑ 1.0 49,965 1

Hash Left Join (cost=3,048.54..7,491.43 rows=50,050 width=840) (actual time=119.883..544.549 rows=49,965 loops=1)

  • Hash Cond: (emp.id_categoria_empresa = empresas_categorias.id_categoria_empresa)
7. 92.468 459.342 ↑ 1.0 49,965 1

Hash Left Join (cost=3,035.39..7,285.65 rows=50,050 width=324) (actual time=119.818..459.342 rows=49,965 loops=1)

  • Hash Cond: (emp.type = empresas_types.id)
8. 153.469 366.816 ↑ 1.0 49,965 1

Hash Join (cost=3,033.80..6,647.66 rows=50,050 width=311) (actual time=119.732..366.816 rows=49,965 loops=1)

  • Hash Cond: (empresas_sucursales.empresa_id = emp.id)
9. 93.686 93.686 ↑ 1.0 49,967 1

Seq Scan on empresas_sucursales (cost=0.00..2,612.82 rows=50,053 width=237) (actual time=0.019..93.686 rows=49,967 loops=1)

  • Filter: (type = 1)
  • Rows Removed by Filter: 5621
10. 51.587 119.661 ↓ 1.0 49,826 1

Hash (cost=2,410.99..2,410.99 rows=49,825 width=82) (actual time=119.661..119.661 rows=49,826 loops=1)

  • Buckets: 8192 Batches: 1 Memory Usage: 5569kB
11. 68.074 68.074 ↓ 1.0 49,826 1

Seq Scan on empresas emp (cost=0.00..2,410.99 rows=49,825 width=82) (actual time=0.024..68.074 rows=49,826 loops=1)

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

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

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

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

14. 0.005 0.025 ↑ 35.0 4 1

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

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

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

16. 0.254 0.514 ↑ 1.1 251 1

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

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

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

18. 0.019 0.037 ↑ 1.2 18 1

Hash (cost=1.21..1.21 rows=21 width=18) (actual time=0.037..0.037 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.649 1.324 ↑ 1.0 700 1

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

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

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

22.          

SubPlan (forNested Loop)

23. 599.580 30,278.790 ↑ 1.0 1 49,965

Aggregate (cost=1,393.61..1,393.62 rows=1 width=8) (actual time=0.605..0.606 rows=1 loops=49,965)

24. 999.300 29,679.210 ↑ 5.8 10 49,965

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

25. 299.790 299.790 ↑ 1.0 1 49,965

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.006 rows=1 loops=49,965)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 143
26. 4,256.613 28,380.120 ↑ 5.8 10 49,965

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

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

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

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

SubPlan (forBitmap Heap Scan)

29. 2,207.064 23,174.172 ↑ 1.0 1 1,103,532

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

30. 5,517.660 20,967.108 ↑ 2.0 1 1,103,532

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

  • Sort Key: empleados_movimientos.fecha, empleados_movimientos.id
  • Sort Method: quicksort Memory: 25kB
31. 5,520.018 15,449.448 ↑ 1.0 2 1,103,532

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

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

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

  • Index Cond: (empleado_id = empleados.id)
  • Rows Removed by Index Recheck: 0
33. 699.510 23,583.480 ↑ 1.0 1 49,965

Aggregate (cost=1,269.60..1,269.63 rows=1 width=16) (actual time=0.472..0.472 rows=1 loops=49,965)

34. 3,894.384 22,883.970 ↑ 5.8 12 49,965

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.052..0.458 rows=12 loops=49,965)

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

SubPlan (forIndex Only Scan)

36. 2,712.798 18,989.586 ↑ 1.0 1 1,356,399

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

37. 8,138.394 16,276.788 ↑ 2.0 1 1,356,399

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

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

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

  • Index Cond: (empleado_id = emplea.id)
  • Rows Removed by Index Recheck: 0
39. 449.685 30,878.370 ↑ 1.0 1 49,965

Aggregate (cost=1,743.24..1,743.25 rows=1 width=8) (actual time=0.617..0.618 rows=1 loops=49,965)

40. 649.545 30,428.685 ↑ 6.3 6 49,965

Nested Loop (cost=4.17..1,743.15 rows=38 width=8) (actual time=0.078..0.609 rows=6 loops=49,965)

41. 199.860 199.860 ↑ 1.0 1 49,965

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

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 143
42. 2,096.733 29,579.280 ↑ 6.3 6 49,965

Nested Loop (cost=3.88..1,739.46 rows=38 width=16) (actual time=0.071..0.592 rows=6 loops=49,965)

43. 2,870.499 23,033.865 ↑ 5.8 10 49,965

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

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

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

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

SubPlan (forBitmap Heap Scan)

46. 2,207.064 19,863.576 ↑ 1.0 1 1,103,532

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

47. 5,517.660 17,656.512 ↑ 2.0 1 1,103,532

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

  • Sort Key: empleados_movimientos_2.fecha, empleados_movimientos_2.id
  • Sort Method: quicksort Memory: 25kB
48. 5,519.232 12,138.852 ↑ 1.0 2 1,103,532

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

  • One-Time Filter: (empleados_1.empresa_id = emp.id)
49. 6,619.620 6,619.620 ↑ 1.0 2 1,103,270

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

  • Index Cond: (empleado_id = empleados_1.id)
  • Rows Removed by Index Recheck: 0
50. 4,448.682 4,448.682 ↑ 1.0 1 494,298

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

  • 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.790 27,430.785 ↑ 1.0 1 49,965

Aggregate (cost=1,743.02..1,743.03 rows=1 width=8) (actual time=0.548..0.549 rows=1 loops=49,965)

52. 449.685 27,130.995 ↑ 6.7 3 49,965

Nested Loop (cost=4.17..1,742.97 rows=20 width=8) (actual time=0.116..0.543 rows=3 loops=49,965)

53. 199.860 199.860 ↑ 1.0 1 49,965

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

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 143
54. 1,770.183 26,481.450 ↑ 6.7 3 49,965

Nested Loop (cost=3.88..1,739.46 rows=20 width=16) (actual time=0.110..0.530 rows=3 loops=49,965)

55. 2,620.674 22,734.075 ↑ 5.8 10 49,965

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

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

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

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

SubPlan (forBitmap Heap Scan)

58. 3,310.596 19,863.576 ↑ 1.0 1 1,103,532

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

59. 4,414.128 16,552.980 ↑ 2.0 1 1,103,532

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

  • Sort Key: empleados_movimientos_3.fecha, empleados_movimientos_3.id
  • Sort Method: quicksort Memory: 25kB
60. 5,519.232 12,138.852 ↑ 1.0 2 1,103,532

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

  • One-Time Filter: (empleados_2.empresa_id = emp.id)
61. 6,619.620 6,619.620 ↑ 1.0 2 1,103,270

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

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

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

  • Index Cond: (id = empleados_2.persona_id)
  • Rows Removed by Index Recheck: 0
  • Filter: ((sexo)::text = 'F'::text)
  • Rows Removed by Filter: 1
63. 99.930 2,048.565 ↑ 1.0 1 49,965

Limit (cost=7.19..7.19 rows=1 width=134) (actual time=0.041..0.041 rows=1 loops=49,965)

64. 249.825 1,948.635 ↑ 1.0 1 49,965

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

  • Sort Key: cambio_situacion_empresa.fecha_creacion, cambio_situacion_empresa.id_cambio_situacion_empresa
  • Sort Method: quicksort Memory: 25kB
65. 617.744 1,698.810 ↑ 1.0 1 49,965

Nested Loop (cost=0.00..7.18 rows=1 width=134) (actual time=0.022..0.034 rows=1 loops=49,965)

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

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.011..0.014 rows=1 loops=49,965)

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

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