explain.depesz.com

PostgreSQL's explain analyze made readable

Result: HFSt

Settings
# exclusive inclusive rows x rows loops node
1. 24.775 33,676.682 ↑ 1.0 10,000 1

Limit (cost=0.86..86,606,667.25 rows=10,000 width=469) (actual time=121.258..33,676.682 rows=10,000 loops=1)

2. 461.523 33,651.907 ↑ 5.2 10,000 1

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

3. 89.209 2,750.384 ↑ 5.2 10,000 1

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

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

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

5. 153.260 2,213.120 ↑ 5.2 10,000 1

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

6. 138.581 1,909.860 ↑ 5.2 10,000 1

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

7. 75.366 1,551.279 ↑ 5.2 10,000 1

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

8. 140.112 1,325.913 ↑ 5.2 10,000 1

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

9. 78.936 795.801 ↑ 5.2 10,000 1

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

10. 246.865 246.865 ↑ 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=5.246..246.865 rows=10,000 loops=1)

  • Filter: (type = 1)
  • Rows Removed by Filter: 3017
11. 470.000 470.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.043..0.047 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. 390.000 390.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.035..0.039 rows=1 loops=10,000)

  • Index Cond: (emp.type = id)
13. 150.000 150.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.014..0.015 rows=0 loops=10,000)

  • Index Cond: (emp.id_categoria_empresa = id_categoria_empresa)
14. 220.000 220.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.021..0.022 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.013..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.024..0.028 rows=1 loops=10,000)

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

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

18. 0.019 0.019 ↑ 1.0 1 1

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

  • Filter: (id = 1)
  • Rows Removed by Filter: 2
19. 280.000 280.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.024..0.028 rows=1 loops=10,000)

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

SubPlan (forNested Loop Left Join)

21. 140.000 10,940.000 ↑ 1.0 1 10,000

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

22. 170.000 10,800.000 ↑ 20.0 3 10,000

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

23. 150.000 150.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.011..0.015 rows=1 loops=10,000)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 15
24. 2,177.107 10,480.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.391..1.048 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. 226.855 8,302.893 ↑ 1.0 1 45,371

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

27. 544.452 8,076.038 ↑ 1.0 1 45,371

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

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

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

  • One-Time Filter: (empleados.empresa_id = emp.id)
29. 5,956.500 7,077.876 ↓ 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.117..0.156 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,121.376 1,121.376 ↓ 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.016..0.016 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. 160.000 4,820.000 ↑ 1.0 1 10,000

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

33. 927.700 4,660.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.156..0.466 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. 199.056 3,732.300 ↑ 1.0 1 49,764

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

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

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

  • Sort Key: empleados_movimientos_1.fecha, empleados_movimientos_1.id
  • Sort Method: quicksort Memory: 25kB
37. 2,094.598 2,936.076 ↓ 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.043..0.059 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. 110.000 7,620.000 ↑ 1.0 1 10,000

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

41. 120.000 7,510.000 ↑ 15.5 2 10,000

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

42. 220.000 220.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.018..0.022 rows=1 loops=10,000)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 15
43. 196.018 7,170.000 ↑ 15.5 2 10,000

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

44. 868.094 4,770.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.125..0.477 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,901.906 ↑ 1.0 1 45,371

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

47. 499.081 3,675.051 ↑ 1.0 1 45,371

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

  • Sort Key: empleados_movimientos_2.fecha, empleados_movimientos_2.id
  • Sort Method: quicksort Memory: 25kB
48. 499.081 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_1.empresa_id = emp.id)
49. 1,835.857 2,676.889 ↓ 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.059 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. 841.032 841.032 ↓ 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.012..0.012 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. 2,203.982 2,203.982 ↑ 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.081..0.083 rows=1 loops=26,554)

  • Index Cond: ((id = empleados_1.persona_id) AND (sexo = 'M'::text))
  • Heap Fetches: 919
53. 80.000 6,080.000 ↑ 1.0 1 10,000

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

54. 80.000 6,000.000 ↑ 29.0 1 10,000

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

55. 250.000 250.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.024..0.025 rows=1 loops=10,000)

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

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

57. 761.981 4,800.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.131..0.480 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. 226.855 4,038.019 ↑ 1.0 1 45,371

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

60. 680.565 3,811.164 ↑ 1.0 1 45,371

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

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

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

  • One-Time Filter: (empleados_2.empresa_id = emp.id)
62. 1,905.943 2,676.889 ↓ 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.044..0.059 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. 770.946 770.946 ↓ 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.011..0.011 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. 663.850 663.850 ↓ 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.025..0.025 rows=0 loops=26,554)

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

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

67. 151.645 640.000 ↑ 2.0 1 10,000

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

  • Join Filter: (cambio_situacion_empresa.situacion_act = situacion_emp.id_situacion)
  • Rows Removed by Join Filter: 4
68. 420.000 420.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.042..0.042 rows=1 loops=10,000)

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

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

70. 0.015 0.015 ↑ 1.0 7 1

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