RSS Subscription 168 Posts and 2,769 Comments

Exchange 2010 24×7 Online Defragmentation and Online Database Scanning

Exchange has an Online Maintenance task that runs every night.  In the Exchange Management Console (EMC),  go to Organization Configuration > Mailbox > Database Management Tab > Right-Click our Database > Properties >  Maintenace Tab. We can then see our Maintenance Schedule.

In Exchange 2010, this will appear as:

As you can see, in Exchange 2010, there is a new option that is enabled by default.  This option is the “Enable background database maintenance (24 x 7 ESE scanning).  This option is not Online Defragmentation, but is rather Database Checksumming.  More on this later…

In Online Maintenance, there’s several tasks that run such as dumpster cleanup, purging mailboxes based on retention, etc…  You can see a full list of these tasks here.  When these eleven tasks successfully finish, an Online Defragmentation (OLD) process runs.  Microsoft explains OLD as, “The intention for online defragmentation is to free up pages in the database by compacting records onto the fewest number of pages possible, thus reducing the amount of I/O necessary. The ESE database engine does this by taking the database metadata, which is the information in the database that describes tables in the database, and for each table, visiting each page in the table, and attempting to move records onto logically ordered pages.”

There is also a process called Online Maintenance Database Checksumming.  Checksumming checks the integrity of the database by looking through every database page since there was no guarantee OLD would successfully look through every page to ensure there is no corruption.  This process is entirely sequential and doesn’t cause a performance problem on the database.  The issues with this method in Exchange 2007 RTM is that this process ran at the end of Online Maintenace and because of that, resiliency is effected as these processes temporary suspend continous replication.  In Exchange 2007 SP1, Microsoft provided registry keys to allow you to run background checksumming.  You can read more about these processes and the registry keys at the bottom of this article here.

In Exchange editions prior to Exchange 2010, we can monitor OLD by checking out the available 70x Event IDs in the Event Viewer’s Application Log.  Similarly, you can verify the amount of whitespace that has been created in the database by viewing the 1221 Event ID.   The list of Event IDs for Exchange versions prior to Exchange 2010 is as follows:

  • 700 – Starting
  • 701 – Completed
  • 702 – Resuming
  • 703 – Completed Resumed Pass
  • 704 – Interrupted and Terminated
  • 1221 – Whitespace Amount

This has all changed quite a bit in Exchange 2010.  OLD2 is the new version of Online Defragmentation and no longer occurs at the end of the Online Maintenance Schedule.  Instead, it runs 24 x 7 on a database. It is throttled so it does not negatively affect performance.  You cannot modify OLD2 to run as OLD did in earlier versions of Exchange.  OLD2 is not configurable. Because of this, the need to troll the above Event IDs is no more.  Instead of trolling 70x Event IDs, Exchange 2010 will only notify you if something goes wrong with Online Maintenance.  That way all the 70x error codes do not appear as spam.  If you see a 70x in Exchange 2010, you know there is a problem. Keep in mind though, that this is all in regards to Mailbox Databases.  Queue Databases still have 70x Event IDs.

If you need to check available whitespace, you can now do this via the Exchange Management Shell (EMS).  Please keep in mind, this only pulls available whitespace from the root of the B-Tree database. If you want to find available whitespace for the entire database, you would have to dismount your databases and use eseutil. If your database is called Database1, the command would be:

Get-MailboxDatabase Database1 -Status | FL AvailableNewMailboxSpace

Note: The -Status switch is required when you need to contact the database directly for the following pieces of information:

  • BackupInProgress
  • Mounted
  • OnlineMaintenanceInProgress
  • Available free space in the database root

As stated, OLD2 is throttled and doesn’t negatively affect performance.  If you have an interest in monitoring performance of OLD2, you can do so by using the following perfmon counter set: MSExchange Database -> Defragmentation Tasks.

In Exchange 2010, there are two ways you can configure Online Database Scanning (checksumming).  The first is the default option shown in the first image in this article.  By default, it runs as a 24 x 7 process on the Active Database.   You can uncheck this option which will then revert Online Database Scanning so that it runs after all online maintenance tasks are completed.  Because most online maintenance tasks complete within an hour, this process works reasonably fine for smaller databases (under 500GB).  Microsoft now supports up to 2TB databases.  Anything larger than 500GB should definitely have the default set which is to run this process 24 x 7 to ensure it completes.  Exchange 2010 was designed with the mindset that Online Database Scanning should complete at least once every three days.  If it does not, Exchange 2010 will provide a warning event in the Event Logs.

Thanks to Matt Gossage, Program Manager for Storage at Microsoft for providing much of this information. You can see Matt Gossage’s level 300 webcast on Exchange 2010 Storage here.


19 Responses to “Exchange 2010 24×7 Online Defragmentation and Online Database Scanning”

  1. on 26 Oct 2010 at 7:00 amHariramprasath

    any c++ or java programs to calculate

  2. on 26 Oct 2010 at 7:02 amHariramprasath

    Sorry.. Typed only a few words.. Any c++ or java programs to calculate the whitespace in Exchange 2010?!.. I wrote a program using wmi queries to calculate the white space in Exchange 2007 and Exchange 2003, but am unable to find it in Exchange 2010. Is there any other way to do this using any c++ or java?!

  3. on 12 May 2011 at 1:19 pmGhost Scripter

    Get-MailboxDatabase -Status | FL Name,AvailableNewMailboxSpace

  4. on 22 Jun 2011 at 1:26 pmHank

    If I get the Database Size by doing a filesize and do
    Get-MailboxStatistics -Database “Mailbox Database” | Format-Table DisplayName, ItemCount, @{expression={$_.totalitemsize.value.ToMB()};label=”Size(MB)”}

    to get my users and the amount of space they are using should the whitespace equal

    Get-MailboxDatabase -Status | FL Name,AvailableNewMailboxSpace

    because it don't

  5. on 22 Jun 2011 at 4:09 pmElan Shudnow

    The two values should be different. The first is how much space the user's mailbox is using and the second command is how much whitespace the entire database has available for mailbox users to use. Two completely different purposes for those 2 commands.

  6. on 18 Nov 2011 at 7:36 amrahamathullah

    Use below command to display for all the databases:

    Get-MailboxDatabase -Status | FT name,databasesize,available* -auto

    Use below command to display for particular database:

    Get-MailboxDatabase database name -Status | FT name,databasesize,available* -auto

  7. on 10 Feb 2012 at 8:41 ammstr1002

    online maintenance is kind of a croc. I want to see the DB size actually decrease after the process runs, and whitespace is revealed. the same way it would if i ran an eseutil /d . It does not decrease (sometimes it acutally increases) so i really don't find this helpful. yes maybe the DB becomes in a sense more efficient, but when i am faced with a DB going offline in the middle of the day becasue it gets to large, i really don't care about efficiency.

  8. on 10 Feb 2012 at 2:35 pmElan Shudnow

    Sounds like the database being large is a red herring. Exchange 2010 supports up to 64TB databases and the max recommended is 2TB. I've seen a lot of really large databases that haven't had stability problems. So your issues may be related to something other than large database size.

  9. on 12 Apr 2012 at 12:15 pmFrank

    Does changing this setting require the database to be remounted?

  10. on 17 Apr 2012 at 8:17 amElan Shudnow

    Don't know as I've never changed it. Can't test it either atm as I'm rebuilding my entire lab environment.

  11. on 12 Jul 2012 at 1:33 amIan Salgado


    if the option "ENABLE BACKGROUND DATABASE MAINTENANCE (24 x 7 ESE) scanning" is UNTICKED……

    1. Would the WhiteSpace be regain during the processs ?
    2. Would the DB is question not be accessible by users during the process ?
    3. if the DB is in a DAG, what would happen to the copy(ies) of the DB ? would they also reduced in size ?



  12. on 14 Jul 2012 at 7:51 amElan Shudnow

    1. No. The 24×7 option has nothing to do with defragmentation. As stated in my article, 24×7 online defragmentation is not optional and the 24×7 database maintenance process is database checksumming. And even if it was online defragmentation, that only restructures existing data within the database rather than clears up whitespace. The only way to reduce EDB filesize is using eseutil in offline defragmentation mode.
    2. It would be accessible. All this does if it is unchecked is move the scanning process to the maintenace schedule in the middle of the night.
    3. They don't reduce in size. See #1.

  13. on 15 Jul 2012 at 5:07 amnashwa


    I can't understand the configuration of online database checksumming ,you stated in the article that it is configured by default if the enable background database mainitenece is checked ,if it is uncheck you said that it will revert Online Database Scanning so that it runs after all online maintenance tasks are completed

    what online maintenanace tasks will happen if I already disabled or unckeck the background maintenance option .

    if online defragmentation version 2 is running by default and not configured and its aim is to reduce the number of pages why the size is not reduced accordingly.

  14. on 15 Jul 2012 at 8:07 amElan Shudnow

    Online Defragmentation, regardless of version, has never ever in the history of Exchange reduced the size of the database. What happens though during online defragmentation is that whitespace is created and Exchange will use that whitespace instead of expanding the EDB file. The only way to reduce the size of the EDB file is to run offline defragmentation via the ESEUTIL utility.

    You can see here what the online maintenance tasks are that happen in the middle of the night (if you haven't changed the schedule that is):

  15. on 16 Sep 2012 at 10:07 pmExchGirl

    Great post Elan! I believe you can move all users to a new .edb file, then you will reduce size as it does not bring whitespace over. I have done that with .edb's that were 100-300GB in size, took a long time but it worked!

  16. on 28 Sep 2012 at 7:47 amScott

    I read a comment on a separate blog about how reseeding the passive copy of the DAG also does not copy whitespace. Once the passive copy is reseeded, it is made the active copy and the process is done to the other copy.

    Does this sound like a reasonable approach if there is a DAG?

  17. on 12 Nov 2012 at 6:27 pmFLIBOI

    Been crawling the web to find an answer to this one: I have a netiq monitoring system alerting me that my maintenance window is too short. I have a 2010 3 node DAG with 7 dbases all ranging from 190 GB to 350 GB. since the event logs don't show me info about windows anymore I can't tell which databases aren't getting a large enough window. Does anyone know how to determine which dbases aren't getting finished within the one-day maintenance window I have configured?

  18. on 18 Apr 2013 at 1:26 amMvd

    when "24×7 scanning" is turned on, will the "maintenance schedule" be ignored?


  19. on 19 Jun 2013 at 10:34 amcranky

    what would happen if my databases are under 200gb and i have 24×7 ese scanning enabled?

Trackback this post | Feed on Comments to this post

Leave a Reply