explain.depesz.com

PostgreSQL's explain analyze made readable

Result: ZDSY : Optimization for: plan #naM

Settings

Optimization path:

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 622.629 114,526.819 ↓ 1.2 49,968 1

Nested Loop (cost=3,591.85..260,278,307.73 rows=41,977 width=964) (actual time=261.009..114,526.819 rows=49,968 loops=1)

2. 0.031 0.031 ↑ 1.0 1 1

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

  • Filter: (id = 1)
  • Rows Removed by Filter: 2
3. 129.278 976.479 ↓ 1.2 49,968 1

Hash Left Join (cost=3,591.85..8,952.96 rows=41,977 width=940) (actual time=260.698..976.479 rows=49,968 loops=1)

  • Hash Cond: (empresas_sucursales.id_activ_econ = actividad_econ.id_activ_econ)
4. 96.926 845.826 ↓ 1.2 49,968 1

Hash Left Join (cost=3,567.10..8,351.02 rows=41,977 width=886) (actual time=259.303..845.826 rows=49,968 loops=1)

  • Hash Cond: (empresas_sucursales.distrito_id = distritos.id)
5. 103.495 748.865 ↓ 1.2 49,968 1

Hash Left Join (cost=3,565.63..7,772.69 rows=41,977 width=876) (actual time=259.250..748.865 rows=49,968 loops=1)

  • Hash Cond: (empresas_sucursales.city_id = city.id)
6. 87.545 644.862 ↓ 1.2 49,968 1

Hash Left Join (cost=3,552.69..7,184.77 rows=41,977 width=840) (actual time=258.723..644.862 rows=49,968 loops=1)

  • Hash Cond: (emp.id_categoria_empresa = empresas_categorias.id_categoria_empresa)
7. 204.008 557.299 ↓ 1.2 49,968 1

Hash Join (cost=3,539.54..7,010.10 rows=41,977 width=324) (actual time=258.684..557.299 rows=49,968 loops=1)

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

Seq Scan on empresas_sucursales (cost=0.00..2,612.82 rows=50,053 width=237) (actual time=0.017..94.654 rows=49,970 loops=1)

  • Filter: (type = 1)
  • Rows Removed by Filter: 5621
9. 75.488 258.637 ↓ 1.2 49,829 1

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

  • Buckets: 8192 Batches: 1 Memory Usage: 5999kB
10. 94.702 183.149 ↓ 1.2 49,829 1

Hash Join (cost=1.58..3,017.22 rows=41,786 width=95) (actual time=0.124..183.149 rows=49,829 loops=1)

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

Seq Scan on empresas emp (cost=0.00..2,410.94 rows=49,822 width=82) (actual time=0.019..88.356 rows=49,829 loops=1)

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

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

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

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

14. 0.006 0.018 ↑ 35.0 4 1

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

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

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

16. 0.228 0.508 ↑ 1.1 251 1

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

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

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

18. 0.017 0.035 ↑ 1.2 18 1

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

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

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

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

22.          

SubPlan (forNested Loop)

23. 599.616 29,880.864 ↑ 1.0 1 49,968

Aggregate (cost=1,407.13..1,407.14 rows=1 width=8) (actual time=0.597..0.598 rows=1 loops=49,968)

24. 999.360 29,281.248 ↑ 5.8 10 49,968

Nested Loop (cost=0.72..1,406.98 rows=58 width=8) (actual time=0.065..0.586 rows=10 loops=49,968)

25. 249.840 249.840 ↑ 1.0 1 49,968

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

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 189
26. 4,856.721 28,032.048 ↑ 5.8 10 49,968

Index Scan using empleados_npatronal_id_idx on empleados (cost=0.43..1,403.10 rows=58 width=24) (actual time=0.057..0.561 rows=10 loops=49,968)

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

SubPlan (forIndex Scan)

28. 2,207.174 23,175.327 ↑ 1.0 1 1,103,587

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

29. 5,517.935 20,968.153 ↑ 2.0 1 1,103,587

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

  • Sort Key: empleados_movimientos.fecha, empleados_movimientos.id
  • Sort Method: quicksort Memory: 25kB
30. 5,520.293 15,450.218 ↑ 1.0 2 1,103,587

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

  • One-Time Filter: (empleados.empresa_id = emp.id)
31. 9,929.925 9,929.925 ↑ 1.0 2 1,103,325

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

  • Index Cond: (empleado_id = empleados.id)
  • Rows Removed by Index Recheck: 0
32. 749.520 23,035.248 ↑ 1.0 1 49,968

Aggregate (cost=1,272.59..1,272.62 rows=1 width=16) (actual time=0.460..0.461 rows=1 loops=49,968)

33. 3,295.120 22,285.728 ↑ 5.8 12 49,968

Index Only Scan using empleados_empresa_id_id_idx on empleados emplea (cost=0.43..1,271.19 rows=70 width=16) (actual time=0.039..0.446 rows=12 loops=49,968)

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

SubPlan (forIndex Only Scan)

35. 2,712.944 18,990.608 ↑ 1.0 1 1,356,472

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

36. 6,782.360 16,277.664 ↑ 2.0 1 1,356,472

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

  • Sort Key: empleados_movimientos_1.fecha, empleados_movimientos_1.id
  • Sort Method: quicksort Memory: 25kB
37. 9,495.304 9,495.304 ↑ 1.0 2 1,356,472

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.007 rows=2 loops=1,356,472)

  • Index Cond: (empleado_id = emplea.id)
  • Rows Removed by Index Recheck: 0
38. 449.712 29,980.800 ↑ 1.0 1 49,968

Aggregate (cost=1,756.76..1,756.77 rows=1 width=8) (actual time=0.599..0.600 rows=1 loops=49,968)

39. 649.584 29,531.088 ↑ 6.3 6 49,968

Nested Loop (cost=0.72..1,756.67 rows=38 width=8) (actual time=0.070..0.591 rows=6 loops=49,968)

40. 199.872 199.872 ↑ 1.0 1 49,968

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

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 188
41. 1,891.984 28,681.632 ↑ 6.3 6 49,968

Nested Loop (cost=0.43..1,752.98 rows=38 width=16) (actual time=0.063..0.574 rows=6 loops=49,968)

42. 2,970.810 22,835.376 ↑ 5.8 10 49,968

Index Scan using empleados_npatronal_id_idx on empleados empleados_1 (cost=0.43..1,403.10 rows=58 width=24) (actual time=0.039..0.457 rows=10 loops=49,968)

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

SubPlan (forIndex Scan)

44. 2,207.174 19,864.566 ↑ 1.0 1 1,103,587

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

45. 5,517.935 17,657.392 ↑ 2.0 1 1,103,587

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

  • Sort Key: empleados_movimientos_2.fecha, empleados_movimientos_2.id
  • Sort Method: quicksort Memory: 25kB
46. 5,519.507 12,139.457 ↑ 1.0 2 1,103,587

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

  • One-Time Filter: (empleados_1.empresa_id = emp.id)
47. 6,619.950 6,619.950 ↑ 1.0 2 1,103,325

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

  • Index Cond: (empleado_id = empleados_1.id)
  • Rows Removed by Index Recheck: 0
48. 3,954.272 3,954.272 ↑ 1.0 1 494,284

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

  • Index Cond: (id = empleados_1.persona_id)
  • Rows Removed by Index Recheck: 0
  • Filter: ((sexo)::text = 'M'::text)
  • Rows Removed by Filter: 0
49. 299.808 27,282.528 ↑ 1.0 1 49,968

Aggregate (cost=1,756.54..1,756.55 rows=1 width=8) (actual time=0.545..0.546 rows=1 loops=49,968)

50. 449.712 26,982.720 ↑ 6.7 3 49,968

Nested Loop (cost=0.72..1,756.49 rows=20 width=8) (actual time=0.105..0.540 rows=3 loops=49,968)

51. 199.872 199.872 ↑ 1.0 1 49,968

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

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 188
52. 1,720.496 26,333.136 ↑ 6.7 3 49,968

Nested Loop (cost=0.43..1,752.98 rows=20 width=16) (actual time=0.099..0.527 rows=3 loops=49,968)

53. 2,770.938 22,635.504 ↑ 5.8 10 49,968

Index Scan using empleados_npatronal_id_idx on empleados empleados_2 (cost=0.43..1,403.10 rows=58 width=24) (actual time=0.039..0.453 rows=10 loops=49,968)

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

SubPlan (forIndex Scan)

55. 3,310.761 19,864.566 ↑ 1.0 1 1,103,587

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

56. 4,414.348 16,553.805 ↑ 2.0 1 1,103,587

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

  • Sort Key: empleados_movimientos_3.fecha, empleados_movimientos_3.id
  • Sort Method: quicksort Memory: 25kB
57. 5,519.507 12,139.457 ↑ 1.0 2 1,103,587

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

  • One-Time Filter: (empleados_2.empresa_id = emp.id)
58. 6,619.950 6,619.950 ↑ 1.0 2 1,103,325

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

  • Index Cond: (empleado_id = empleados_2.id)
  • Rows Removed by Index Recheck: 0
59. 1,977.136 1,977.136 ↓ 0.0 0 494,284

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

  • Index Cond: (id = empleados_2.persona_id)
  • Rows Removed by Index Recheck: 0
  • Filter: ((sexo)::text = 'F'::text)
  • Rows Removed by Filter: 1
60. 99.936 2,748.240 ↑ 1.0 1 49,968

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

61. 249.840 2,648.304 ↑ 1.0 1 49,968

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

  • Sort Key: cambio_situacion_empresa.fecha_creacion, cambio_situacion_empresa.id_cambio_situacion_empresa
  • Sort Method: quicksort Memory: 25kB
62. 617.426 2,398.464 ↑ 1.0 1 49,968

Nested Loop (cost=0.00..7.18 rows=1 width=134) (actual time=0.036..0.048 rows=1 loops=49,968)

  • Join Filter: (cambio_situacion_empresa.situacion_act = situacion_emp.id_situacion)
  • Rows Removed by Join Filter: 7
63. 1,399.104 1,399.104 ↑ 1.0 1 49,968

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.025..0.028 rows=1 loops=49,968)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
64. 381.934 381.934 ↑ 1.0 7 54,562

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