explain.depesz.com

PostgreSQL's explain analyze made readable

Result: YYtO

Settings
# exclusive inclusive rows x rows loops node
1. 0.165 68.521 ↑ 1.0 100 1

Limit (cost=0.58..197,271.67 rows=100 width=12) (actual time=0.302..68.521 rows=100 loops=1)

2. 0.653 68.356 ↑ 7.5 100 1

Nested Loop (cost=0.58..1,485,451.86 rows=753 width=12) (actual time=0.300..68.356 rows=100 loops=1)

3. 3.003 3.003 ↑ 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.052..3.003 rows=100 loops=1)

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

Index Scan using empresas_pk on empresas emp (cost=0.29..2.31 rows=1 width=20) (actual time=0.015..0.017 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 63.000 ↑ 1.0 1 100

Aggregate (cost=1,962.67..1,962.68 rows=1 width=8) (actual time=0.629..0.630 rows=1 loops=100)

7. 2.000 61.700 ↑ 6.7 9 100

Nested Loop (cost=0.29..1,962.52 rows=60 width=8) (actual time=0.061..0.617 rows=9 loops=100)

8. 0.600 0.600 ↑ 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.006 rows=1 loops=100)

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

Index Scan using empleados_npatronal_idx on empleados (cost=0.00..1,959.61 rows=60 width=24) (actual time=0.051..0.591 rows=9 loops=100)

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

SubPlan (forIndex Scan)

11. 1.948 49.674 ↑ 1.0 1 974

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

12. 6.818 47.726 ↑ 1.0 1 974

Sort (cost=14.15..14.16 rows=1 width=20) (actual time=0.049..0.049 rows=1 loops=974)

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

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

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

Index Scan using empleados_movimientos_empleado_id_tipo_idx on empleados_movimientos (cost=0.43..14.14 rows=1 width=20) (actual time=0.029..0.032 rows=1 loops=974)

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

SubPlan (forIndex Scan)

16. 5.355 5.355 ↓ 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.005..0.005 rows=0 loops=1,071)

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