简体   繁体   中英

Query slow on SQL Server 2008 R2

I've a server with 20 clients. If I don't use a client for 1 day, the result of query arrives after 2:30 minutes (over 1000 rows). After the execution of 5/6 queries, the result arrives after few seconds.

I think it's a scheduling problem of SQL Server. How can I resolve?

Thanks

UPDATE

this is the query

Select * from  [WWALMDB].[dbo].[v_AlarmConsolidated]
Where Critico = 1 AND ApprovatoQA = 0 
AND InAttesaDiRiconoscimento Like '%param1%' 
AND (Tipo Like '%param2%') AND Area Like '%param3%'
AND Nome Like '%%param4%%' AND Descrizione Like '%%param5%%'
AND (([Dataora Scatto] >= CONVERT(DATETIME,'param6',105))
AND ([Dataora Scatto] <= CONVERT(DATETIME,'param7',105))
OR( ([Dataora Rientro] >= CONVERT(DATETIME,'param6',105))
AND ([Dataora Rientro] <= CONVERT(DATETIME,'param7',105))  )
OR(  ([Dataora PresoInCarico] >= CONVERT(DATETIME,'param6',105))
AND ([Dataora PresoInCarico] <= CONVERT(DATETIME,'param7',105))  ))
ORDER BY AlarmID DESC

What you described is a normal SQL Server caching behavior.

More information about MSSQL Server caching mechanisms you can find here

It's impossible to tell you anything else without knowing the background (example sql queries, health status of your sql server machine and actual db data structure)

UPDATE:

Your query is probably so badly optimized, that is actually a miracle it's only 2:30

SELECT *

LIKE '%%*%%'

ORDER BY

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM