dbTalk Databases Forums  

no_log

microsoft.public.sqlserver.setup microsoft.public.sqlserver.setup


Discuss no_log in the microsoft.public.sqlserver.setup forum.



Reply
 
Thread Tools Display Modes
  #11  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: no_log - 10-30-2009 , 02:36 AM






Andre (no (AT) spam (DOT) com) writes:
Quote:
I take it since you're mentioning this that SQL 2008 isn't smart enough to
figure out if index rebuilding is really necessary?
If you say ALTER INDEX ix ON tbl WITH REBUILD, SQL Server should comply
and not try to be smart.

However, it could be a good thing if Microsoft added such parameters to
the maintenance plans to permit you to control this. I don't use maintenance
plans, so I don't know if it's already there.

Quote:
If not, I've seen several sample queries on the web that are used to
rebuild an index - based on necessity. Is that what you recommend? Do
you have any recommendations of good queries out there?
I have no queries canned, but there are several fragmentation values,
and I would probably use a query that returned several values.

I would recommend that you use queries based on dm_sys_index_physical_stats
rather than DBCC SHOWCONTIG, as the latter is deprecated and will go
away one day.

Quote:
And what percent fragmented do you want to see before you rebuild an
index?
In the system I work with, we have a home-brewed maintenance job (which is
just a stored procedure, not a maintenance plan). I think the trigger level
is when Scan Density goes below 70%. I don't think it looks at
logical fragmentation, but maybe it should.


--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

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/prodinf...ons/books.mspx

Reply With Quote
  #12  
Old   
Andrew J. Kelly
 
Posts: n/a

Default Re: no_log - 10-30-2009 , 06:59 PM






I agree with Erland in that if you tell it to run the rebuild it should run
the rebuild. It is up to you to determine if the index should be rebuilt
based on your specific requirements. And I highly recommend you use one of
the scripts you found to customize this process. Don't rebuild the index if
it doesn't need rebuilding.

--

Andrew J. Kelly SQL MVP
Solid Quality Mentors

"Andre" <no (AT) spam (DOT) com> wrote

Quote:
There is also reason to make index rebuild dependent on whether there is
any actual fragmentation.

I take it since you're mentioning this that SQL 2008 isn't smart enough to
figure out if index rebuilding is really necessary? If not, I've seen
several sample queries on the web that are used to rebuild an index -
based on necessity. Is that what you recommend? Do you have any
recommendations of good queries out there? And what percent fragmented do
you want to see before you rebuild an index?

Andre

Reply With Quote
  #13  
Old   
Andre
 
Posts: n/a

Default Re: no_log - 10-30-2009 , 09:15 PM



Too funny. I just found a great article, and then saw your response.
Recognize this article?

http://www.sqlmag.com/Articles/Artic...019/99019.html

Didn't I just tell you I appreciate your articles earlier this week? See,
it's true!

Andre

Reply With Quote
  #14  
Old   
Andrew J. Kelly
 
Posts: n/a

Default Re: no_log - 10-31-2009 , 03:06 PM



That is funny as I had actually forgotten I even wrote that (they are
usually written months earlier) or I would have pointed you to it . Glad
to see someone read it

--

Andrew J. Kelly SQL MVP
Solid Quality Mentors

"Andre" <no (AT) spam (DOT) com> wrote

Quote:
Too funny. I just found a great article, and then saw your response.
Recognize this article?

http://www.sqlmag.com/Articles/Artic...019/99019.html

Didn't I just tell you I appreciate your articles earlier this week? See,
it's true!

Andre

Reply With Quote
  #15  
Old   
Andre
 
Posts: n/a

Default Re: no_log - 11-02-2009 , 01:02 PM



It worked great Andrew. I can tell it's working properly too because over
the weekend one time it took only 1 second to run, which was correct because
we hadn't touched the 2008 db. Another day it ran in 4 minutes, when we had
been working in 2008, so thanks again for the article.

Now I have another question about update stats. I've read in BOL that
sometimes updating stats can actually hurt us because of the recompile.
What is your take on this? In SQL 2000 we found that updating stats nightly
was a big help. It was a small cost (running the update) versus the
improvement we saw in our queries.

I'm also really puzzled about the maintenance plans for update stats. I
created a new plan that only had the update stats task, pointing to our main
db and only updates tables. The plan took 3 hr 33 minutes. The query below
(which is what we run in SQL 2k) runs in about 14 minutes. Why the huge
difference?


DECLARE @objid INT -- the object id of the table
DECLARE @objname CHAR(100) -- string to build up table name
DECLARE @strSQL VARCHAR(1000)
DECLARE TableName CURSOR
FOR SELECT DISTINCT NAME FROM sysobjects WHERE TYPE = 'U'

OPEN TableName

FETCH NEXT FROM TableName INTO @objname

WHILE @@fetch_status = 0
BEGIN
SET ARITHABORT ON
SET QUOTED_IDENTIFIER ON
SET @strSQL = 'UPDATE STATISTICS ' + @objname
EXEC (@strSQL)

FETCH NEXT FROM TableName INTO @objname
END

DEALLOCATE TableName


Andre

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.