Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Let's say you have a database where the default fill factor is 20. Whenever data is inserted, does it only create pages filled up to 20%?

From my understanding, when the data is inserted there will be roughly 20% of data in the pages. When the data is updated, however, it will expand to more than 20% of the index, upto filling it and generating a page split, right?

share|improve this question
add comment

1 Answer

up vote 14 down vote accepted

Fill factor only comes into play when an index is created or rebuilt. It is the amount of consumption for the index of the leaf level pages that are filled during these operations. (see the note below for more clarification on affected page levels)

When there is a DML command to data (INSERT, UPDATE, and/or DELETE), it will happen to the corresponding affected indexes. In other words, if you have a page that is 20% filled and you insert data into that page, the page will contain more than 20% of the data (let's say 35% just for example's sake). Do another insert, now the page is 64% filled. Rebuild the index, and the leaf level pages will now relatively contain the space percentage that you specify (or implicitly the default value for the server).

(Note, when you don't specify PAD_INDEX to be ON, fill factor is only applied to leaf level pages. But when you set PAD_INDEX = ON, the fill factor will be taken into account for intermediate-level pages of the index. The default is OFF)

The reason to adjust fill factor (instead of using the default 100/0) is so that you minimize page splits when inserting or updating data. But keep in mind, nothing is for free. The lower the fill factor, the more space data would normally take up. If you keep an 80% free page space for your indexes, they will consume a relatively larger amount of disk space, which can lead to more reads.

From my understanding, when the data is inserted there will be roughly 20% of data in the pages. When the data is updated, however, it will expand to more than 20% of the index, upto filling it and generating a page split, right?

When data is inserted it will insert into the appropriate indexes at the appropriate page. This could and most likely would very well cause the page consumption to be higher than the fill factor.

A page split will happen when new data is added to a full index page. SQL Server will then split the page and approximately place half of the data from the full page into a new page. Again, fill factor does not come into play here.

A legitimate reason to lower fill factor would be to minimize page splits, therefore minimizing index page fragmentation.

share|improve this answer
3  
It also minimizes IO operations needed to grow or allocate space. –  JNK Mar 23 '12 at 17:42
    
OK, so I was wrong with how the behavior worked. Thank you for such a detailed answer! –  DForck42 Mar 23 '12 at 19:10
1  
@DForck42 No problem, glad to help. –  Thomas Stringer Mar 23 '12 at 20:47
    
Can we summarize this to say that setting a low fill factor will tend to slow reads (more pages) but speed inserts (fewer splits)? –  Jon of All Trades Apr 2 '12 at 20:05
1  
@Jon: With high fillfactor indexes fragment and reads slow down. For every index there is an optimal fillfactor -- above it and below it slow writes and reads. Optimality depends usage patterns (how many inserts per day), maintenance patterns (how often its rebuild), data (how unique is the key). Non-unique indexes tend to require more free space (lower fillfactor). –  wqw Apr 3 '12 at 12:51
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.