Re: Reindex doesn't work
- From: Erland Sommarskog <esquel@xxxxxxxxxxxxx>
- Date: Thu, 30 Jul 2009 20:55:18 +0000 (UTC)
Herb (stullhe104@xxxxxxxxxxxxxxxx) writes:
I have manually rebuilt the index since the MP ran, so your query shows
the time of when I rebuilt it.
If I run the MP manually (right-click Execute) it runs successfully, and
the index is proper. Also the date/time is correct for when I ran it
manually. So in answer to your question, the MP works but doesn't
improve the response time.
Is it possible that my MP needs to run as a different user? If so, how
do I change that?
The answer is that the whole affair with maintenance plan and reindexing
is an overkill to the whole problem.
Next time, you have this performance issue, try this:
sp_recompile 'yourtable'
This flushes all plans related to the table from the cache.
What happens is related to something known as parameter sniffing. When
SQL Server builds a query plan for the first time, it sniffs the input
parameters, be that a stored procedure or parameterised ad hoc-statement.
If the parameters for the first call are atypical, you will get a plan
which is bad for the rest of your queries.
Say that your application runs a query to load the most recent changes
from the database, passing a high-water mark as parameter. But once a
day, in the morning, your application performs a reload using the same
query, now passing a 0 for the high-water mark. Assume then that for
some reason there is no plan for the query in cache. The plan you will
get will be a scan of the entire table, which is good for that first
query, but really bad for reading the delta.
This example may not at all be applicable to your application, but I
wanted to give an example how this scenario could occur.
--
Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx
Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
.
- References:
- Reindex doesn't work
- From: Herb
- Re: Reindex doesn't work
- From: Dan Guzman
- Re: Reindex doesn't work
- From: Herb
- Reindex doesn't work
- Prev by Date: Re: Reindex doesn't work
- Next by Date: SSMS and constraints
- Previous by thread: Re: Reindex doesn't work
- Next by thread: Re: Reindex doesn't work
- Index(es):
Relevant Pages
|
Loading