explain.depesz.com

PostgreSQL's explain analyze made readable

Result: QdSZ : Optimization for: Optimization for: plan #rjKU; plan #u5Yc

Settings

Optimization path:

# exclusive inclusive rows x rows loops node
1. 159.530 8,465.746 ↓ 1.1 58,964 1

Append (cost=234,121.63..242,750.87 rows=53,132 width=578) (actual time=6,619.791..8,465.746 rows=58,964 loops=1)

2. 1,990.077 6,760.518 ↑ 1.0 52,351 1

Sort (cost=234,121.63..234,252.61 rows=52,391 width=460) (actual time=6,619.789..6,760.518 rows=52,351 loops=1)

  • Sort Key: empresas_sucursales.nro_patronal
  • Sort Method: external merge Disk: 19864kB
3. 511.461 4,770.441 ↑ 1.0 52,351 1

Hash Left Join (cost=3,149.63..222,212.45 rows=52,391 width=460) (actual time=396.329..4,770.441 rows=52,351 loops=1)

  • Hash Cond: (empresas_sucursales.id_tipo_inscripcion = empresas_tipo_inscripcion.id_tipo_inscripcion)
4. 187.186 2,217.276 ↑ 1.0 52,351 1

Hash Left Join (cost=3,148.56..10,910.82 rows=52,391 width=440) (actual time=396.204..2,217.276 rows=52,351 loops=1)

  • Hash Cond: (empresas_sucursales.type = empresas_sucursales_types.id)
5. 198.489 2,030.075 ↑ 1.0 52,351 1

Hash Left Join (cost=3,147.51..10,189.40 rows=52,391 width=433) (actual time=396.166..2,030.075 rows=52,351 loops=1)

  • Hash Cond: (empresas_sucursales.id_activ_econ = actividad_econ.id_activ_econ)
6. 220.520 1,829.315 ↑ 1.0 52,351 1

Hash Left Join (cost=3,122.09..9,443.62 rows=52,391 width=379) (actual time=393.876..1,829.315 rows=52,351 loops=1)

  • Hash Cond: (empresas_sucursales.distrito_id = distritos.id)
7. 229.527 1,608.746 ↑ 1.0 52,351 1

Hash Left Join (cost=3,120.68..8,722.18 rows=52,391 width=368) (actual time=393.803..1,608.746 rows=52,351 loops=1)

  • Hash Cond: (empresas_sucursales.city_id = city.id)
8. 154.665 1,376.864 ↑ 1.0 52,351 1

Hash Left Join (cost=3,107.97..7,991.45 rows=52,391 width=332) (actual time=391.426..1,376.864 rows=52,351 loops=1)

  • Hash Cond: (emp.id_categoria_empresa = empresas_categorias.id_categoria_empresa)
9. 167.386 1,222.184 ↑ 1.0 52,351 1

Hash Left Join (cost=3,106.88..7,763.67 rows=52,391 width=318) (actual time=391.398..1,222.184 rows=52,351 loops=1)

  • Hash Cond: (emp.type = empresas_types.id)
10. 367.584 1,054.729 ↑ 1.0 52,351 1

Hash Join (cost=3,105.20..7,041.61 rows=52,391 width=303) (actual time=391.304..1,054.729 rows=52,351 loops=1)

  • Hash Cond: (empresas_sucursales.empresa_id = emp.id)
11. 295.906 295.906 ↑ 1.0 52,353 1

Seq Scan on empresas_sucursales (cost=0.00..2,888.56 rows=52,394 width=238) (actual time=0.037..295.906 rows=52,353 loops=1)

  • Filter: (type = 1)
  • Rows Removed by Filter: 6652
12. 150.175 391.239 ↓ 1.0 52,210 1

Hash (cost=2,452.64..2,452.64 rows=52,205 width=81) (actual time=391.239..391.239 rows=52,210 loops=1)

  • Buckets: 8192 Batches: 1 Memory Usage: 5856kB
13. 241.064 241.064 ↓ 1.0 52,210 1

Seq Scan on empresas emp (cost=0.00..2,452.64 rows=52,205 width=81) (actual time=0.017..241.064 rows=52,210 loops=1)

  • Filter: (((document)::text <> '0'::text) AND ((document)::text <> ''::text) AND ((document)::text <> '-'::text))
  • Rows Removed by Filter: 2
14. 0.033 0.069 ↑ 1.0 30 1

Hash (cost=1.30..1.30 rows=30 width=23) (actual time=0.069..0.069 rows=30 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 2kB
15. 0.036 0.036 ↑ 1.0 30 1

Seq Scan on empresas_types (cost=0.00..1.30 rows=30 width=23) (actual time=0.006..0.036 rows=30 loops=1)

16. 0.006 0.015 ↑ 1.0 4 1

Hash (cost=1.04..1.04 rows=4 width=18) (actual time=0.015..0.015 rows=4 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
17. 0.009 0.009 ↑ 1.0 4 1

Seq Scan on empresas_categorias (cost=0.00..1.04 rows=4 width=18) (actual time=0.005..0.009 rows=4 loops=1)

18. 2.061 2.355 ↑ 1.0 254 1

Hash (cost=9.54..9.54 rows=254 width=40) (actual time=2.355..2.355 rows=254 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 19kB
19. 0.294 0.294 ↑ 1.0 254 1

Seq Scan on city (cost=0.00..9.54 rows=254 width=40) (actual time=0.006..0.294 rows=254 loops=1)

20. 0.024 0.049 ↑ 1.0 18 1

Hash (cost=1.18..1.18 rows=18 width=19) (actual time=0.049..0.049 rows=18 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
21. 0.025 0.025 ↑ 1.0 18 1

Seq Scan on distritos (cost=0.00..1.18 rows=18 width=19) (actual time=0.008..0.025 rows=18 loops=1)

22. 0.864 2.271 ↑ 1.0 730 1

Hash (cost=16.30..16.30 rows=730 width=58) (actual time=2.271..2.271 rows=730 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 66kB
23. 1.407 1.407 ↑ 1.0 730 1

Seq Scan on actividad_econ (cost=0.00..16.30 rows=730 width=58) (actual time=0.008..1.407 rows=730 loops=1)

24. 0.004 0.015 ↑ 1.0 1 1

Hash (cost=1.04..1.04 rows=1 width=23) (actual time=0.015..0.015 rows=1 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
25. 0.011 0.011 ↑ 1.0 1 1

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

  • Filter: (id = 1)
  • Rows Removed by Filter: 2
26. 0.006 0.015 ↑ 1.0 3 1

Hash (cost=1.03..1.03 rows=3 width=24) (actual time=0.015..0.015 rows=3 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
27. 0.009 0.009 ↑ 1.0 3 1

Seq Scan on empresas_tipo_inscripcion (cost=0.00..1.03 rows=3 width=24) (actual time=0.006..0.009 rows=3 loops=1)

28.          

SubPlan (forHash Left Join)

29. 209.404 2,041.689 ↑ 1.0 1 52,351

Limit (cost=0.42..4.02 rows=1 width=27) (actual time=0.038..0.039 rows=1 loops=52,351)

30. 592.390 1,832.285 ↑ 2.0 1 52,351

Nested Loop (cost=0.42..7.62 rows=2 width=27) (actual time=0.035..0.035 rows=1 loops=52,351)

  • Join Filter: (cambio_situacion_empresa.situacion_act = situacion_emp.id_situacion)
  • Rows Removed by Join Filter: 3
31. 889.967 889.967 ↑ 2.0 1 52,351

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.017..0.017 rows=1 loops=52,351)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
32. 349.913 349.928 ↑ 1.4 5 43,741

Materialize (cost=0.00..1.10 rows=7 width=15) (actual time=0.002..0.008 rows=5 loops=43,741)

33. 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)

34. 85.148 1,545.698 ↓ 8.9 6,613 1

Sort (cost=7,965.08..7,966.94 rows=741 width=462) (actual time=1,518.237..1,545.698 rows=6,613 loops=1)

  • Sort Key: empresas_sucursales_1.nro_patronal
  • Sort Method: quicksort Memory: 4555kB
35. 102.351 1,460.550 ↓ 8.9 6,613 1

Nested Loop Left Join (cost=14.41..7,929.76 rows=741 width=462) (actual time=1.008..1,460.550 rows=6,613 loops=1)

36. 64.706 941.580 ↓ 8.9 6,613 1

Nested Loop Left Join (cost=14.41..4,921.01 rows=741 width=442) (actual time=0.908..941.580 rows=6,613 loops=1)

37. 53.890 797.518 ↓ 8.9 6,613 1

Nested Loop Left Join (cost=14.41..4,890.64 rows=741 width=435) (actual time=0.869..797.518 rows=6,613 loops=1)

38. 24.031 624.594 ↓ 8.9 6,613 1

Hash Left Join (cost=14.41..4,840.26 rows=741 width=381) (actual time=0.822..624.594 rows=6,613 loops=1)

  • Hash Cond: (empresas_sucursales_1.distrito_id = distritos_1.id)
39. 30.493 600.516 ↓ 8.9 6,613 1

Hash Left Join (cost=13.00..4,828.67 rows=741 width=370) (actual time=0.759..600.516 rows=6,613 loops=1)

  • Hash Cond: (empresas_sucursales_1.city_id = city_1.id)
40. 64.394 569.428 ↓ 8.9 6,613 1

Nested Loop Left Join (cost=0.29..4,805.79 rows=741 width=334) (actual time=0.142..569.428 rows=6,613 loops=1)

41. 65.963 485.195 ↓ 8.9 6,613 1

Nested Loop Left Join (cost=0.29..4,785.27 rows=741 width=320) (actual time=0.134..485.195 rows=6,613 loops=1)

42. 57.335 313.424 ↓ 8.9 6,613 1

Nested Loop (cost=0.29..4,764.75 rows=741 width=305) (actual time=0.086..313.424 rows=6,613 loops=1)

43. 89.789 89.789 ↓ 9.0 6,652 1

Seq Scan on empresas_sucursales empresas_sucursales_1 (cost=0.00..3,036.07 rows=741 width=301) (actual time=0.021..89.789 rows=6,652 loops=1)

  • Filter: ((type <> 1) AND (type <> 1))
  • Rows Removed by Filter: 52353
44. 166.300 166.300 ↑ 1.0 1 6,652

Index Scan using empresas_pk on empresas emp_1 (cost=0.29..2.32 rows=1 width=20) (actual time=0.020..0.025 rows=1 loops=6,652)

  • Index Cond: (id = empresas_sucursales_1.empresa_id)
  • Filter: (((document)::text <> '0'::text) AND ((document)::text <> ''::text) AND ((document)::text <> '-'::text))
  • Rows Removed by Filter: 0
45. 105.808 105.808 ↑ 1.0 1 6,613

Index Scan using empresas_types_id_idx on empresas_types empresas_types_1 (cost=0.00..0.02 rows=1 width=23) (actual time=0.012..0.016 rows=1 loops=6,613)

  • Index Cond: (emp_1.type = id)
46. 19.839 19.839 ↓ 0.0 0 6,613

Index Scan using empresas_categorias_id_categoria_empresa_idx on empresas_categorias empresas_categorias_1 (cost=0.00..0.02 rows=1 width=18) (actual time=0.003..0.003 rows=0 loops=6,613)

  • Index Cond: (emp_1.id_categoria_empresa = id_categoria_empresa)
47. 0.312 0.595 ↑ 1.0 254 1

Hash (cost=9.54..9.54 rows=254 width=40) (actual time=0.595..0.595 rows=254 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 19kB
48. 0.283 0.283 ↑ 1.0 254 1

Seq Scan on city city_1 (cost=0.00..9.54 rows=254 width=40) (actual time=0.007..0.283 rows=254 loops=1)

49. 0.024 0.047 ↑ 1.0 18 1

Hash (cost=1.18..1.18 rows=18 width=19) (actual time=0.047..0.047 rows=18 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
50. 0.023 0.023 ↑ 1.0 18 1

Seq Scan on distritos distritos_1 (cost=0.00..1.18 rows=18 width=19) (actual time=0.006..0.023 rows=18 loops=1)

51. 119.034 119.034 ↑ 1.0 1 6,613

Index Scan using actividad_econ_id_activ_econ_idx on actividad_econ actividad_econ_1 (cost=0.00..0.06 rows=1 width=58) (actual time=0.016..0.018 rows=1 loops=6,613)

  • Index Cond: (empresas_sucursales_1.id_activ_econ = id_activ_econ)
52. 79.356 79.356 ↑ 1.0 1 6,613

Index Scan using empresas_sucursales_types_id_idx on empresas_sucursales_types empresas_sucursales_types_1 (cost=0.00..0.03 rows=1 width=23) (actual time=0.009..0.012 rows=1 loops=6,613)

  • Index Cond: (empresas_sucursales_1.type = id)
53. 79.356 79.356 ↑ 1.0 1 6,613

Index Scan using empresas_tipo_inscripcion_id_tipo_inscripcion_idx on empresas_tipo_inscripcion empresas_tipo_inscripcion_1 (cost=0.00..0.03 rows=1 width=24) (actual time=0.007..0.012 rows=1 loops=6,613)

  • Index Cond: (empresas_sucursales_1.id_tipo_inscripcion = id_tipo_inscripcion)
54.          

SubPlan (forNested Loop Left Join)

55. 26.452 337.263 ↑ 1.0 1 6,613

Limit (cost=0.42..4.02 rows=1 width=27) (actual time=0.050..0.051 rows=1 loops=6,613)

56. 102.091 310.811 ↑ 2.0 1 6,613

Nested Loop (cost=0.42..7.62 rows=2 width=27) (actual time=0.047..0.047 rows=1 loops=6,613)

  • Join Filter: (cambio_situacion_empresa_1.situacion_act = situacion_emp_1.id_situacion)
  • Rows Removed by Join Filter: 4
57. 158.712 158.712 ↑ 2.0 1 6,613

Index Scan using cambio_situacion_empresa_nro_patronal_fecha_creacion_id_cam_idx on cambio_situacion_empresa cambio_situacion_empresa_1 (cost=0.42..6.32 rows=2 width=20) (actual time=0.024..0.024 rows=1 loops=6,613)

  • Index Cond: (nro_patronal = empresas_sucursales_1.nro_patronal)
58. 49.997 50.008 ↑ 1.4 5 6,251

Materialize (cost=0.00..1.10 rows=7 width=15) (actual time=0.002..0.008 rows=5 loops=6,251)

59. 0.011 0.011 ↑ 1.2 6 1

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