SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Other SQL Server Topics (2005)
 Query delay
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

anulot1331
Starting Member

2 Posts

Posted - 04/02/2012 :  09:41:25  Show Profile  Reply with Quote
Hi all, I need help with a problem than I have in SQL Server 2005. I'm
executing a query with several joins, and when I execute the query It delay 6 minutes.
The strange thing, It's that when I reinsert all the rows in one of the tables, the query delay only 10 seconds.
Actually every day I have a process that it insert new records in this table, and It's
when this process happens, when my query delay 6 minutes again.

Do anyone has an idea that could happen?

Thanks very much in advance.

greetings.

SwePeso
Patron Saint of Lost Yaks

Sweden
29138 Posts

Posted - 04/02/2012 :  12:34:10  Show Profile  Visit SwePeso's Homepage  Reply with Quote
It's not about reinserting the data again.
First time you run hour query, if the query plan doesn't exist in plan cache, the plan has to be evaluated and stored.
Also, first time the data is accessed, if has to be fetched from drive and stored in buffer pool.
Next time you run your query and access same rows, you will get your data from buffer pool directly which is much faster.

Hence the time difference between 6 minutes and 10 seconds.



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

anulot1331
Starting Member

2 Posts

Posted - 04/03/2012 :  03:06:06  Show Profile  Reply with Quote
Thank you for your answer, but it isn't problem with the cache, because if I don't reinserting all de rows in the table, the query delay 6 minutes al the day, regardless of how many times I run it.
Greetings.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.16 seconds. Powered By: Snitz Forums 2000