explain.depesz.com

PostgreSQL's explain analyze made readable

Result: naM

Settings

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 644.326 119,172.160 ↓ 1.2 49,968 1

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

2. 0.018 0.018 ↑ 1.0 1 1

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Seq Scan on empresas emp (cost=0.00..2,410.94 rows=49,822 width=82) (actual time=0.010..58.350 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.024 0.061 ↓ 1.2 30 1

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

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

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

14. 0.003 0.017 ↑ 35.0 4 1

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

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

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

16. 0.229 0.445 ↑ 1.1 251 1

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

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

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

18. 0.019 0.036 ↑ 1.2 18 1

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

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

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

20. 0.604 1.162 ↑ 1.0 700 1

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

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

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

22.          

SubPlan (forNested Loop)

23. 599.616 30,680.352 ↑ 1.0 1 49,968

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

24. 999.360 30,080.736 ↑ 5.8 10 49,968

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

25. 299.808 299.808 ↑ 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.005..0.006 rows=1 loops=49,968)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 172
26. 4,502.918 28,781.568 ↑ 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.058..0.576 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.150 24,278.650 ↑ 1.0 1 1,103,575

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

29. 5,517.875 22,071.500 ↑ 2.0 1 1,103,575

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

  • Sort Key: empleados_movimientos.fecha, empleados_movimientos.id
  • Sort Method: quicksort Memory: 25kB
30. 5,520.495 16,553.625 ↑ 1.0 2 1,103,575

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

  • One-Time Filter: (empleados.empresa_id = emp.id)
31. 11,033.130 11,033.130 ↑ 1.0 2 1,103,313

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

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

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

33. 3,038.184 23,385.024 ↑ 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.042..0.468 rows=12 loops=49,968)

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

SubPlan (forIndex Only Scan)

35. 4,069.368 20,346.840 ↑ 1.0 1 1,356,456

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

36. 6,782.280 16,277.472 ↑ 2.0 1 1,356,456

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

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

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.005..0.007 rows=2 loops=1,356,456)

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

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

39. 649.584 31,629.744 ↑ 6.3 6 49,968

Nested Loop (cost=0.72..1,756.67 rows=38 width=8) (actual time=0.073..0.633 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: 172
41. 1,902.696 30,780.288 ↑ 6.3 6 49,968

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

42. 2,966.747 23,934.672 ↑ 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.040..0.479 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. 3,310.725 20,967.925 ↑ 1.0 1 1,103,575

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

45. 4,414.300 17,657.200 ↑ 2.0 1 1,103,575

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

  • Sort Key: empleados_movimientos_2.fecha, empleados_movimientos_2.id
  • Sort Method: quicksort Memory: 25kB
46. 6,623.022 13,242.900 ↑ 1.0 2 1,103,575

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

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

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

  • Index Cond: (empleado_id = empleados_1.id)
  • Rows Removed by Index Recheck: 0
48. 4,942.920 4,942.920 ↑ 1.0 1 494,292

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

  • 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 28,481.760 ↑ 1.0 1 49,968

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

50. 449.712 28,181.952 ↑ 6.7 3 49,968

Nested Loop (cost=0.72..1,756.49 rows=20 width=8) (actual time=0.110..0.564 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: 172
52. 1,525.980 27,532.368 ↑ 6.7 3 49,968

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

53. 3,670.578 23,534.928 ↑ 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.041..0.471 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. 2,207.150 19,864.350 ↑ 1.0 1 1,103,575

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

56. 4,414.300 17,657.200 ↑ 2.0 1 1,103,575

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

  • Sort Key: empleados_movimientos_3.fecha, empleados_movimientos_3.id
  • Sort Method: quicksort Memory: 25kB
57. 6,623.022 13,242.900 ↑ 1.0 2 1,103,575

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

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

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

  • Index Cond: (empleado_id = empleados_2.id)
  • Rows Removed by Index Recheck: 0
59. 2,471.460 2,471.460 ↓ 0.0 0 494,292

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

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

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

61. 199.872 2,098.656 ↑ 1.0 1 49,968

Sort (cost=7.19..7.19 rows=1 width=134) (actual time=0.042..0.042 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. 667.471 1,898.784 ↑ 1.0 1 49,968

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

  • Join Filter: (cambio_situacion_empresa.situacion_act = situacion_emp.id_situacion)
  • Rows Removed by Join Filter: 7
63. 849.456 849.456 ↑ 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.013..0.017 rows=1 loops=49,968)

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

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