Trouble with a low performance query SQL Server

Expreso Brio 21 Reputation points
2020-06-01T16:04:29.807+00:00

Hi there i have an issue with a query that i always run to get some non assigned deliveries.

The query code is:

select suc.SucursalNombre as SucursalDestino , env.FechaRecepcion, CONCAT (env.TipoComprobante, env.NroComprobante) as Comprobante,  
env.DomicilioOrigen, env.CodigoPostalOrigen,  env.LocalidadOrigen , env.DomicilioDestino, env.CodigoPostalDestino, env.LocalidadDestino,  
env.Subtotal, env.Seguro, env.Iva, env.Estado, env.Entregado, env.Cobrado, env.Rendido, hr.HojaRutaID             
from envios env  
inner join Sucursales suc on suc.SucursalID = env.SucursalIDDestino   
left join HojaRutaDetalle hrd on hrd.EnvioID = env.EnvioID  
left join HojaRuta hr on hr.HojaRutaID = hrd.HojaRutaID   
where env.FechaRecepcion =  '20200527' and env.TipoComprobante in ('FA', 'FB', 'RE', 'CP') and hr.HojaRutaID is null  

When i run this code usually i get around 100 to 300 records and it last about 3 minutes to run that query...

When i run the Execution Plan i get the following tree...

8886-query.jpg

The Assistant recommends to put an non clustered index so the performance of that query could improve about 16% but i want to do this in about 1 or 2 (or so) seconds like the other querys that i do.

My question is what can i do to improve the performance of that query because i want to learn how to do this but im very new in this area and i dont know how to start...

I hope someone can help me..

Thank you so much in advance.

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
36,445 questions
0 comments No comments
{count} votes

Accepted answer
  1. Dave Patrick 426.2K Reputation points MVP
    2020-06-01T16:06:24.363+00:00

    SQL Server is not currently supported here on QnA. I'd try asking for help in dedicated forums here.

    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/home?category=sqlserver

    --please don't forget to Accept as answer if the reply is helpful--


    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows Server] Datacenter Management

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.

    0 comments No comments

0 additional answers

Sort by: Most helpful