explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 0tk

Settings
# exclusive inclusive rows x rows loops node
1. 2.799 1,050.637 ↑ 1.0 1,000 1

Limit (cost=0.86..8,371,889.40 rows=1,000 width=469) (actual time=1.080..1,050.637 rows=1,000 loops=1)

2. 33.487 1,047.838 ↑ 52.4 1,000 1

Nested Loop Left Join (cost=0.86..438,829,282.18 rows=52,417 width=469) (actual time=1.077..1,047.838 rows=1,000 loops=1)

3. 5.028 172.351 ↑ 52.4 1,000 1

Nested Loop Left Join (cost=0.86..49,070.92 rows=52,417 width=449) (actual time=0.168..172.351 rows=1,000 loops=1)

  • Join Filter: (empresas_sucursales.type = empresas_sucursales_types.id)
4. 7.806 165.323 ↑ 52.4 1,000 1

Nested Loop Left Join (cost=0.86..48,283.63 rows=52,417 width=442) (actual time=0.133..165.323 rows=1,000 loops=1)

5. 3.993 128.517 ↑ 52.4 1,000 1

Nested Loop Left Join (cost=0.86..46,812.16 rows=52,417 width=388) (actual time=0.117..128.517 rows=1,000 loops=1)

6. 5.721 117.524 ↑ 52.4 1,000 1

Nested Loop Left Join (cost=0.72..38,157.36 rows=52,417 width=377) (actual time=0.106..117.524 rows=1,000 loops=1)

7. 10.832 90.803 ↑ 52.4 1,000 1

Nested Loop Left Join (cost=0.58..29,097.42 rows=52,417 width=341) (actual time=0.091..90.803 rows=1,000 loops=1)

8. 11.191 72.971 ↑ 52.4 1,000 1

Nested Loop Left Join (cost=0.58..27,645.92 rows=52,417 width=327) (actual time=0.059..72.971 rows=1,000 loops=1)

9. 4.591 50.780 ↑ 52.4 1,000 1

Nested Loop (cost=0.58..26,194.41 rows=52,417 width=312) (actual time=0.040..50.780 rows=1,000 loops=1)

10. 24.189 24.189 ↑ 52.4 1,000 1

Index Scan Backward using empresas_sucursales_nro_patronal_key on empresas_sucursales (cost=0.29..5,658.86 rows=52,420 width=239) (actual time=0.016..24.189 rows=1,000 loops=1)

  • Filter: (type = 1)
  • Rows Removed by Filter: 149
11. 22.000 22.000 ↑ 1.0 1 1,000

Index Scan using empresas_pk on empresas emp (cost=0.29..0.38 rows=1 width=81) (actual time=0.019..0.022 rows=1 loops=1,000)

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

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

  • Index Cond: (emp.type = id)
13. 7.000 7.000 ↑ 1.0 1 1,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=1 loops=1,000)

  • Index Cond: (emp.id_categoria_empresa = id_categoria_empresa)
14. 21.000 21.000 ↑ 1.0 1 1,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.021 rows=1 loops=1,000)

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

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

  • Index Cond: (empresas_sucursales.distrito_id = id)
16. 29.000 29.000 ↑ 1.0 1 1,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.029 rows=1 loops=1,000)

  • Index Cond: (empresas_sucursales.id_activ_econ = id_activ_econ)
17. 1.974 2.000 ↑ 1.0 1 1,000

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

18. 0.026 0.026 ↑ 1.0 1 1

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

  • Filter: (id = 1)
  • Rows Removed by Filter: 2
19. 9.000 9.000 ↑ 1.0 1 1,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.007..0.009 rows=1 loops=1,000)

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

SubPlan (forNested Loop Left Join)

21. 9.000 273.000 ↑ 1.0 1 1,000

Aggregate (cost=1,978.02..1,978.03 rows=1 width=8) (actual time=0.273..0.273 rows=1 loops=1,000)

22. 20.000 264.000 ↑ 61.0 1 1,000

Nested Loop (cost=0.29..1,977.87 rows=61 width=8) (actual time=0.152..0.264 rows=1 loops=1,000)

23. 22.000 22.000 ↑ 1.0 1 1,000

Index Only Scan using empresas_sucursales_nro_patronal_key on empresas_sucursales es (cost=0.29..2.31 rows=1 width=4) (actual time=0.021..0.022 rows=1 loops=1,000)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 0
24. 115.119 222.000 ↑ 61.0 1 1,000

Index Scan using empleados_npatronal_idx on empleados (cost=0.00..1,974.95 rows=61 width=24) (actual time=0.118..0.222 rows=1 loops=1,000)

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

SubPlan (forIndex Scan)

26. 13.941 106.881 ↑ 1.0 1 1,549

Limit (cost=14.15..14.15 rows=1 width=20) (actual time=0.069..0.069 rows=1 loops=1,549)

27. 13.941 92.940 ↑ 1.0 1 1,549

Sort (cost=14.15..14.15 rows=1 width=20) (actual time=0.060..0.060 rows=1 loops=1,549)

  • Sort Key: empleados_movimientos.fecha, empleados_movimientos.id
  • Sort Method: quicksort Memory: 25kB
28. 12.392 78.999 ↑ 1.0 1 1,549

Result (cost=0.43..14.14 rows=1 width=20) (actual time=0.044..0.051 rows=1 loops=1,549)

  • One-Time Filter: (empleados.empresa_id = emp.id)
29. 37.367 66.607 ↑ 1.0 1 1,549

Index Scan using empleados_movimientos_empleado_id_tipo_idx on empleados_movimientos (cost=0.43..14.13 rows=1 width=20) (actual time=0.040..0.043 rows=1 loops=1,549)

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

SubPlan (forIndex Scan)

31. 29.240 29.240 ↓ 0.0 0 1,720

Index Scan using multas_id_registro_multado_idx on multas (cost=0.00..4.02 rows=1 width=8) (actual time=0.017..0.017 rows=0 loops=1,720)

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

Aggregate (cost=2,129.31..2,129.34 rows=1 width=16) (actual time=0.107..0.108 rows=1 loops=1,000)

33. 17.172 87.000 ↑ 75.0 1 1,000

Index Only Scan using empleados_empresa_id_id_idx on empleados emplea (cost=0.43..2,127.81 rows=75 width=16) (actual time=0.033..0.087 rows=1 loops=1,000)

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

SubPlan (forIndex Only Scan)

35. 4.761 69.828 ↑ 1.0 1 1,587

Limit (cost=14.15..14.15 rows=1 width=20) (actual time=0.044..0.044 rows=1 loops=1,587)

36. 15.870 65.067 ↑ 1.0 1 1,587

Sort (cost=14.15..14.15 rows=1 width=20) (actual time=0.041..0.041 rows=1 loops=1,587)

  • Sort Key: empleados_movimientos_1.fecha, empleados_movimientos_1.id
  • Sort Method: quicksort Memory: 25kB
37. 36.877 49.197 ↑ 1.0 1 1,587

Index Scan using empleados_movimientos_empleado_id_tipo_idx on empleados_movimientos empleados_movimientos_1 (cost=0.43..14.14 rows=1 width=20) (actual time=0.028..0.031 rows=1 loops=1,587)

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

SubPlan (forIndex Scan)

39. 12.320 12.320 ↓ 0.0 0 1,760

Index Scan using multas_id_registro_multado_idx on multas multas_1 (cost=0.00..4.02 rows=1 width=8) (actual time=0.007..0.007 rows=0 loops=1,760)

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

Aggregate (cost=2,128.02..2,128.03 rows=1 width=8) (actual time=0.228..0.228 rows=1 loops=1,000)

41. 11.000 223.000 ↑ 32.0 1 1,000

Nested Loop (cost=0.72..2,127.94 rows=32 width=8) (actual time=0.097..0.223 rows=1 loops=1,000)

42. 5.000 5.000 ↑ 1.0 1 1,000

Index Only Scan using empresas_sucursales_nro_patronal_key on empresas_sucursales es_1 (cost=0.29..2.31 rows=1 width=4) (actual time=0.004..0.005 rows=1 loops=1,000)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 0
43. 9.012 207.000 ↑ 32.0 1 1,000

Nested Loop (cost=0.43..2,125.31 rows=32 width=16) (actual time=0.088..0.207 rows=1 loops=1,000)

44. 25.119 132.000 ↑ 61.0 1 1,000

Index Scan using empleados_npatronal_idx on empleados empleados_1 (cost=0.00..1,974.95 rows=61 width=24) (actual time=0.048..0.132 rows=1 loops=1,000)

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

SubPlan (forIndex Scan)

46. 7.745 106.881 ↑ 1.0 1 1,549

Limit (cost=14.15..14.15 rows=1 width=20) (actual time=0.069..0.069 rows=1 loops=1,549)

47. 15.490 99.136 ↑ 1.0 1 1,549

Sort (cost=14.15..14.15 rows=1 width=20) (actual time=0.064..0.064 rows=1 loops=1,549)

  • Sort Key: empleados_movimientos_2.fecha, empleados_movimientos_2.id
  • Sort Method: quicksort Memory: 25kB
48. 12.392 83.646 ↑ 1.0 1 1,549

Result (cost=0.43..14.14 rows=1 width=20) (actual time=0.041..0.054 rows=1 loops=1,549)

  • One-Time Filter: (empleados_1.empresa_id = emp.id)
49. 35.134 71.254 ↑ 1.0 1 1,549

Index Scan using empleados_movimientos_empleado_id_tipo_idx on empleados_movimientos empleados_movimientos_2 (cost=0.43..14.13 rows=1 width=20) (actual time=0.035..0.046 rows=1 loops=1,549)

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

SubPlan (forIndex Scan)

51. 36.120 36.120 ↓ 0.0 0 1,720

Index Scan using multas_id_registro_multado_idx on multas multas_2 (cost=0.00..4.02 rows=1 width=8) (actual time=0.021..0.021 rows=0 loops=1,720)

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

Index Only Scan using persons_id_sexo_idx on persons (cost=0.43..2.46 rows=1 width=8) (actual time=0.046..0.047 rows=1 loops=1,404)

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

Aggregate (cost=2,127.98..2,127.99 rows=1 width=8) (actual time=0.171..0.178 rows=1 loops=1,000)

54. 7.000 168.000 ↓ 0.0 0 1,000

Nested Loop (cost=0.72..2,127.91 rows=29 width=8) (actual time=0.110..0.168 rows=0 loops=1,000)

55. 5.000 5.000 ↑ 1.0 1 1,000

Index Only Scan using empresas_sucursales_nro_patronal_key on empresas_sucursales es_2 (cost=0.29..2.31 rows=1 width=4) (actual time=0.004..0.005 rows=1 loops=1,000)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 0
56. 13.748 156.000 ↓ 0.0 0 1,000

Nested Loop (cost=0.43..2,125.31 rows=29 width=16) (actual time=0.099..0.156 rows=0 loops=1,000)

57. 21.766 124.000 ↑ 61.0 1 1,000

Index Scan using empleados_npatronal_idx on empleados empleados_2 (cost=0.00..1,974.95 rows=61 width=24) (actual time=0.045..0.124 rows=1 loops=1,000)

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

SubPlan (forIndex Scan)

59. 6.196 102.234 ↑ 1.0 1 1,549

Limit (cost=14.15..14.15 rows=1 width=20) (actual time=0.066..0.066 rows=1 loops=1,549)

60. 38.725 96.038 ↑ 1.0 1 1,549

Sort (cost=14.15..14.15 rows=1 width=20) (actual time=0.062..0.062 rows=1 loops=1,549)

  • Sort Key: empleados_movimientos_3.fecha, empleados_movimientos_3.id
  • Sort Method: quicksort Memory: 25kB
61. 13.941 57.313 ↑ 1.0 1 1,549

Result (cost=0.43..14.14 rows=1 width=20) (actual time=0.031..0.037 rows=1 loops=1,549)

  • One-Time Filter: (empleados_2.empresa_id = emp.id)
62. 24.452 43.372 ↑ 1.0 1 1,549

Index Scan using empleados_movimientos_empleado_id_tipo_idx on empleados_movimientos empleados_movimientos_3 (cost=0.43..14.13 rows=1 width=20) (actual time=0.024..0.028 rows=1 loops=1,549)

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

SubPlan (forIndex Scan)

64. 18.920 18.920 ↓ 0.0 0 1,720

Index Scan using multas_id_registro_multado_idx on multas multas_3 (cost=0.00..4.02 rows=1 width=8) (actual time=0.011..0.011 rows=0 loops=1,720)

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

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

  • Index Cond: ((id = empleados_2.persona_id) AND (sexo = 'F'::text))
  • Heap Fetches: 0
66. 8.000 46.000 ↑ 1.0 1 1,000

Limit (cost=7.53..7.53 rows=1 width=27) (actual time=0.043..0.046 rows=1 loops=1,000)

67. 12.000 38.000 ↑ 2.0 1 1,000

Sort (cost=7.53..7.53 rows=2 width=27) (actual time=0.038..0.038 rows=1 loops=1,000)

  • Sort Key: cambio_situacion_empresa.fecha_creacion, cambio_situacion_empresa.id_cambio_situacion_empresa
  • Sort Method: quicksort Memory: 25kB
68. 6.979 26.000 ↑ 2.0 1 1,000

Hash Join (cost=1.57..7.52 rows=2 width=27) (actual time=0.023..0.026 rows=1 loops=1,000)

  • Hash Cond: (cambio_situacion_empresa.situacion_act = situacion_emp.id_situacion)
69. 19.000 19.000 ↑ 2.0 1 1,000

Index Scan using cambio_situacion_empresa_nro_patronal_fecha_creacion_id_cam_idx on cambio_situacion_empresa (cost=0.42..6.33 rows=2 width=20) (actual time=0.018..0.019 rows=1 loops=1,000)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
70. 0.009 0.021 ↑ 1.0 7 1

Hash (cost=1.07..1.07 rows=7 width=15) (actual time=0.021..0.021 rows=7 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
71. 0.012 0.012 ↑ 1.0 7 1

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