explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 4D1G

Settings
# exclusive inclusive rows x rows loops node
1. 2,213.244 10,304.049 ↓ 1.0 52,356 1

Sort (cost=233,738.85..233,869.60 rows=52,303 width=461) (actual time=10,130.729..10,304.049 rows=52,356 loops=1)

  • Sort Key: empresas_sucursales.nro_patronal
  • Sort Method: external merge Disk: 19864kB
2. 581.739 8,090.805 ↓ 1.0 52,356 1

Hash Left Join (cost=3,149.87..221,849.70 rows=52,303 width=461) (actual time=518.601..8,090.805 rows=52,356 loops=1)

  • Hash Cond: (empresas_sucursales.id_tipo_inscripcion = empresas_tipo_inscripcion.id_tipo_inscripcion)
3. 228.470 2,901.724 ↓ 1.0 52,356 1

Hash Left Join (cost=3,148.80..10,902.98 rows=52,303 width=441) (actual time=518.507..2,901.724 rows=52,356 loops=1)

  • Hash Cond: (empresas_sucursales.type = empresas_sucursales_types.id)
4. 321.628 2,673.241 ↓ 1.0 52,356 1

Hash Left Join (cost=3,147.75..10,182.77 rows=52,303 width=434) (actual time=518.465..2,673.241 rows=52,356 loops=1)

  • Hash Cond: (empresas_sucursales.id_activ_econ = actividad_econ.id_activ_econ)
5. 228.757 2,347.938 ↓ 1.0 52,356 1

Hash Left Join (cost=3,122.33..9,438.18 rows=52,303 width=380) (actual time=514.764..2,347.938 rows=52,356 loops=1)

  • Hash Cond: (empresas_sucursales.distrito_id = distritos.id)
6. 241.802 2,119.135 ↓ 1.0 52,356 1

Hash Left Join (cost=3,120.92..8,717.94 rows=52,303 width=369) (actual time=514.684..2,119.135 rows=52,356 loops=1)

  • Hash Cond: (empresas_sucursales.city_id = city.id)
7. 252.885 1,876.767 ↓ 1.0 52,356 1

Hash Left Join (cost=3,108.21..7,988.10 rows=52,303 width=333) (actual time=514.094..1,876.767 rows=52,356 loops=1)

  • Hash Cond: (emp.id_categoria_empresa = empresas_categorias.id_categoria_empresa)
8. 258.986 1,623.864 ↓ 1.0 52,356 1

Hash Left Join (cost=3,107.12..7,761.00 rows=52,303 width=319) (actual time=514.051..1,623.864 rows=52,356 loops=1)

  • Hash Cond: (emp.type = empresas_types.id)
9. 547.630 1,364.814 ↓ 1.0 52,356 1

Hash Join (cost=3,105.44..7,040.16 rows=52,303 width=304) (actual time=513.952..1,364.814 rows=52,356 loops=1)

  • Hash Cond: (empresas_sucursales.empresa_id = emp.id)
10. 303.304 303.304 ↓ 1.0 52,358 1

Seq Scan on empresas_sucursales (cost=0.00..2,888.62 rows=52,306 width=238) (actual time=0.008..303.304 rows=52,358 loops=1)

  • Filter: (type = 1)
  • Rows Removed by Filter: 6653
11. 204.141 513.880 ↓ 1.0 52,215 1

Hash (cost=2,452.78..2,452.78 rows=52,213 width=82) (actual time=513.880..513.880 rows=52,215 loops=1)

  • Buckets: 8192 Batches: 1 Memory Usage: 5857kB
12. 309.739 309.739 ↓ 1.0 52,215 1

Seq Scan on empresas emp (cost=0.00..2,452.78 rows=52,213 width=82) (actual time=0.011..309.739 rows=52,215 loops=1)

  • Filter: (((document)::text <> '0'::text) AND ((document)::text <> ''::text) AND ((document)::text <> '-'::text))
  • Rows Removed by Filter: 2
13. 0.031 0.064 ↑ 1.0 30 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 2kB
14. 0.033 0.033 ↑ 1.0 30 1

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

15. 0.008 0.018 ↑ 1.0 4 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
16. 0.010 0.010 ↑ 1.0 4 1

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

17. 0.277 0.566 ↑ 1.0 254 1

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

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

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

19. 0.026 0.046 ↑ 1.0 18 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
20. 0.020 0.020 ↑ 1.0 18 1

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

21. 0.765 3.675 ↑ 1.0 730 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 66kB
22. 2.910 2.910 ↑ 1.0 730 1

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

23. 0.003 0.013 ↑ 1.0 1 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
24. 0.010 0.010 ↑ 1.0 1 1

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

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

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

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
26. 0.008 0.008 ↑ 1.0 3 1

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

27.          

SubPlan (forHash Left Join)

28. 314.136 4,607.328 ↑ 1.0 1 52,356

Limit (cost=0.42..4.02 rows=1 width=27) (actual time=0.086..0.088 rows=1 loops=52,356)

29. 766.728 4,293.192 ↑ 2.0 1 52,356

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

  • Join Filter: (cambio_situacion_empresa.situacion_act = situacion_emp.id_situacion)
  • Rows Removed by Join Filter: 3
30. 3,089.004 3,089.004 ↑ 2.0 1 52,356

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.059..0.059 rows=1 loops=52,356)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
31. 437.447 437.460 ↑ 1.4 5 43,746

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

32. 0.013 0.013 ↑ 1.0 7 1

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