explain.depesz.com

PostgreSQL's explain analyze made readable

Result: hFA9

Settings
# exclusive inclusive rows x rows loops node
1. 648.279 123,990.418 ↓ 1.2 49,968 1

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

2. 0.119 0.119 ↑ 1.0 1 1

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

14. 0.006 0.021 ↑ 35.0 4 1

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

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

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

16. 0.296 0.607 ↑ 1.1 251 1

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

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

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

18. 0.022 0.047 ↑ 1.2 18 1

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

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

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

20. 0.711 1.383 ↑ 1.0 700 1

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

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

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

22.          

SubPlan (forNested Loop)

23. 599.616 33,178.752 ↑ 1.0 1 49,968

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

24. 999.360 32,579.136 ↑ 5.8 10 49,968

Nested Loop (cost=0.72..1,406.98 rows=58 width=8) (actual time=0.093..0.652 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. 5,897.904 31,279.968 ↑ 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.084..0.626 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.136 25,382.064 ↑ 1.0 1 1,103,568

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

29. 5,517.840 23,174.928 ↑ 2.0 1 1,103,568

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

  • Sort Key: empleados_movimientos.fecha, empleados_movimientos.id
  • Sort Method: quicksort Memory: 25kB
30. 6,624.028 17,657.088 ↑ 1.0 2 1,103,568

Result (cost=0.00..9.05 rows=2 width=20) (actual time=0.010..0.016 rows=2 loops=1,103,568)

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

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

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

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

33. 3,837.867 24,184.512 ↑ 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.484 rows=12 loops=49,968)

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

SubPlan (forIndex Only Scan)

35. 2,712.886 20,346.645 ↑ 1.0 1 1,356,443

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

36. 8,138.658 17,633.759 ↑ 2.0 1 1,356,443

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

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

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

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

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

39. 699.552 32,079.456 ↑ 6.3 6 49,968

Nested Loop (cost=0.72..1,756.67 rows=38 width=8) (actual time=0.075..0.642 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. 2,097.072 31,180.032 ↑ 6.3 6 49,968

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

42. 3,666.432 24,634.224 ↑ 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.042..0.493 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.136 20,967.792 ↑ 1.0 1 1,103,568

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

45. 5,517.840 18,760.656 ↑ 2.0 1 1,103,568

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

  • Sort Key: empleados_movimientos_2.fecha, empleados_movimientos_2.id
  • Sort Method: quicksort Memory: 25kB
46. 6,622.980 13,242.816 ↑ 1.0 2 1,103,568

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

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

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

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

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

  • 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 29,431.152 ↑ 1.0 1 49,968

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

50. 499.680 29,131.344 ↑ 6.7 3 49,968

Nested Loop (cost=0.72..1,756.49 rows=20 width=8) (actual time=0.113..0.583 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,675.824 28,431.792 ↑ 6.7 3 49,968

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

53. 3,316.656 24,284.448 ↑ 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.042..0.486 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.136 20,967.792 ↑ 1.0 1 1,103,568

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

56. 5,517.840 18,760.656 ↑ 2.0 1 1,103,568

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

  • Sort Key: empleados_movimientos_3.fecha, empleados_movimientos_3.id
  • Sort Method: quicksort Memory: 25kB
57. 6,622.980 13,242.816 ↑ 1.0 2 1,103,568

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

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

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

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

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

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

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

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

Sort (cost=7.19..7.19 rows=1 width=134) (actual time=0.043..0.043 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. 612.984 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. 436.344 436.344 ↑ 1.0 7 54,543

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