explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 646F

Settings
# exclusive inclusive rows x rows loops node
1. 0.163 67.853 ↑ 1.0 100 1

Limit (cost=0.58..196,800.73 rows=100 width=12) (actual time=0.115..67.853 rows=100 loops=1)

2. 0.750 67.690 ↑ 7.5 100 1

Nested Loop (cost=0.58..1,481,905.73 rows=753 width=12) (actual time=0.114..67.690 rows=100 loops=1)

3. 2.940 2.940 ↑ 7.5 100 1

Index Scan Backward using empresas_sucursales_nro_patronal_key on empresas_sucursales (cost=0.29..5,805.62 rows=753 width=44) (actual time=0.045..2.940 rows=100 loops=1)

  • Filter: ((type <> 1) AND (type <> 1))
  • Rows Removed by Filter: 669
4. 1.200 1.200 ↑ 1.0 1 100

Index Scan using empresas_pk on empresas emp (cost=0.29..2.31 rows=1 width=20) (actual time=0.011..0.012 rows=1 loops=100)

  • Index Cond: (id = empresas_sucursales.empresa_id)
  • Filter: (((document)::text <> '0'::text) AND ((document)::text <> ''::text) AND ((document)::text <> '-'::text))
5.          

SubPlan (forNested Loop)

6. 1.300 62.800 ↑ 1.0 1 100

Aggregate (cost=1,957.96..1,957.97 rows=1 width=8) (actual time=0.627..0.628 rows=1 loops=100)

7. 2.200 61.500 ↑ 6.7 9 100

Nested Loop (cost=0.29..1,957.81 rows=60 width=8) (actual time=0.067..0.615 rows=9 loops=100)

8. 0.500 0.500 ↑ 1.0 1 100

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

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 0
9. 9.126 58.800 ↑ 6.7 9 100

Index Scan using empleados_npatronal_idx on empleados (cost=0.00..1,954.91 rows=60 width=24) (actual time=0.057..0.588 rows=9 loops=100)

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

SubPlan (forIndex Scan)

11. 2.922 49.674 ↑ 1.0 1 974

Limit (cost=14.12..14.12 rows=1 width=20) (actual time=0.051..0.051 rows=1 loops=974)

12. 5.844 46.752 ↑ 1.0 1 974

Sort (cost=14.12..14.12 rows=1 width=20) (actual time=0.048..0.048 rows=1 loops=974)

  • Sort Key: empleados_movimientos.fecha, empleados_movimientos.id
  • Sort Method: quicksort Memory: 25kB
13. 3.896 40.908 ↑ 1.0 1 974

Result (cost=0.43..14.11 rows=1 width=20) (actual time=0.037..0.042 rows=1 loops=974)

  • One-Time Filter: (empleados.empresa_id = emp.id)
14. 15.592 37.012 ↑ 1.0 1 974

Index Scan using empleados_movimientos_empleado_id_tipo_idx on empleados_movimientos (cost=0.43..14.10 rows=1 width=20) (actual time=0.034..0.038 rows=1 loops=974)

  • Index Cond: (empleado_id = empleados.id)
  • Filter: (NOT (SubPlan 1))
15.          

SubPlan (forIndex Scan)

16. 21.420 21.420 ↓ 0.0 0 1,071

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

  • Index Cond: (id_registro_multado = empleados_movimientos.id)
  • Filter: ((estado IS NULL) AND (idtipo_multa = 11))