explain.depesz.com

PostgreSQL's explain analyze made readable

Result: WpJu

Settings
# exclusive inclusive rows x rows loops node
1. 636.743 101,519.617 ↓ 1.0 50,019 1

Hash Left Join (cost=3,088.70..201,135,253.29 rows=50,001 width=964) (actual time=180.021..101,519.617 rows=50,019 loops=1)

  • Hash Cond: (empresas_sucursales.type = empresas_sucursales_types.id)
2. 101.052 894.846 ↓ 1.0 50,019 1

Hash Left Join (cost=3,087.65..9,559.77 rows=50,001 width=940) (actual time=174.869..894.846 rows=50,019 loops=1)

  • Hash Cond: (empresas_sucursales.id_activ_econ = actividad_econ.id_activ_econ)
3. 89.428 792.040 ↓ 1.0 50,019 1

Hash Left Join (cost=3,062.90..8,847.53 rows=50,001 width=886) (actual time=173.057..792.040 rows=50,019 loops=1)

  • Hash Cond: (empresas_sucursales.distrito_id = distritos.id)
4. 93.356 702.562 ↓ 1.0 50,019 1

Hash Left Join (cost=3,061.43..8,158.96 rows=50,001 width=876) (actual time=172.974..702.562 rows=50,019 loops=1)

  • Hash Cond: (empresas_sucursales.city_id = city.id)
5. 79.433 608.447 ↓ 1.0 50,019 1

Hash Left Join (cost=3,048.78..7,461.27 rows=50,001 width=840) (actual time=172.173..608.447 rows=50,019 loops=1)

  • Hash Cond: (emp.id_categoria_empresa = empresas_categorias.id_categoria_empresa)
6. 86.672 528.976 ↓ 1.0 50,019 1

Hash Left Join (cost=3,035.63..7,255.72 rows=50,001 width=324) (actual time=172.021..528.976 rows=50,019 loops=1)

  • Hash Cond: (emp.type = empresas_types.id)
7. 183.690 442.210 ↓ 1.0 50,019 1

Hash Join (cost=3,034.04..6,647.27 rows=50,001 width=311) (actual time=171.828..442.210 rows=50,019 loops=1)

  • Hash Cond: (empresas_sucursales.empresa_id = emp.id)
8. 86.837 86.837 ↓ 1.0 50,021 1

Seq Scan on empresas_sucursales (cost=0.00..2,613.18 rows=50,004 width=237) (actual time=0.028..86.837 rows=50,021 loops=1)

  • Filter: (type = 1)
  • Rows Removed by Filter: 5628
9. 73.893 171.683 ↓ 1.0 49,881 1

Hash (cost=2,411.13..2,411.13 rows=49,833 width=82) (actual time=171.683..171.683 rows=49,881 loops=1)

  • Buckets: 8192 Batches: 1 Memory Usage: 5575kB
10. 97.790 97.790 ↓ 1.0 49,881 1

Seq Scan on empresas emp (cost=0.00..2,411.13 rows=49,833 width=82) (actual time=0.036..97.790 rows=49,881 loops=1)

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

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

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

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

13. 0.015 0.038 ↑ 35.0 4 1

Hash (cost=11.40..11.40 rows=140 width=520) (actual time=0.038..0.038 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.018..0.023 rows=4 loops=1)

15. 0.375 0.759 ↑ 1.0 251 1

Hash (cost=9.51..9.51 rows=251 width=40) (actual time=0.759..0.759 rows=251 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 19kB
16. 0.384 0.384 ↑ 1.0 251 1

Seq Scan on city (cost=0.00..9.51 rows=251 width=40) (actual time=0.020..0.384 rows=251 loops=1)

17. 0.026 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
18. 0.024 0.024 ↑ 1.2 18 1

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

19. 0.897 1.754 ↓ 1.0 701 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 64kB
20. 0.857 0.857 ↓ 1.0 701 1

Seq Scan on actividad_econ (cost=0.00..16.00 rows=700 width=58) (actual time=0.010..0.857 rows=701 loops=1)

21. 0.004 0.047 ↑ 1.0 1 1

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

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

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

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

SubPlan (forHash Left Join)

24. 550.209 26,410.032 ↑ 1.0 1 50,019

Aggregate (cost=957.75..957.76 rows=1 width=8) (actual time=0.528..0.528 rows=1 loops=50,019)

25. 900.342 25,859.823 ↑ 5.9 10 50,019

Nested Loop (cost=0.72..957.60 rows=59 width=8) (actual time=0.057..0.517 rows=10 loops=50,019)

26. 250.095 250.095 ↑ 1.0 1 50,019

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

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 659
27. 3,715.450 24,709.386 ↑ 5.9 10 50,019

Index Scan using empleados_npatronal_id_idx on empleados (cost=0.43..954.70 rows=59 width=24) (actual time=0.050..0.494 rows=10 loops=50,019)

  • Index Cond: (npatronal = empresas_sucursales.nro_patronal)
  • Filter: (SubPlan 1)
  • Rows Removed by Filter: 12
28.          

SubPlan (forIndex Scan)

29. 2,209.888 20,993.936 ↑ 1.0 1 1,104,944

Limit (cost=6.06..6.06 rows=1 width=20) (actual time=0.018..0.019 rows=1 loops=1,104,944)

30. 5,524.720 18,784.048 ↑ 2.0 1 1,104,944

Sort (cost=6.06..6.06 rows=2 width=20) (actual time=0.017..0.017 rows=1 loops=1,104,944)

  • Sort Key: empleados_movimientos.fecha, empleados_movimientos.id
  • Sort Method: quicksort Memory: 25kB
31. 5,526.554 13,259.328 ↑ 1.0 2 1,104,944

Result (cost=0.00..6.05 rows=2 width=20) (actual time=0.007..0.012 rows=2 loops=1,104,944)

  • One-Time Filter: (empleados.empresa_id = emp.id)
32. 7,732.774 7,732.774 ↑ 1.0 2 1,104,682

Index Scan using empleados_movimientos_empleado_id_idx on empleados_movimientos (cost=0.00..6.04 rows=2 width=20) (actual time=0.005..0.007 rows=2 loops=1,104,682)

  • Index Cond: (empleado_id = empleados.id)
  • Rows Removed by Index Recheck: 0
33. 650.247 20,357.733 ↑ 1.0 1 50,019

Aggregate (cost=854.68..854.71 rows=1 width=16) (actual time=0.407..0.407 rows=1 loops=50,019)

34. 3,408.414 19,707.486 ↑ 5.8 12 50,019

Index Only Scan using empleados_empresa_id_id_idx on empleados emplea (cost=0.43..853.28 rows=70 width=16) (actual time=0.032..0.394 rows=12 loops=50,019)

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

SubPlan (forIndex Only Scan)

36. 2,716.512 16,299.072 ↑ 1.0 1 1,358,256

Limit (cost=6.05..6.06 rows=1 width=20) (actual time=0.012..0.012 rows=1 loops=1,358,256)

37. 6,791.280 13,582.560 ↑ 2.0 1 1,358,256

Sort (cost=6.05..6.06 rows=2 width=20) (actual time=0.010..0.010 rows=1 loops=1,358,256)

  • Sort Key: empleados_movimientos_1.fecha, empleados_movimientos_1.id
  • Sort Method: quicksort Memory: 25kB
38. 6,791.280 6,791.280 ↑ 1.0 2 1,358,256

Index Scan using empleados_movimientos_empleado_id_idx on empleados_movimientos empleados_movimientos_1 (cost=0.00..6.04 rows=2 width=20) (actual time=0.003..0.005 rows=2 loops=1,358,256)

  • Index Cond: (empleado_id = emplea.id)
  • Rows Removed by Index Recheck: 0
39. 400.152 26,660.127 ↑ 1.0 1 50,019

Aggregate (cost=1,102.49..1,102.50 rows=1 width=8) (actual time=0.532..0.533 rows=1 loops=50,019)

40. 650.247 26,259.975 ↑ 6.5 6 50,019

Nested Loop (cost=1.14..1,102.39 rows=39 width=8) (actual time=0.062..0.525 rows=6 loops=50,019)

41. 150.057 150.057 ↑ 1.0 1 50,019

Index Only Scan using empresas_sucursales_nro_patronal_key on empresas_sucursales es_1 (cost=0.29..2.31 rows=1 width=4) (actual time=0.002..0.003 rows=1 loops=50,019)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 659
42. 1,638.168 25,459.671 ↑ 6.5 6 50,019

Nested Loop (cost=0.85..1,099.70 rows=39 width=16) (actual time=0.057..0.509 rows=6 loops=50,019)

43. 3,178.819 20,857.923 ↑ 5.9 10 50,019

Index Scan using empleados_npatronal_id_idx on empleados empleados_1 (cost=0.43..954.70 rows=59 width=24) (actual time=0.036..0.417 rows=10 loops=50,019)

  • Index Cond: (npatronal = empresas_sucursales.nro_patronal)
  • Filter: (SubPlan 5)
  • Rows Removed by Filter: 12
44.          

SubPlan (forIndex Scan)

45. 2,209.888 17,679.104 ↑ 1.0 1 1,104,944

Limit (cost=6.06..6.06 rows=1 width=20) (actual time=0.016..0.016 rows=1 loops=1,104,944)

46. 5,524.720 15,469.216 ↑ 2.0 1 1,104,944

Sort (cost=6.06..6.06 rows=2 width=20) (actual time=0.014..0.014 rows=1 loops=1,104,944)

  • Sort Key: empleados_movimientos_2.fecha, empleados_movimientos_2.id
  • Sort Method: quicksort Memory: 25kB
47. 4,421.086 9,944.496 ↑ 1.0 2 1,104,944

Result (cost=0.00..6.05 rows=2 width=20) (actual time=0.005..0.009 rows=2 loops=1,104,944)

  • One-Time Filter: (empleados_1.empresa_id = emp.id)
48. 5,523.410 5,523.410 ↑ 1.0 2 1,104,682

Index Scan using empleados_movimientos_empleado_id_idx on empleados_movimientos empleados_movimientos_2 (cost=0.00..6.04 rows=2 width=20) (actual time=0.003..0.005 rows=2 loops=1,104,682)

  • Index Cond: (empleado_id = empleados_1.id)
  • Rows Removed by Index Recheck: 0
49. 2,963.580 2,963.580 ↑ 1.0 1 493,930

Index Only Scan using persons_id_sexo_idx on persons (cost=0.42..2.45 rows=1 width=8) (actual time=0.006..0.006 rows=1 loops=493,930)

  • Index Cond: ((id = empleados_1.persona_id) AND (sexo = 'M'::text))
  • Heap Fetches: 0
50. 300.114 24,809.424 ↑ 1.0 1 50,019

Aggregate (cost=1,102.25..1,102.26 rows=1 width=8) (actual time=0.495..0.496 rows=1 loops=50,019)

51. 400.152 24,509.310 ↑ 6.7 3 50,019

Nested Loop (cost=1.14..1,102.20 rows=20 width=8) (actual time=0.097..0.490 rows=3 loops=50,019)

52. 150.057 150.057 ↑ 1.0 1 50,019

Index Only Scan using empresas_sucursales_nro_patronal_key on empresas_sucursales es_2 (cost=0.29..2.31 rows=1 width=4) (actual time=0.002..0.003 rows=1 loops=50,019)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 659
53. 1,175.477 23,959.101 ↑ 6.7 3 50,019

Nested Loop (cost=0.85..1,099.70 rows=20 width=16) (actual time=0.091..0.479 rows=3 loops=50,019)

54. 3,128.800 20,807.904 ↑ 5.9 10 50,019

Index Scan using empleados_npatronal_id_idx on empleados empleados_2 (cost=0.43..954.70 rows=59 width=24) (actual time=0.036..0.416 rows=10 loops=50,019)

  • Index Cond: (npatronal = empresas_sucursales.nro_patronal)
  • Filter: (SubPlan 7)
  • Rows Removed by Filter: 12
55.          

SubPlan (forIndex Scan)

56. 2,209.888 17,679.104 ↑ 1.0 1 1,104,944

Limit (cost=6.06..6.06 rows=1 width=20) (actual time=0.016..0.016 rows=1 loops=1,104,944)

57. 5,524.720 15,469.216 ↑ 2.0 1 1,104,944

Sort (cost=6.06..6.06 rows=2 width=20) (actual time=0.014..0.014 rows=1 loops=1,104,944)

  • Sort Key: empleados_movimientos_3.fecha, empleados_movimientos_3.id
  • Sort Method: quicksort Memory: 25kB
58. 4,421.086 9,944.496 ↑ 1.0 2 1,104,944

Result (cost=0.00..6.05 rows=2 width=20) (actual time=0.005..0.009 rows=2 loops=1,104,944)

  • One-Time Filter: (empleados_2.empresa_id = emp.id)
59. 5,523.410 5,523.410 ↑ 1.0 2 1,104,682

Index Scan using empleados_movimientos_empleado_id_idx on empleados_movimientos empleados_movimientos_3 (cost=0.00..6.04 rows=2 width=20) (actual time=0.003..0.005 rows=2 loops=1,104,682)

  • Index Cond: (empleado_id = empleados_2.id)
  • Rows Removed by Index Recheck: 0
60. 1,975.720 1,975.720 ↓ 0.0 0 493,930

Index Only Scan using persons_id_sexo_idx on persons persons_1 (cost=0.42..2.45 rows=1 width=8) (actual time=0.004..0.004 rows=0 loops=493,930)

  • Index Cond: ((id = empleados_2.persona_id) AND (sexo = 'F'::text))
  • Heap Fetches: 0
61. 100.038 1,750.665 ↑ 1.0 1 50,019

Limit (cost=5.19..5.19 rows=1 width=134) (actual time=0.034..0.035 rows=1 loops=50,019)

62. 250.095 1,650.627 ↑ 1.0 1 50,019

Sort (cost=5.19..5.19 rows=1 width=134) (actual time=0.033..0.033 rows=1 loops=50,019)

  • Sort Key: cambio_situacion_empresa.fecha_creacion, cambio_situacion_empresa.id_cambio_situacion_empresa
  • Sort Method: quicksort Memory: 25kB
63. 566.404 1,400.532 ↑ 1.0 1 50,019

Nested Loop (cost=0.00..5.18 rows=1 width=134) (actual time=0.017..0.028 rows=1 loops=50,019)

  • Join Filter: (cambio_situacion_empresa.situacion_act = situacion_emp.id_situacion)
  • Rows Removed by Join Filter: 7
64. 450.171 450.171 ↑ 1.0 1 50,019

Index Scan using cambio_situacion_empresa_nro_patronal_idx on cambio_situacion_empresa (cost=0.00..4.02 rows=1 width=20) (actual time=0.007..0.009 rows=1 loops=50,019)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
65. 383.957 383.957 ↑ 1.0 7 54,851

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