explain.depesz.com

PostgreSQL's explain analyze made readable

Result: ofG4

Settings
# exclusive inclusive rows x rows loops node
1. 581.979 102,126.793 ↑ 1.0 49,965 1

Hash Left Join (cost=3,088.72..308,154,108.23 rows=50,050 width=964) (actual time=110.798..102,126.793 rows=49,965 loops=1)

  • Hash Cond: (empresas_sucursales.type = empresas_sucursales_types.id)
2. 100.359 815.348 ↑ 1.0 49,965 1

Hash Left Join (cost=3,087.67..9,592.10 rows=50,050 width=940) (actual time=110.340..815.348 rows=49,965 loops=1)

  • Hash Cond: (empresas_sucursales.id_activ_econ = actividad_econ.id_activ_econ)
3. 89.244 713.725 ↑ 1.0 49,965 1

Hash Left Join (cost=3,062.92..8,879.17 rows=50,050 width=886) (actual time=109.055..713.725 rows=49,965 loops=1)

  • Hash Cond: (empresas_sucursales.distrito_id = distritos.id)
4. 94.176 624.436 ↑ 1.0 49,965 1

Hash Left Join (cost=3,061.45..8,189.89 rows=50,050 width=876) (actual time=108.987..624.436 rows=49,965 loops=1)

  • Hash Cond: (empresas_sucursales.city_id = city.id)
5. 81.141 529.787 ↑ 1.0 49,965 1

Hash Left Join (cost=3,048.51..7,491.40 rows=50,050 width=840) (actual time=108.482..529.787 rows=49,965 loops=1)

  • Hash Cond: (emp.id_categoria_empresa = empresas_categorias.id_categoria_empresa)
6. 87.466 448.620 ↑ 1.0 49,965 1

Hash Left Join (cost=3,035.36..7,285.62 rows=50,050 width=324) (actual time=108.384..448.620 rows=49,965 loops=1)

  • Hash Cond: (emp.type = empresas_types.id)
7. 163.710 361.098 ↑ 1.0 49,965 1

Hash Join (cost=3,033.77..6,647.63 rows=50,050 width=311) (actual time=108.292..361.098 rows=49,965 loops=1)

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

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

  • Filter: (type = 1)
  • Rows Removed by Filter: 5621
9. 49.103 108.199 ↓ 1.0 49,826 1

Hash (cost=2,410.97..2,410.97 rows=49,824 width=82) (actual time=108.199..108.199 rows=49,826 loops=1)

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

Seq Scan on empresas emp (cost=0.00..2,410.97 rows=49,824 width=82) (actual time=0.007..59.096 rows=49,826 loops=1)

  • Filter: (((document)::text <> '0'::text) AND ((document)::text <> ''::text) AND ((document)::text <> '-'::text))
  • Rows Removed by Filter: 2
11. 0.025 0.056 ↓ 1.2 30 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 2kB
12. 0.031 0.031 ↓ 1.2 30 1

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

13. 0.003 0.026 ↑ 35.0 4 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
14. 0.023 0.023 ↑ 35.0 4 1

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

15. 0.227 0.473 ↑ 1.1 251 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 19kB
16. 0.246 0.246 ↑ 1.1 251 1

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

17. 0.026 0.045 ↑ 1.2 18 1

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

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

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

19. 0.648 1.264 ↑ 1.0 700 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 63kB
20. 0.616 0.616 ↑ 1.0 700 1

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

21. 0.003 0.026 ↑ 1.0 1 1

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

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

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

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

SubPlan (forHash Left Join)

24. 549.615 26,981.100 ↑ 1.0 1 49,965

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

25. 949.335 26,431.485 ↑ 5.8 10 49,965

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

26. 249.825 249.825 ↑ 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.005 rows=1 loops=49,965)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 38
27. 3,715.849 25,232.325 ↑ 5.8 10 49,965

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

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

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

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

SubPlan (forBitmap Heap Scan)

30. 2,207.038 20,966.861 ↑ 1.0 1 1,103,519

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

31. 5,517.595 18,759.823 ↑ 2.0 1 1,103,519

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

  • Sort Key: empleados_movimientos.fecha, empleados_movimientos.id
  • Sort Method: quicksort Memory: 25kB
32. 5,519.429 13,242.228 ↑ 1.0 2 1,103,519

Result (cost=0.00..9.05 rows=2 width=20) (actual time=0.007..0.012 rows=2 loops=1,103,519)

  • One-Time Filter: (empleados.empresa_id = emp.id)
33. 7,722.799 7,722.799 ↑ 1.0 2 1,103,257

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

  • Index Cond: (empleado_id = empleados.id)
  • Rows Removed by Index Recheck: 0
34. 699.510 20,385.720 ↑ 1.0 1 49,965

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

35. 3,409.590 19,686.210 ↑ 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.033..0.394 rows=12 loops=49,965)

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

SubPlan (forIndex Only Scan)

37. 2,712.770 16,276.620 ↑ 1.0 1 1,356,385

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

38. 6,781.925 13,563.850 ↑ 2.0 1 1,356,385

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

  • Sort Key: empleados_movimientos_1.fecha, empleados_movimientos_1.id
  • Sort Method: quicksort Memory: 25kB
39. 6,781.925 6,781.925 ↑ 1.0 2 1,356,385

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

  • Index Cond: (empleado_id = emplea.id)
  • Rows Removed by Index Recheck: 0
40. 399.720 27,130.995 ↑ 1.0 1 49,965

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

41. 699.510 26,731.275 ↑ 6.3 6 49,965

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

42. 149.895 149.895 ↑ 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.002..0.003 rows=1 loops=49,965)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 38
43. 1,686.029 25,881.870 ↑ 6.3 6 49,965

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

44. 2,829.346 20,735.475 ↑ 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.042..0.415 rows=10 loops=49,965)

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

SubPlan (forBitmap Heap Scan)

47. 2,207.038 17,656.304 ↑ 1.0 1 1,103,519

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

48. 5,517.595 15,449.266 ↑ 2.0 1 1,103,519

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

  • Sort Key: empleados_movimientos_2.fecha, empleados_movimientos_2.id
  • Sort Method: quicksort Memory: 25kB
49. 4,415.386 9,931.671 ↑ 1.0 2 1,103,519

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

  • One-Time Filter: (empleados_1.empresa_id = emp.id)
50. 5,516.285 5,516.285 ↑ 1.0 2 1,103,257

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

  • Index Cond: (empleado_id = empleados_1.id)
  • Rows Removed by Index Recheck: 0
51. 3,460.366 3,460.366 ↑ 1.0 1 494,338

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

  • Index Cond: (id = empleados_1.persona_id)
  • Rows Removed by Index Recheck: 0
  • Filter: ((sexo)::text = 'M'::text)
  • Rows Removed by Filter: 0
52. 249.825 24,532.815 ↑ 1.0 1 49,965

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

53. 449.685 24,282.990 ↑ 6.7 3 49,965

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

54. 149.895 149.895 ↑ 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.002..0.003 rows=1 loops=49,965)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 38
55. 1,614.816 23,683.410 ↑ 6.7 3 49,965

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

56. 2,679.451 20,585.580 ↑ 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.043..0.412 rows=10 loops=49,965)

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

SubPlan (forBitmap Heap Scan)

59. 2,207.038 17,656.304 ↑ 1.0 1 1,103,519

Limit (cost=9.06..9.06 rows=1 width=20) (actual time=0.015..0.016 rows=1 loops=1,103,519)

60. 5,517.595 15,449.266 ↑ 2.0 1 1,103,519

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

  • Sort Key: empleados_movimientos_3.fecha, empleados_movimientos_3.id
  • Sort Method: quicksort Memory: 25kB
61. 4,415.386 9,931.671 ↑ 1.0 2 1,103,519

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

  • One-Time Filter: (empleados_2.empresa_id = emp.id)
62. 5,516.285 5,516.285 ↑ 1.0 2 1,103,257

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

  • Index Cond: (empleado_id = empleados_2.id)
  • Rows Removed by Index Recheck: 0
63. 1,483.014 1,483.014 ↓ 0.0 0 494,338

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

  • 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.895 1,698.810 ↑ 1.0 1 49,965

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

65. 199.860 1,548.915 ↑ 1.0 1 49,965

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

  • Sort Key: cambio_situacion_empresa.fecha_creacion, cambio_situacion_empresa.id_cambio_situacion_empresa
  • Sort Method: quicksort Memory: 25kB
66. 567.821 1,349.055 ↑ 1.0 1 49,965

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

  • Join Filter: (cambio_situacion_empresa.situacion_act = situacion_emp.id_situacion)
  • Rows Removed by Join Filter: 7
67. 399.720 399.720 ↑ 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.006..0.008 rows=1 loops=49,965)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
68. 381.514 381.514 ↑ 1.0 7 54,502

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