explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 7FJf

Settings
# exclusive inclusive rows x rows loops node
1. 24.520 31,874.076 ↑ 1.0 10,000 1

Limit (cost=0.86..86,606,667.25 rows=10,000 width=469) (actual time=4.755..31,874.076 rows=10,000 loops=1)

2. 400.819 31,849.556 ↑ 5.2 10,000 1

Nested Loop Left Join (cost=0.86..452,978,848.05 rows=52,303 width=469) (actual time=4.753..31,849.556 rows=10,000 loops=1)

3. 93.830 2,528.737 ↑ 5.2 10,000 1

Nested Loop Left Join (cost=0.86..48,984.76 rows=52,303 width=449) (actual time=4.308..2,528.737 rows=10,000 loops=1)

  • Join Filter: (empresas_sucursales.type = empresas_sucursales_types.id)
4. 115.315 2,404.907 ↑ 5.2 10,000 1

Nested Loop Left Join (cost=0.86..48,199.17 rows=52,303 width=442) (actual time=4.269..2,404.907 rows=10,000 loops=1)

5. 86.470 2,009.592 ↑ 5.2 10,000 1

Nested Loop Left Join (cost=0.86..46,730.84 rows=52,303 width=388) (actual time=4.249..2,009.592 rows=10,000 loops=1)

6. 86.163 1,773.122 ↑ 5.2 10,000 1

Nested Loop Left Join (cost=0.72..38,094.85 rows=52,303 width=377) (actual time=4.235..1,773.122 rows=10,000 loops=1)

7. 83.926 1,446.959 ↑ 5.2 10,000 1

Nested Loop Left Join (cost=0.58..29,054.58 rows=52,303 width=341) (actual time=4.216..1,446.959 rows=10,000 loops=1)

8. 124.668 1,293.033 ↑ 5.2 10,000 1

Nested Loop Left Join (cost=0.58..27,606.23 rows=52,303 width=327) (actual time=4.199..1,293.033 rows=10,000 loops=1)

9. 87.053 868.365 ↑ 5.2 10,000 1

Nested Loop (cost=0.58..26,157.88 rows=52,303 width=312) (actual time=4.172..868.365 rows=10,000 loops=1)

10. 301.312 301.312 ↑ 5.2 10,000 1

Index Scan Backward using empresas_sucursales_nro_patronal_key on empresas_sucursales (cost=0.29..5,659.67 rows=52,306 width=238) (actual time=0.044..301.312 rows=10,000 loops=1)

  • Filter: (type = 1)
  • Rows Removed by Filter: 3017
11. 480.000 480.000 ↑ 1.0 1 10,000

Index Scan using empresas_id_idx on empresas emp (cost=0.29..0.38 rows=1 width=82) (actual time=0.045..0.048 rows=1 loops=10,000)

  • Index Cond: (id = empresas_sucursales.empresa_id)
  • Filter: (((document)::text <> '0'::text) AND ((document)::text <> ''::text) AND ((document)::text <> '-'::text))
12. 300.000 300.000 ↑ 1.0 1 10,000

Index Scan using empresas_types_id_idx on empresas_types (cost=0.00..0.02 rows=1 width=23) (actual time=0.028..0.030 rows=1 loops=10,000)

  • Index Cond: (emp.type = id)
13. 70.000 70.000 ↓ 0.0 0 10,000

Index Scan using empresas_categorias_id_categoria_empresa_idx on empresas_categorias (cost=0.00..0.02 rows=1 width=18) (actual time=0.006..0.007 rows=0 loops=10,000)

  • Index Cond: (emp.id_categoria_empresa = id_categoria_empresa)
14. 240.000 240.000 ↑ 1.0 1 10,000

Index Scan using city_id_distrito_id_idx on city (cost=0.14..0.16 rows=1 width=40) (actual time=0.019..0.024 rows=1 loops=10,000)

  • Index Cond: (empresas_sucursales.city_id = id)
15. 150.000 150.000 ↑ 1.0 1 10,000

Index Scan using distritos_pkey on distritos (cost=0.14..0.16 rows=1 width=19) (actual time=0.014..0.015 rows=1 loops=10,000)

  • Index Cond: (empresas_sucursales.distrito_id = id)
16. 280.000 280.000 ↑ 1.0 1 10,000

Index Scan using actividad_econ_id_activ_econ_idx on actividad_econ (cost=0.00..0.02 rows=1 width=58) (actual time=0.025..0.028 rows=1 loops=10,000)

  • Index Cond: (empresas_sucursales.id_activ_econ = id_activ_econ)
17. 29.977 30.000 ↑ 1.0 1 10,000

Materialize (cost=0.00..1.04 rows=1 width=23) (actual time=0.002..0.003 rows=1 loops=10,000)

18. 0.023 0.023 ↑ 1.0 1 1

Seq Scan on empresas_sucursales_types (cost=0.00..1.04 rows=1 width=23) (actual time=0.021..0.023 rows=1 loops=1)

  • Filter: (id = 1)
  • Rows Removed by Filter: 2
19. 240.000 240.000 ↑ 1.0 1 10,000

Index Scan using empresas_tipo_inscripcion_id_tipo_inscripcion_idx on empresas_tipo_inscripcion (cost=0.00..0.02 rows=1 width=24) (actual time=0.021..0.024 rows=1 loops=10,000)

  • Index Cond: (empresas_sucursales.id_tipo_inscripcion = id_tipo_inscripcion)
20.          

SubPlan (forNested Loop Left Join)

21. 110.000 9,950.000 ↑ 1.0 1 10,000

Aggregate (cost=2,048.45..2,048.46 rows=1 width=8) (actual time=0.994..0.995 rows=1 loops=10,000)

22. 190.000 9,840.000 ↑ 20.0 3 10,000

Nested Loop (cost=0.72..2,048.30 rows=60 width=8) (actual time=0.329..0.984 rows=3 loops=10,000)

23. 160.000 160.000 ↑ 1.0 1 10,000

Index Only Scan using empresas_sucursales_nro_patronal_idx on empresas_sucursales es (cost=0.29..2.31 rows=1 width=4) (actual time=0.014..0.016 rows=1 loops=10,000)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 15
24. 2,003.785 9,490.000 ↑ 20.0 3 10,000

Index Scan using empleados_npatronal_idx on empleados (cost=0.43..2,045.39 rows=60 width=24) (actual time=0.304..0.949 rows=3 loops=10,000)

  • Index Cond: (npatronal = empresas_sucursales.nro_patronal)
  • Filter: (SubPlan 2)
  • Rows Removed by Filter: 2
25.          

SubPlan (forIndex Scan)

26. 181.484 7,486.215 ↑ 1.0 1 45,371

Limit (cost=15.01..15.01 rows=1 width=20) (actual time=0.164..0.165 rows=1 loops=45,371)

27. 589.823 7,304.731 ↑ 1.0 1 45,371

Sort (cost=15.01..15.01 rows=1 width=20) (actual time=0.161..0.161 rows=1 loops=45,371)

  • Sort Key: empleados_movimientos.fecha, empleados_movimientos.id
  • Sort Method: quicksort Memory: 25kB
28. 453.710 6,714.908 ↓ 2.0 2 45,371

Result (cost=0.43..15.00 rows=1 width=20) (actual time=0.106..0.148 rows=2 loops=45,371)

  • One-Time Filter: (empleados.empresa_id = emp.id)
29. 5,209.908 6,261.198 ↓ 2.0 2 45,371

Index Scan using empleados_movimientos_empleado_id_tipo_idx on empleados_movimientos (cost=0.43..14.99 rows=1 width=20) (actual time=0.100..0.138 rows=2 loops=45,371)

  • Index Cond: (empleado_id = empleados.id)
  • Filter: (NOT (SubPlan 1))
  • Rows Removed by Filter: 0
30.          

SubPlan (forIndex Scan)

31. 1,051.290 1,051.290 ↓ 0.0 0 70,086

Index Scan using multas_id_registro_multado_idx on multas (cost=0.29..4.31 rows=1 width=8) (actual time=0.015..0.015 rows=0 loops=70,086)

  • Index Cond: (id_registro_multado = empleados_movimientos.id)
  • Filter: ((estado IS NULL) AND (idtipo_multa = 11))
  • Rows Removed by Filter: 0
32. 170.000 4,780.000 ↑ 1.0 1 10,000

Aggregate (cost=2,215.22..2,215.25 rows=1 width=16) (actual time=0.476..0.478 rows=1 loops=10,000)

33. 778.172 4,610.000 ↑ 24.7 3 10,000

Index Only Scan using empleados_empresa_id_id_idx on empleados emplea (cost=0.43..2,213.74 rows=74 width=16) (actual time=0.142..0.461 rows=3 loops=10,000)

  • Index Cond: (empresa_id = emp.id)
  • Filter: (SubPlan 5)
  • Rows Removed by Filter: 2
  • Heap Fetches: 182
34.          

SubPlan (forIndex Only Scan)

35. 248.820 3,831.828 ↑ 1.0 1 49,764

Limit (cost=15.01..15.01 rows=1 width=20) (actual time=0.077..0.077 rows=1 loops=49,764)

36. 597.168 3,583.008 ↑ 1.0 1 49,764

Sort (cost=15.01..15.01 rows=1 width=20) (actual time=0.072..0.072 rows=1 loops=49,764)

  • Sort Key: empleados_movimientos_1.fecha, empleados_movimientos_1.id
  • Sort Method: quicksort Memory: 25kB
37. 2,144.362 2,985.840 ↓ 2.0 2 49,764

Index Scan using empleados_movimientos_empleado_id_tipo_idx on empleados_movimientos empleados_movimientos_1 (cost=0.43..15.00 rows=1 width=20) (actual time=0.044..0.060 rows=2 loops=49,764)

  • Index Cond: (empleado_id = emplea.id)
  • Filter: (NOT (SubPlan 4))
  • Rows Removed by Filter: 0
38.          

SubPlan (forIndex Scan)

39. 841.478 841.478 ↓ 0.0 0 76,498

Index Scan using multas_id_registro_multado_idx on multas multas_1 (cost=0.29..4.31 rows=1 width=8) (actual time=0.011..0.011 rows=0 loops=76,498)

  • Index Cond: (id_registro_multado = empleados_movimientos_1.id)
  • Filter: ((estado IS NULL) AND (idtipo_multa = 11))
  • Rows Removed by Filter: 0
40. 100.000 7,190.000 ↑ 1.0 1 10,000

Aggregate (cost=2,195.99..2,196.00 rows=1 width=8) (actual time=0.718..0.719 rows=1 loops=10,000)

41. 130.000 7,090.000 ↑ 15.5 2 10,000

Nested Loop (cost=1.15..2,195.91 rows=31 width=8) (actual time=0.240..0.709 rows=2 loops=10,000)

42. 150.000 150.000 ↑ 1.0 1 10,000

Index Only Scan using empresas_sucursales_nro_patronal_idx on empresas_sucursales es_1 (cost=0.29..2.31 rows=1 width=4) (actual time=0.012..0.015 rows=1 loops=10,000)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 15
43. 284.328 6,810.000 ↑ 15.5 2 10,000

Nested Loop (cost=0.86..2,193.29 rows=31 width=16) (actual time=0.218..0.681 rows=2 loops=10,000)

44. 772.723 4,720.000 ↑ 20.0 3 10,000

Index Scan using empleados_npatronal_idx on empleados empleados_1 (cost=0.43..2,045.39 rows=60 width=24) (actual time=0.137..0.472 rows=3 loops=10,000)

  • Index Cond: (npatronal = empresas_sucursales.nro_patronal)
  • Filter: (SubPlan 8)
  • Rows Removed by Filter: 2
45.          

SubPlan (forIndex Scan)

46. 226.855 3,947.277 ↑ 1.0 1 45,371

Limit (cost=15.01..15.01 rows=1 width=20) (actual time=0.087..0.087 rows=1 loops=45,371)

47. 589.823 3,720.422 ↑ 1.0 1 45,371

Sort (cost=15.01..15.01 rows=1 width=20) (actual time=0.082..0.082 rows=1 loops=45,371)

  • Sort Key: empleados_movimientos_2.fecha, empleados_movimientos_2.id
  • Sort Method: quicksort Memory: 25kB
48. 499.081 3,130.599 ↓ 2.0 2 45,371

Result (cost=0.43..15.00 rows=1 width=20) (actual time=0.049..0.069 rows=2 loops=45,371)

  • One-Time Filter: (empleados_1.empresa_id = emp.id)
49. 1,860.572 2,631.518 ↓ 2.0 2 45,371

Index Scan using empleados_movimientos_empleado_id_tipo_idx on empleados_movimientos empleados_movimientos_2 (cost=0.43..14.99 rows=1 width=20) (actual time=0.043..0.058 rows=2 loops=45,371)

  • Index Cond: (empleado_id = empleados_1.id)
  • Filter: (NOT (SubPlan 7))
  • Rows Removed by Filter: 0
50.          

SubPlan (forIndex Scan)

51. 770.946 770.946 ↓ 0.0 0 70,086

Index Scan using multas_id_registro_multado_idx on multas multas_2 (cost=0.29..4.31 rows=1 width=8) (actual time=0.011..0.011 rows=0 loops=70,086)

  • Index Cond: (id_registro_multado = empleados_movimientos_2.id)
  • Filter: ((estado IS NULL) AND (idtipo_multa = 11))
  • Rows Removed by Filter: 0
52. 1,805.672 1,805.672 ↑ 1.0 1 26,554

Index Only Scan using persons_id_sexo_idx on persons (cost=0.43..2.46 rows=1 width=8) (actual time=0.066..0.068 rows=1 loops=26,554)

  • Index Cond: ((id = empleados_1.persona_id) AND (sexo = 'M'::text))
  • Heap Fetches: 903
53. 60.000 5,980.000 ↑ 1.0 1 10,000

Aggregate (cost=2,195.96..2,195.97 rows=1 width=8) (actual time=0.597..0.598 rows=1 loops=10,000)

54. 90.000 5,920.000 ↑ 29.0 1 10,000

Nested Loop (cost=1.15..2,195.89 rows=29 width=8) (actual time=0.287..0.592 rows=1 loops=10,000)

55. 140.000 140.000 ↑ 1.0 1 10,000

Index Only Scan using empresas_sucursales_nro_patronal_idx on empresas_sucursales es_2 (cost=0.29..2.31 rows=1 width=4) (actual time=0.012..0.014 rows=1 loops=10,000)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 15
56. 196.488 5,690.000 ↑ 29.0 1 10,000

Nested Loop (cost=0.86..2,193.29 rows=29 width=16) (actual time=0.268..0.569 rows=1 loops=10,000)

57. 711.981 4,750.000 ↑ 20.0 3 10,000

Index Scan using empleados_npatronal_idx on empleados empleados_2 (cost=0.43..2,045.39 rows=60 width=24) (actual time=0.136..0.475 rows=3 loops=10,000)

  • Index Cond: (npatronal = empresas_sucursales.nro_patronal)
  • Filter: (SubPlan 11)
  • Rows Removed by Filter: 2
58.          

SubPlan (forIndex Scan)

59. 272.226 4,038.019 ↑ 1.0 1 45,371

Limit (cost=15.01..15.01 rows=1 width=20) (actual time=0.088..0.089 rows=1 loops=45,371)

60. 589.823 3,765.793 ↑ 1.0 1 45,371

Sort (cost=15.01..15.01 rows=1 width=20) (actual time=0.083..0.083 rows=1 loops=45,371)

  • Sort Key: empleados_movimientos_3.fecha, empleados_movimientos_3.id
  • Sort Method: quicksort Memory: 25kB
61. 589.823 3,175.970 ↓ 2.0 2 45,371

Result (cost=0.43..15.00 rows=1 width=20) (actual time=0.049..0.070 rows=2 loops=45,371)

  • One-Time Filter: (empleados_2.empresa_id = emp.id)
62. 1,745.115 2,586.147 ↓ 2.0 2 45,371

Index Scan using empleados_movimientos_empleado_id_tipo_idx on empleados_movimientos empleados_movimientos_3 (cost=0.43..14.99 rows=1 width=20) (actual time=0.042..0.057 rows=2 loops=45,371)

  • Index Cond: (empleado_id = empleados_2.id)
  • Filter: (NOT (SubPlan 10))
  • Rows Removed by Filter: 0
63.          

SubPlan (forIndex Scan)

64. 841.032 841.032 ↓ 0.0 0 70,086

Index Scan using multas_id_registro_multado_idx on multas multas_3 (cost=0.29..4.31 rows=1 width=8) (actual time=0.012..0.012 rows=0 loops=70,086)

  • Index Cond: (id_registro_multado = empleados_movimientos_3.id)
  • Filter: ((estado IS NULL) AND (idtipo_multa = 11))
  • Rows Removed by Filter: 0
65. 743.512 743.512 ↓ 0.0 0 26,554

Index Only Scan using persons_id_sexo_idx on persons persons_1 (cost=0.43..2.46 rows=1 width=8) (actual time=0.027..0.028 rows=0 loops=26,554)

  • Index Cond: ((id = empleados_2.persona_id) AND (sexo = 'F'::text))
  • Heap Fetches: 444
66. 50.000 780.000 ↑ 1.0 1 10,000

Limit (cost=0.42..4.02 rows=1 width=27) (actual time=0.075..0.078 rows=1 loops=10,000)

67. 122.115 730.000 ↑ 2.0 1 10,000

Nested Loop (cost=0.42..7.62 rows=2 width=27) (actual time=0.073..0.073 rows=1 loops=10,000)

  • Join Filter: (cambio_situacion_empresa.situacion_act = situacion_emp.id_situacion)
  • Rows Removed by Join Filter: 4
68. 520.000 520.000 ↑ 2.0 1 10,000

Index Scan using cambio_situacion_empresa_nro_patronal_fecha_creacion_id_cam_idx on cambio_situacion_empresa (cost=0.42..6.32 rows=2 width=20) (actual time=0.052..0.052 rows=1 loops=10,000)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
69. 87.868 87.885 ↑ 1.4 5 9,765

Materialize (cost=0.00..1.10 rows=7 width=15) (actual time=0.002..0.009 rows=5 loops=9,765)

70. 0.017 0.017 ↑ 1.0 7 1

Seq Scan on situacion_emp (cost=0.00..1.07 rows=7 width=15) (actual time=0.006..0.017 rows=7 loops=1)