SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Indexing & Fragmentation


Indexing & Fragmentation

Author
Message
speedman_2001
speedman_2001
SSC Rookie
SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)

Group: General Forum Members
Points: 39 Visits: 152
First - a little background - I'm a new DBA for my company and am trying to wrap my head around index fragmentation and some practices I've been reading about. This all started with about 30 location specific databases that are all queried overnight to gather information for reporting. Occasionally a couple of the db's show locks being caused by our script so I started looking at possible fixes. Though index fragmentation may not be the actual cause, it's something I've been looking through.

As I've been reading I've read information ranging from "re-index often" to "you don't need to worry about re-indexing." I've read that indexes fragmented < 30 % should be reorganized and >30 % completely rebuilt. I've read that reorganize can be done online and that rebuild could be either offline or online. I've also come across Ola Hallengren's site (http://ola.hallengren.com/) that has a good script to analyze and decide whether to reorganize/rebuild an index automatically and the script will perform the appropriate action.

At this point, I'm only focused on the index fragmentation of 1 table and each index (with 1 exception) has fragmentation around 98%. The size and read/write frequency is database specific due to some locations are busier than others.

What I'm asking you guys is what other resources am I missing? Are my thoughts completely off? What other scripts/articles would you guys suggest going through to analyze my indexes and fragmentation?

Thank you all very much for taking the time to read through this, I appreciate it very much. My apologies if I haven't provided enough information in this post.
raadee
raadee
SSC-Enthusiastic
SSC-Enthusiastic (187 reputation)SSC-Enthusiastic (187 reputation)SSC-Enthusiastic (187 reputation)SSC-Enthusiastic (187 reputation)SSC-Enthusiastic (187 reputation)SSC-Enthusiastic (187 reputation)SSC-Enthusiastic (187 reputation)SSC-Enthusiastic (187 reputation)

Group: General Forum Members
Points: 187 Visits: 476
Hi,

you can't miss with Ola's solution regarding maintenance.

If you want to analyze your indexes, have a look at sp_blitzindex.
It will tell you what is going on in your database, superb tool that has helped me a lot.
Geert Vanhove
Geert Vanhove
SSC Veteran
SSC Veteran (265 reputation)SSC Veteran (265 reputation)SSC Veteran (265 reputation)SSC Veteran (265 reputation)SSC Veteran (265 reputation)SSC Veteran (265 reputation)SSC Veteran (265 reputation)SSC Veteran (265 reputation)

Group: General Forum Members
Points: 265 Visits: 101
If the issue is limited to one single table I'd check it's clustered key choice. Fragmentation is most often the results of page splits which are most often caused by sub-optimal clustered index key choice. If you manage to use a better key as clustered index, this might solve your fragmentation issue.
Also check fillfactor of the index. This will not avoid fragmentation but postpone it because a page can handle more inserts before a page split occurs
If fragmentation can be avoided, index rebuilds will also be postponed. Which is a good thing as well for your application as for your maintenance window.
Steve Jones
Steve Jones
SSC Guru
SSC Guru (145K reputation)SSC Guru (145K reputation)SSC Guru (145K reputation)SSC Guru (145K reputation)SSC Guru (145K reputation)SSC Guru (145K reputation)SSC Guru (145K reputation)SSC Guru (145K reputation)

Group: Administrators
Points: 145641 Visits: 19425
Geert Vanhove (8/1/2013)
If the issue is limited to one single table I'd check it's clustered key choice. Fragmentation is most often the results of page splits which are most often caused by sub-optimal clustered index key choice. If you manage to use a better key as clustered index, this might solve your fragmentation issue.
Also check fillfactor of the index. This will not avoid fragmentation but postpone it because a page can handle more inserts before a page split occurs
If fragmentation can be avoided, index rebuilds will also be postponed. Which is a good thing as well for your application as for your maintenance window.


+1

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
speedman_2001
speedman_2001
SSC Rookie
SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)

Group: General Forum Members
Points: 39 Visits: 152
If you want to analyze your indexes, have a look at sp_blitzindex.
It will tell you what is going on in your database, superb tool that has helped me a lot.


Thanks raadee for the link to sp_blitzindex, will definitely be looking into that one.

If the issue is limited to one single table I'd check it's clustered key choice.


After looking at some stored procs we're having issues with it may be a couple other tables, but the # of tables that are really affected are few so I'll be sure to look into the key choice. Thanks for the info.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search