explain.depesz.com

PostgreSQL's explain analyze made readable

Result: Pw8s

Settings
# exclusive inclusive rows x rows loops node
1. 827.991 135,781.781 ↑ 1.0 49,791 1

Nested Loop (cost=37.55..431,985,569.13 rows=49,818 width=1,396) (actual time=3.394..135,781.781 rows=49,791 loops=1)

2. 0.012 0.012 ↑ 1.0 1 1

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

  • Filter: (id = 1)
  • Rows Removed by Filter: 2
3. 91.587 1,862.435 ↑ 1.0 49,791 1

Hash Left Join (cost=37.55..11,674.90 rows=49,818 width=1,372) (actual time=3.047..1,862.435 rows=49,791 loops=1)

  • Hash Cond: (empresas_sucursales.distrito_id = distritos.id)
4. 100.020 1,770.797 ↑ 1.0 49,791 1

Hash Left Join (cost=36.14..10,988.83 rows=49,818 width=1,348) (actual time=2.982..1,770.797 rows=49,791 loops=1)

  • Hash Cond: (empresas_sucursales.city_id = city.id)
5. 79.699 1,670.362 ↑ 1.0 49,791 1

Hash Left Join (cost=27.49..10,297.82 rows=49,818 width=1,320) (actual time=2.534..1,670.362 rows=49,791 loops=1)

  • Hash Cond: (emp.id_categoria_empresa = empresas_categorias.id_categoria_empresa)
6. 94.389 1,590.097 ↑ 1.0 49,791 1

Hash Left Join (cost=26.40..10,106.28 rows=49,818 width=808) (actual time=1.944..1,590.097 rows=49,791 loops=1)

  • Hash Cond: (emp.type = empresas_types.id)
7. 203.527 1,495.637 ↑ 1.0 49,791 1

Nested Loop (cost=24.73..9,419.60 rows=49,818 width=300) (actual time=1.851..1,495.637 rows=49,791 loops=1)

8. 113.585 196.664 ↑ 1.0 49,793 1

Hash Join (cost=24.73..3,295.49 rows=49,821 width=226) (actual time=1.780..196.664 rows=49,793 loops=1)

  • Hash Cond: (empresas_sucursales.id_activ_econ = actividad_econ.id_activ_econ)
9. 81.908 81.908 ↓ 1.0 49,892 1

Seq Scan on empresas_sucursales (cost=0.00..2,585.71 rows=49,823 width=172) (actual time=0.569..81.908 rows=49,892 loops=1)

  • Filter: (type = 1)
  • Rows Removed by Filter: 5605
10. 0.582 1.171 ↑ 1.0 699 1

Hash (cost=15.99..15.99 rows=699 width=58) (actual time=1.171..1.171 rows=699 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 63kB
11. 0.589 0.589 ↑ 1.0 699 1

Seq Scan on actividad_econ (cost=0.00..15.99 rows=699 width=58) (actual time=0.007..0.589 rows=699 loops=1)

12. 1,095.446 1,095.446 ↑ 1.0 1 49,793

Index Scan using empresas_id_idx on empresas emp (cost=0.00..0.11 rows=1 width=82) (actual time=0.020..0.022 rows=1 loops=49,793)

  • Index Cond: (id = empresas_sucursales.empresa_id)
  • Filter: (((document)::text <> '0'::text) AND ((document)::text <> ''::text) AND ((document)::text <> '-'::text))
  • Rows Removed by Filter: 0
13. 0.023 0.071 ↑ 1.0 30 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 2kB
14. 0.048 0.048 ↑ 1.0 30 1

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

15. 0.009 0.566 ↑ 1.0 4 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
16. 0.557 0.557 ↑ 1.0 4 1

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

17. 0.209 0.415 ↑ 1.0 251 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 19kB
18. 0.206 0.206 ↑ 1.0 251 1

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

19. 0.014 0.051 ↑ 1.0 18 1

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

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

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

21.          

SubPlan (forNested Loop)

22. 448.119 42,421.932 ↑ 1.0 1 49,791

Aggregate (cost=1,842.96..1,842.97 rows=1 width=8) (actual time=0.852..0.852 rows=1 loops=49,791)

23. 1,045.611 41,973.813 ↑ 5.8 10 49,791

Nested Loop (cost=4.88..1,842.81 rows=58 width=8) (actual time=0.126..0.843 rows=10 loops=49,791)

24. 398.328 398.328 ↑ 1.0 1 49,791

Index Scan using empresas_sucursales_nro_patronal_idx on empresas_sucursales es (cost=0.00..8.02 rows=1 width=4) (actual time=0.007..0.008 rows=1 loops=49,791)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
25. 7,740.055 40,529.874 ↑ 5.8 10 49,791

Bitmap Heap Scan on empleados (cost=4.88..1,834.22 rows=58 width=24) (actual time=0.109..0.814 rows=10 loops=49,791)

  • Recheck Cond: (npatronal = empresas_sucursales.nro_patronal)
  • Filter: (SubPlan 1)
  • Rows Removed by Filter: 12
26. 1,145.193 1,145.193 ↑ 5.3 22 49,791

Bitmap Index Scan on empleados_npatronal_idx (cost=0.00..4.87 rows=116 width=0) (actual time=0.023..0.023 rows=22 loops=49,791)

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

SubPlan (forBitmap Heap Scan)

28. 3,273.582 31,644.626 ↑ 1.0 1 1,091,194

Limit (cost=12.06..12.06 rows=1 width=20) (actual time=0.028..0.029 rows=1 loops=1,091,194)

29. 5,455.970 28,371.044 ↑ 2.0 1 1,091,194

Sort (cost=12.06..12.06 rows=2 width=20) (actual time=0.026..0.026 rows=1 loops=1,091,194)

  • Sort Key: empleados_movimientos.fecha, empleados_movimientos.id
  • Sort Method: quicksort Memory: 25kB
30. 4,369.230 22,915.074 ↑ 1.0 2 1,091,194

Result (cost=0.00..12.05 rows=2 width=20) (actual time=0.015..0.021 rows=2 loops=1,091,194)

  • One-Time Filter: (empleados.empresa_id = emp.id)
31. 18,545.844 18,545.844 ↑ 1.0 2 1,090,932

Index Scan using empleados_movimientos_empleado_id_idx on empleados_movimientos (cost=0.00..12.04 rows=2 width=20) (actual time=0.012..0.017 rows=2 loops=1,090,932)

  • Index Cond: (empleado_id = empleados.id)
  • Rows Removed by Index Recheck: 0
32. 796.656 25,692.156 ↑ 1.0 1 49,791

Aggregate (cost=2,198.12..2,198.15 rows=1 width=16) (actual time=0.516..0.516 rows=1 loops=49,791)

33. 4,914.056 24,895.500 ↑ 5.8 12 49,791

Bitmap Heap Scan on empleados emplea (cost=9.06..2,196.74 rows=69 width=16) (actual time=0.058..0.500 rows=12 loops=49,791)

  • Recheck Cond: (empresa_id = emp.id)
  • Filter: (SubPlan 3)
  • Rows Removed by Filter: 15
34. 1,194.984 1,194.984 ↑ 5.1 27 49,791

Bitmap Index Scan on empleados_empresa_id_indx (cost=0.00..9.04 rows=139 width=0) (actual time=0.024..0.024 rows=27 loops=49,791)

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

SubPlan (forBitmap Heap Scan)

36. 4,025.670 18,786.460 ↑ 1.0 1 1,341,890

Limit (cost=12.06..12.06 rows=1 width=20) (actual time=0.014..0.014 rows=1 loops=1,341,890)

37. 5,367.560 14,760.790 ↑ 2.0 1 1,341,890

Sort (cost=12.06..12.06 rows=2 width=20) (actual time=0.011..0.011 rows=1 loops=1,341,890)

  • Sort Key: empleados_movimientos_1.fecha, empleados_movimientos_1.id
  • Sort Method: quicksort Memory: 25kB
38. 9,393.230 9,393.230 ↑ 1.0 2 1,341,890

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,341,890)

  • Index Cond: (empleado_id = emplea.id)
  • Rows Removed by Index Recheck: 0
39. 398.328 36,596.385 ↑ 1.0 1 49,791

Aggregate (cost=2,308.59..2,308.60 rows=1 width=8) (actual time=0.735..0.735 rows=1 loops=49,791)

40. 547.701 36,198.057 ↑ 6.3 6 49,791

Nested Loop (cost=4.88..2,308.50 rows=38 width=8) (actual time=0.095..0.727 rows=6 loops=49,791)

41. 199.164 199.164 ↑ 1.0 1 49,791

Index Scan using empresas_sucursales_nro_patronal_idx on empresas_sucursales es_1 (cost=0.00..8.02 rows=1 width=4) (actual time=0.003..0.004 rows=1 loops=49,791)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
42. 2,170.929 35,451.192 ↑ 6.3 6 49,791

Nested Loop (cost=4.88..2,300.10 rows=38 width=16) (actual time=0.087..0.712 rows=6 loops=49,791)

43. 3,851.444 21,559.503 ↑ 5.8 10 49,791

Bitmap Heap Scan on empleados empleados_1 (cost=4.88..1,834.22 rows=58 width=24) (actual time=0.042..0.433 rows=10 loops=49,791)

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

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

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

SubPlan (forBitmap Heap Scan)

46. 2,182.388 17,459.104 ↑ 1.0 1 1,091,194

Limit (cost=12.06..12.06 rows=1 width=20) (actual time=0.016..0.016 rows=1 loops=1,091,194)

47. 5,455.970 15,276.716 ↑ 2.0 1 1,091,194

Sort (cost=12.06..12.06 rows=2 width=20) (actual time=0.014..0.014 rows=1 loops=1,091,194)

  • Sort Key: empleados_movimientos_2.fecha, empleados_movimientos_2.id
  • Sort Method: quicksort Memory: 25kB
48. 4,366.086 9,820.746 ↑ 1.0 2 1,091,194

Result (cost=0.00..12.05 rows=2 width=20) (actual time=0.006..0.009 rows=2 loops=1,091,194)

  • One-Time Filter: (empleados_1.empresa_id = emp.id)
49. 5,454.660 5,454.660 ↑ 1.0 2 1,090,932

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,090,932)

  • Index Cond: (empleado_id = empleados_1.id)
  • Rows Removed by Index Recheck: 0
50. 11,720.760 11,720.760 ↑ 1.0 1 488,365

Index Scan using persons_id_idx on persons (cost=0.00..8.02 rows=1 width=8) (actual time=0.024..0.024 rows=1 loops=488,365)

  • Index Cond: (id = empleados_1.persona_id)
  • Rows Removed by Index Recheck: 0
  • Filter: ((sexo)::text = 'M'::text)
  • Rows Removed by Filter: 0
51. 248.955 25,293.828 ↑ 1.0 1 49,791

Aggregate (cost=2,308.37..2,308.38 rows=1 width=8) (actual time=0.507..0.508 rows=1 loops=49,791)

52. 497.910 25,044.873 ↑ 6.7 3 49,791

Nested Loop (cost=4.88..2,308.32 rows=20 width=8) (actual time=0.112..0.503 rows=3 loops=49,791)

53. 149.373 149.373 ↑ 1.0 1 49,791

Index Scan using empresas_sucursales_nro_patronal_idx on empresas_sucursales es_2 (cost=0.00..8.02 rows=1 width=4) (actual time=0.002..0.003 rows=1 loops=49,791)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
54. 1,581.701 24,397.590 ↑ 6.7 3 49,791

Nested Loop (cost=4.88..2,300.10 rows=20 width=16) (actual time=0.104..0.490 rows=3 loops=49,791)

55. 3,204.161 20,862.429 ↑ 5.8 10 49,791

Bitmap Heap Scan on empleados empleados_2 (cost=4.88..1,834.22 rows=58 width=24) (actual time=0.043..0.419 rows=10 loops=49,791)

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

Bitmap Index Scan on empleados_npatronal_idx (cost=0.00..4.87 rows=116 width=0) (actual time=0.004..0.004 rows=22 loops=49,791)

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

SubPlan (forBitmap Heap Scan)

58. 3,273.582 17,459.104 ↑ 1.0 1 1,091,194

Limit (cost=12.06..12.06 rows=1 width=20) (actual time=0.016..0.016 rows=1 loops=1,091,194)

59. 4,364.776 14,185.522 ↑ 2.0 1 1,091,194

Sort (cost=12.06..12.06 rows=2 width=20) (actual time=0.013..0.013 rows=1 loops=1,091,194)

  • Sort Key: empleados_movimientos_3.fecha, empleados_movimientos_3.id
  • Sort Method: quicksort Memory: 25kB
60. 5,457.018 9,820.746 ↑ 1.0 2 1,091,194

Result (cost=0.00..12.05 rows=2 width=20) (actual time=0.006..0.009 rows=2 loops=1,091,194)

  • One-Time Filter: (empleados_2.empresa_id = emp.id)
61. 4,363.728 4,363.728 ↑ 1.0 2 1,090,932

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.004 rows=2 loops=1,090,932)

  • Index Cond: (empleado_id = empleados_2.id)
  • Rows Removed by Index Recheck: 0
62. 1,953.460 1,953.460 ↓ 0.0 0 488,365

Index Scan using persons_id_idx on persons persons_1 (cost=0.00..8.02 rows=1 width=8) (actual time=0.003..0.004 rows=0 loops=488,365)

  • Index Cond: (id = empleados_2.persona_id)
  • Rows Removed by Index Recheck: 0
  • Filter: ((sexo)::text = 'F'::text)
  • Rows Removed by Filter: 1
63. 199.164 3,087.042 ↑ 1.0 1 49,791

Limit (cost=12.92..12.93 rows=1 width=134) (actual time=0.061..0.062 rows=1 loops=49,791)

64. 497.910 2,887.878 ↑ 2.0 1 49,791

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

  • Sort Key: cambio_situacion_empresa.fecha_creacion, cambio_situacion_empresa.id_cambio_situacion_empresa
  • Sort Method: quicksort Memory: 25kB
65. 495.984 2,389.968 ↑ 2.0 1 49,791

Hash Join (cost=11.79..12.91 rows=2 width=134) (actual time=0.045..0.048 rows=1 loops=49,791)

  • Hash Cond: (situacion_emp.id_situacion = cambio_situacion_empresa.situacion_act)
66. 201.090 201.090 ↑ 1.0 7 40,218

Seq Scan on situacion_emp (cost=0.00..1.07 rows=7 width=122) (actual time=0.002..0.005 rows=7 loops=40,218)

67. 348.537 1,692.894 ↑ 2.0 1 49,791

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

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
68. 846.447 1,344.357 ↑ 2.0 1 49,791

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

  • Recheck Cond: (nro_patronal = empresas_sucursales.nro_patronal)
69. 497.910 497.910 ↑ 2.0 1 49,791

Bitmap Index Scan on cambio_situacion_empresa_nro_patronal_idx (cost=0.00..4.01 rows=2 width=0) (actual time=0.010..0.010 rows=1 loops=49,791)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)