explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 5F6P

Settings
# exclusive inclusive rows x rows loops node
1. 545.990 108,396.958 ↓ 1.2 49,967 1

Nested Loop (cost=3,591.85..258,450,001.56 rows=41,977 width=964) (actual time=189.806..108,396.958 rows=49,967 loops=1)

2. 0.019 0.019 ↑ 1.0 1 1

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

  • Filter: (id = 1)
  • Rows Removed by Filter: 2
3. 112.076 871.602 ↓ 1.2 49,967 1

Hash Left Join (cost=3,591.85..8,952.96 rows=41,977 width=940) (actual time=189.568..871.602 rows=49,967 loops=1)

  • Hash Cond: (empresas_sucursales.id_activ_econ = actividad_econ.id_activ_econ)
4. 94.448 758.311 ↓ 1.2 49,967 1

Hash Left Join (cost=3,567.10..8,351.02 rows=41,977 width=886) (actual time=188.315..758.311 rows=49,967 loops=1)

  • Hash Cond: (empresas_sucursales.distrito_id = distritos.id)
5. 100.572 663.826 ↓ 1.2 49,967 1

Hash Left Join (cost=3,565.63..7,772.69 rows=41,977 width=876) (actual time=188.260..663.826 rows=49,967 loops=1)

  • Hash Cond: (empresas_sucursales.city_id = city.id)
6. 82.472 562.775 ↓ 1.2 49,967 1

Hash Left Join (cost=3,552.69..7,184.77 rows=41,977 width=840) (actual time=187.762..562.775 rows=49,967 loops=1)

  • Hash Cond: (emp.id_categoria_empresa = empresas_categorias.id_categoria_empresa)
7. 203.848 480.283 ↓ 1.2 49,967 1

Hash Join (cost=3,539.54..7,010.10 rows=41,977 width=324) (actual time=187.716..480.283 rows=49,967 loops=1)

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

Seq Scan on empresas_sucursales (cost=0.00..2,612.82 rows=50,053 width=237) (actual time=0.006..88.763 rows=49,969 loops=1)

  • Filter: (type = 1)
  • Rows Removed by Filter: 5621
9. 53.290 187.672 ↓ 1.2 49,828 1

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

  • Buckets: 8192 Batches: 1 Memory Usage: 5999kB
10. 77.524 134.382 ↓ 1.2 49,828 1

Hash Join (cost=1.58..3,017.22 rows=41,786 width=95) (actual time=0.110..134.382 rows=49,828 loops=1)

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

Seq Scan on empresas emp (cost=0.00..2,410.94 rows=49,822 width=82) (actual time=0.007..56.780 rows=49,828 loops=1)

  • Filter: (((document)::text <> '0'::text) AND ((document)::text <> ''::text) AND ((document)::text <> '-'::text))
  • Rows Removed by Filter: 2
12. 0.043 0.078 ↓ 1.2 30 1

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

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

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

14. 0.007 0.020 ↑ 35.0 4 1

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

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

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

16. 0.218 0.479 ↑ 1.1 251 1

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

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

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

18. 0.016 0.037 ↑ 1.2 18 1

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

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

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

20. 0.660 1.215 ↑ 1.0 700 1

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

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

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

22.          

SubPlan (forNested Loop)

23. 549.637 29,280.662 ↑ 1.0 1 49,967

Aggregate (cost=1,393.61..1,393.62 rows=1 width=8) (actual time=0.585..0.586 rows=1 loops=49,967)

24. 999.340 28,731.025 ↑ 5.8 10 49,967

Nested Loop (cost=4.17..1,393.46 rows=58 width=8) (actual time=0.078..0.575 rows=10 loops=49,967)

25. 249.835 249.835 ↑ 1.0 1 49,967

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.004..0.005 rows=1 loops=49,967)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 171
26. 4,711.412 27,481.850 ↑ 5.8 10 49,967

Bitmap Heap Scan on empleados (cost=3.88..1,389.58 rows=58 width=24) (actual time=0.069..0.550 rows=10 loops=49,967)

  • Recheck Cond: (npatronal = empresas_sucursales.nro_patronal)
  • Filter: (SubPlan 1)
  • Rows Removed by Filter: 12
27. 699.538 699.538 ↑ 5.3 22 49,967

Bitmap Index Scan on empleados_npatronal_idx (cost=0.00..3.87 rows=116 width=0) (actual time=0.014..0.014 rows=22 loops=49,967)

  • Index Cond: (npatronal = empresas_sucursales.nro_patronal)
28.          

SubPlan (forBitmap Heap Scan)

29. 2,207.090 22,070.900 ↑ 1.0 1 1,103,545

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

30. 4,414.180 19,863.810 ↑ 2.0 1 1,103,545

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

  • Sort Key: empleados_movimientos.fecha, empleados_movimientos.id
  • Sort Method: quicksort Memory: 25kB
31. 6,623.366 15,449.630 ↑ 1.0 2 1,103,545

Result (cost=0.00..9.05 rows=2 width=20) (actual time=0.008..0.014 rows=2 loops=1,103,545)

  • One-Time Filter: (empleados.empresa_id = emp.id)
32. 8,826.264 8,826.264 ↑ 1.0 2 1,103,283

Index Scan using empleados_movimientos_empleado_id_idx on empleados_movimientos (cost=0.00..9.04 rows=2 width=20) (actual time=0.006..0.008 rows=2 loops=1,103,283)

  • Index Cond: (empleado_id = empleados.id)
  • Rows Removed by Index Recheck: 0
33. 749.505 21,735.645 ↑ 1.0 1 49,967

Aggregate (cost=1,269.60..1,269.63 rows=1 width=16) (actual time=0.434..0.435 rows=1 loops=49,967)

34. 3,352.784 20,986.140 ↑ 5.8 12 49,967

Index Only Scan using empleados_empresa_id_id_idx on empleados emplea (cost=0.43..1,268.20 rows=70 width=16) (actual time=0.037..0.420 rows=12 loops=49,967)

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

SubPlan (forIndex Only Scan)

36. 2,712.824 17,633.356 ↑ 1.0 1 1,356,412

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

37. 6,782.060 14,920.532 ↑ 2.0 1 1,356,412

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

  • Sort Key: empleados_movimientos_1.fecha, empleados_movimientos_1.id
  • Sort Method: quicksort Memory: 25kB
38. 8,138.472 8,138.472 ↑ 1.0 2 1,356,412

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.004..0.006 rows=2 loops=1,356,412)

  • Index Cond: (empleado_id = emplea.id)
  • Rows Removed by Index Recheck: 0
39. 449.703 27,881.586 ↑ 1.0 1 49,967

Aggregate (cost=1,743.24..1,743.25 rows=1 width=8) (actual time=0.557..0.558 rows=1 loops=49,967)

40. 599.604 27,431.883 ↑ 6.3 6 49,967

Nested Loop (cost=4.17..1,743.15 rows=38 width=8) (actual time=0.073..0.549 rows=6 loops=49,967)

41. 199.868 199.868 ↑ 1.0 1 49,967

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

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 171
42. 1,831.038 26,632.411 ↑ 6.3 6 49,967

Nested Loop (cost=3.88..1,739.46 rows=38 width=16) (actual time=0.067..0.533 rows=6 loops=49,967)

43. 2,775.512 21,835.579 ↑ 5.8 10 49,967

Bitmap Heap Scan on empleados empleados_1 (cost=3.88..1,389.58 rows=58 width=24) (actual time=0.045..0.437 rows=10 loops=49,967)

  • Recheck Cond: (npatronal = empresas_sucursales.nro_patronal)
  • Filter: (SubPlan 5)
  • Rows Removed by Filter: 12
44. 299.802 299.802 ↑ 5.3 22 49,967

Bitmap Index Scan on empleados_npatronal_idx (cost=0.00..3.87 rows=116 width=0) (actual time=0.006..0.006 rows=22 loops=49,967)

  • Index Cond: (npatronal = empresas_sucursales.nro_patronal)
45.          

SubPlan (forBitmap Heap Scan)

46. 2,207.090 18,760.265 ↑ 1.0 1 1,103,545

Limit (cost=9.06..9.06 rows=1 width=20) (actual time=0.016..0.017 rows=1 loops=1,103,545)

47. 5,517.725 16,553.175 ↑ 2.0 1 1,103,545

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

  • Sort Key: empleados_movimientos_2.fecha, empleados_movimientos_2.id
  • Sort Method: quicksort Memory: 25kB
48. 5,519.035 11,035.450 ↑ 1.0 2 1,103,545

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

  • One-Time Filter: (empleados_1.empresa_id = emp.id)
49. 5,516.415 5,516.415 ↑ 1.0 2 1,103,283

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.003..0.005 rows=2 loops=1,103,283)

  • Index Cond: (empleado_id = empleados_1.id)
  • Rows Removed by Index Recheck: 0
50. 2,965.794 2,965.794 ↑ 1.0 1 494,299

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

  • Index Cond: (id = empleados_1.persona_id)
  • Rows Removed by Index Recheck: 0
  • Filter: ((sexo)::text = 'M'::text)
  • Rows Removed by Filter: 0
51. 299.802 26,232.675 ↑ 1.0 1 49,967

Aggregate (cost=1,743.02..1,743.03 rows=1 width=8) (actual time=0.524..0.525 rows=1 loops=49,967)

52. 399.736 25,932.873 ↑ 6.7 3 49,967

Nested Loop (cost=4.17..1,742.97 rows=20 width=8) (actual time=0.112..0.519 rows=3 loops=49,967)

53. 199.868 199.868 ↑ 1.0 1 49,967

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

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 171
54. 1,520.494 25,333.269 ↑ 6.7 3 49,967

Nested Loop (cost=3.88..1,739.46 rows=20 width=16) (actual time=0.106..0.507 rows=3 loops=49,967)

55. 2,825.479 21,835.579 ↑ 5.8 10 49,967

Bitmap Heap Scan on empleados empleados_2 (cost=3.88..1,389.58 rows=58 width=24) (actual time=0.045..0.437 rows=10 loops=49,967)

  • Recheck Cond: (npatronal = empresas_sucursales.nro_patronal)
  • Filter: (SubPlan 7)
  • Rows Removed by Filter: 12
56. 249.835 249.835 ↑ 5.3 22 49,967

Bitmap Index Scan on empleados_npatronal_idx (cost=0.00..3.87 rows=116 width=0) (actual time=0.005..0.005 rows=22 loops=49,967)

  • Index Cond: (npatronal = empresas_sucursales.nro_patronal)
57.          

SubPlan (forBitmap Heap Scan)

58. 2,207.090 18,760.265 ↑ 1.0 1 1,103,545

Limit (cost=9.06..9.06 rows=1 width=20) (actual time=0.016..0.017 rows=1 loops=1,103,545)

59. 5,517.725 16,553.175 ↑ 2.0 1 1,103,545

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

  • Sort Key: empleados_movimientos_3.fecha, empleados_movimientos_3.id
  • Sort Method: quicksort Memory: 25kB
60. 5,519.035 11,035.450 ↑ 1.0 2 1,103,545

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

  • One-Time Filter: (empleados_2.empresa_id = emp.id)
61. 5,516.415 5,516.415 ↑ 1.0 2 1,103,283

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.003..0.005 rows=2 loops=1,103,283)

  • Index Cond: (empleado_id = empleados_2.id)
  • Rows Removed by Index Recheck: 0
62. 1,977.196 1,977.196 ↓ 0.0 0 494,299

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

  • Index Cond: (id = empleados_2.persona_id)
  • Rows Removed by Index Recheck: 0
  • Filter: ((sexo)::text = 'F'::text)
  • Rows Removed by Filter: 1
63. 149.901 1,848.779 ↑ 1.0 1 49,967

Limit (cost=7.19..7.19 rows=1 width=134) (actual time=0.036..0.037 rows=1 loops=49,967)

64. 199.868 1,698.878 ↑ 1.0 1 49,967

Sort (cost=7.19..7.19 rows=1 width=134) (actual time=0.034..0.034 rows=1 loops=49,967)

  • Sort Key: cambio_situacion_empresa.fecha_creacion, cambio_situacion_empresa.id_cambio_situacion_empresa
  • Sort Method: quicksort Memory: 25kB
65. 617.707 1,499.010 ↑ 1.0 1 49,967

Nested Loop (cost=0.00..7.18 rows=1 width=134) (actual time=0.018..0.030 rows=1 loops=49,967)

  • Join Filter: (cambio_situacion_empresa.situacion_act = situacion_emp.id_situacion)
  • Rows Removed by Join Filter: 7
66. 499.670 499.670 ↑ 1.0 1 49,967

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.007..0.010 rows=1 loops=49,967)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
67. 381.633 381.633 ↑ 1.0 7 54,519

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