April 27, 2016 at 12:28 pm
Dear all,
We will try in Production environment to clean the cache in order to get new query plans (stored procédures will need to create new plans)
This is because everytime we have the server for more than 1 month online we start to get slow. After a restart we are ok for another month.
We think that this is realted with bad query plans on SPs as memory , processor and disk are normal.
Can you please advice if the following commands can make any warm?
DBCC FREEPROCCACHE
GO
DBCC DROPCLEANBUFFERS
GO
DBCC FREESYSTEMCACHE ('ALL')
GO
DBCC FREESESSIONCACHE
GO
April 27, 2016 at 12:37 pm
The cache drops old plans and add new ones as needed.
If you find certain items getting slow, I'd address those queries/procedures/functions themselves rather than clearing the cache. If you do this, then every plan, including good ones, gets flushed and all queries must be recompiled. I'd think that would slow your system down when this happens.
April 27, 2016 at 1:11 pm
Don't guess as to the cause of a problem. You need to do enough analysis and investigation to be sure of the cause before you decide on a solution. Otherwise you could end up making the problems worse.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
April 27, 2016 at 4:45 pm
river1 (4/27/2016)
Dear all,We will try in Production environment to clean the cache in order to get new query plans (stored procédures will need to create new plans)
This is because everytime we have the server for more than 1 month online we start to get slow. After a restart we are ok for another month.
We think that this is realted with bad query plans on SPs as memory , processor and disk are normal.
Can you please advice if the following commands can make any warm?
DBCC FREEPROCCACHE
GO
DBCC DROPCLEANBUFFERS
GO
DBCC FREESYSTEMCACHE ('ALL')
GO
DBCC FREESESSIONCACHE
GO
How often do you rebuild STATISTICS? Based on what you stated, it sounds like "never" is the answer and you need to change that sooner than later.
--Jeff Moden
Change is inevitable... Change for the better is not.
April 27, 2016 at 8:11 pm
I'm with Jeff - sounds like your stats are not getting updated. You should check your Auto Update Statistics setting for your databases (right click DB, go to options).
-- Itzik Ben-Gan 2001
April 27, 2016 at 11:34 pm
I have a proc running every day that reorg/rebuild indexes. If reorg then also updates the stats
April 27, 2016 at 11:36 pm
I have a proc running every day that reorg/rebuild indexes. If reorg then also updates the stats
April 28, 2016 at 2:33 am
river1 (4/27/2016)
I have a proc running every day that reorg/rebuild indexes. If reorg then also updates the stats
It still sounds like the stats are getting stale. If the statistics get updated, you will automatically get a plan rebuild, no need to nuke the entire cache to make that happen. I'm with everyone else, focus on gathering some more metrics so you know precisely where and why the issues are occurring. Running FREEPROCCACHE over & over on a scheduled basis is a poor choice for performance tuning.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
April 28, 2016 at 6:30 am
river1 (4/27/2016)
I have a proc running every day that reorg/rebuild indexes. If reorg then also updates the stats
Ah, careful now. Specifically, REORG does NOT rebuild stats. Only a REBUILD will. You can verify that in "Books Online".
Even then, relying on REBUILDs to take care of stats isn't the way to go because any given index may not become fragmented enough to trip the REBUILD into action. This is especially true if you have tables with a clustered index with ever increasing keys, which frequently never get fragmented enough to trigger a REBUILD in most folks maintenance procs.
Autostats are also woefully inadequate in 2008 because roughly 20% of the table has to change before autostats will kick in.
--Jeff Moden
Change is inevitable... Change for the better is not.
April 28, 2016 at 6:46 am
Jeff Moden (4/28/2016)
river1 (4/27/2016)
I have a proc running every day that reorg/rebuild indexes. If reorg then also updates the statsAh, careful now. Specifically, REORG does NOT rebuild stats. Only a REBUILD will. You can verify that in "Books Online".
Even then, relying on REBUILDs to take care of stats isn't the way to go because any given index may not become fragmented enough to trip the REBUILD into action. This is especially true if you have tables with a clustered index with ever increasing keys, which frequently never get fragmented enough to trigger a REBUILD in most folks maintenance procs.
Autostats are also woefully inadequate in 2008 because roughly 20% of the table has to change before autostats will kick in.
I read that as "There's an additional step that updates statistics" but I could be very wrong (as usual).
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
April 28, 2016 at 8:14 am
Jeff Moden (4/28/2016)
river1 (4/27/2016)
I have a proc running every day that reorg/rebuild indexes. If reorg then also updates the statsAh, careful now. Specifically, REORG does NOT rebuild stats. Only a REBUILD will. You can verify that in "Books Online".
While that's true, the OP explicitly says that if it was a reorg, then they update stats.
Besides, there's not enough evidence (no evidence in fact) that the problem is related to execution plans or stats. Restarts don't update stats and so uptime should not be a factor if it is stale stats
Last time I saw a problem like this (overall slowdown that got worse the longer the server had been up), it was a memory leak in a linked server driver, on SQL 2005 IA64.
The first step should be to ensure there's sufficient monitoring on the server to track query performance and common performance-related characteristics over time (I'd start with wait stats and latch stats, overall CPU, memory use and IO stats) and analyse them until you can determine a possible cause.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
April 28, 2016 at 9:09 am
GilaMonster (4/28/2016)
Jeff Moden (4/28/2016)
river1 (4/27/2016)
I have a proc running every day that reorg/rebuild indexes. If reorg then also updates the statsAh, careful now. Specifically, REORG does NOT rebuild stats. Only a REBUILD will. You can verify that in "Books Online".
While that's true, the OP explicitly says that if it was a reorg, then they update stats.
Besides, there's not enough evidence (no evidence in fact) that the problem is related to execution plans or stats. Restarts don't update stats and so uptime should not be a factor if it is stale stats
Last time I saw a problem like this (overall slowdown that got worse the longer the server had been up), it was a memory leak in a linked server driver, on SQL 2005 IA64.
The first step should be to ensure there's sufficient monitoring on the server to track query performance and common performance-related characteristics over time (I'd start with wait stats and latch stats, overall CPU, memory use and IO stats) and analyse them until you can determine a possible cause.
Apologies and the heads up. Misread what the op stated as him thinking that REORG rebuilt stats.
--Jeff Moden
Change is inevitable... Change for the better is not.
May 6, 2016 at 8:20 am
Thank you for the reply. How can we see if we have the same situation on our linked server drivers? Is there any special command to do this?
Viewing 13 posts - 1 through 13 (of 13 total)
You must be logged in to reply to this topic. Login to reply