Welcome to MSDN Blogs Sign in | Join | Help

Microsoft Exchange and Search Folders

The Exchange search folders tend to be a very complicated subject for a lot of administrators. There are two different ways of filtering messages in MAPI - (Search folders and restrictions).

  • A search folder is like a regular MAPI folder, except that instead of containing real messages, it contains only links to messages in other folders which meet some specified restriction.  A search folder is created by calling IMAPIFolder::CreateFolder with a folder type of FOLDER_SEARCH, followed by a call to IMAPIContainer::SetSearchCriteria to specify the search restriction and search domain.  The search domain may be an arbitrary set of folders in the same store, and may be recursive, so that messages in any sub-folder of the specified domain folders are also searched.
  • A “restriction” is formed by calling IMAPITable::Restrict on a MAPI Table.  The resulting table shows only the items which match the restriction specified in the Restrict call.  A restricted contents table can show only messages from a single folder.  This usage sometimes causes confusion with the MAPI-defined structure which describes the filter criteria for a search folder, which we also call a restriction.

The only way that the contents of a search-results folder can be modified is through a call to SetSearchCriteria. For more information about the implementation of SetSearchCriteria, see Knowledge Base article 260322: How To Search Folders with the SetSearchCriteria Method. 

Search-results folders have the following limits:

  • Messages cannot be moved or copied into search-results folders.
  • Search-results folders cannot contain subfolders.
  • Clients cannot make a search-results folder the subject of a search.

When a client (any application with search capabilities) sets up a restriction on a contents table object (which is known as a VMSG – View Message Object), we will create a hidden search folder which searches the original folder, and will point the VMSG at the search folder. Clients have no knowledge that this has occurred, and will only that some of the messages have disappeared from the table. This is not a fast process because even a restriction on a small table requires that we create a new folder row and a new message folder table in Jet. Creating tables via Jet will cause us to log transactions because we are creating objects. Excessive logging can lead to complications and 623’s (Version Store Out Of Memory). For more information on Version Store please see this blog: "Troubleshooting Version Store issues - JET_errVersionStoreOutOfMemory". In addition to that blog I also reviewed an article that we wrote and we blogged about it on the Exchange Blog site: "Version Store issues revisited - Event ID 623 at Information Store service startup".

Now there are two types of search folders (Temporary and Permanent) that can get created.  When you create a hidden search folder this is actually a “permanent” part of the database, it can be reused later when someone performs the same restriction. Search folders are very much like regular folders. Each search folder has a single row in the folders table. Instead of a message folder table, there is a search table with a name like “S-1-4309”. The S denotes that this is a search folder and the following [1-4309] is the FID of the search folder.

Search tables will contain a subset of message folder tables that have columns.  Ideally you want to have only a few columns and each row should be just a pointer to the “real” message in another folder.

Search folders can be created by a number of applications like Outlook, or any 3rd party application that issues searches for messages in an information store. The problem starts to manifest itself when a lot of search folders are created and never deleted by the application that creates them.

What is a Search Queue and how is it used in Exchange?

When Exchange has a larger search operation it will use the search queue. When a search event is issued against a search folder, we create a task and we enter that task into the databases search queue. The search queue is a Jet table and is a permanent part of the database. Each row in the search queue will represent a particular search event that was previously entered. For example “search folder ‘Inbox’ with respect to a search folder called ‘Dave’s Search Folder’, and create links for any messages which match”.

When a search folder is created, or other operations occur which cause a search to be modified, the appropriate search events are added to the search.  Once the transaction has been committed, Exchange will then call a function to start the search task operation. This will process the search events listed in the databases search queue. This is done so if the information store is shut down or crashes before the search is complete, the search event will still be in the search queue.  When Exchange starts up, it will also call a function to start searching for any search tasks events in the search queue.

When a restriction is started, the same search events are entered in the search queue as for a regular search folder.  Rather than starting a separate background task to actually perform the search, restrictions process the search events immediately on the RPC thread before returning.

Having a ton of search folders will impact an exchange servers performance. When messages are created, modified, or deleted, all of the search folders linked will be updated immediately, within the same transaction as the original message operation. Since all search folders are updated in one big transaction, all search folders need to be locked before the transaction begins. When the exchange server starts to process batches of transactions it will begin to use up the stores Version Store cache to process these transactions.

There is a way that this can be controlled to a small extent and you can age out the views. For more information please see this article: How to Temporarily Delete Existing Search Folders.

I have also written a tool that will allow you to take an isinteg.pri file and search through it to look for users that have a very high amount of search folders.

Download Link: https://code.msdn.microsoft.com/Release/ProjectReleases.aspx?ProjectName=FindSearchFolders&ReleaseId=1456

Here is what the output looks like if you are search for a mailbox that has a high item count and high search folders. The action plan for finding the mailbox with the high search folder count is listed at the end of this output.


**********************************************************
Find Search Folders
Dave Goldman - Exchange Escalations Services
NOTE: There is no support for this tool and will be used as is!
Purpose: Scan an isinte.pri file and find the highest search folder offenders
Trace time: 09/15/09 11:27:42
**********************************************************
Opening C:\Users\DGOLDM~1.NOR\AppData\Local\Temp\FindSearchFolders.txt for writing.

Could not find c:\program files\Exchsrvr\mdbdata\isinteg.pri
Checking the current application path for an isinteg.pri file

Isinteg.pri file located in: D:\Tools\FindSearchFolders\release\isinteg.pri
Opening D:\Tools\FindSearchFolders\release\isinteg.pri for writing.

Isinteg is from server name: server.corp.company.com

.. Truncated for readability ...

Parent FID=000F-0000073E49F8
Name=Contacts
Folder Type=1
Msg Count=4
Search Fids found: 358

Parent FID=0036-000001D88044
Name=Contacts
Folder Type=1
Msg Count=197
Search Fids found: 96

Parent FID=0036-000012B67D11
Name=Contacts
Folder Type=1
Msg Count=30
Search Fids found: 98

Total number of mailboxes with over 75 search folders: 14
Highest number of search folders found in a single mailbox: 358
Highest offender is: Folder FID=000F-0000073CC00F
Parent Folder: Parent FID=000F-0000073E49F8
Total folders that do not contain search folders: 146112

These are the possible folder types
===================================
Folder_Root = Folder Type = 0
Normal_Folder = Folder Type = 1
Search_Folder = Folder Type = 2
MDB_Attachment_Folder = Folder Type = 4
Repl_Folder = Folder Type = 5
Categorization_Folder = Folder Type = 7

NOTE: Folders with a type of 7 are cached views in the information store.

For more information please see: http://technet.microsoft.com/en-us/library/bb124802(EXCHG.65).aspx

To expire cached views from the information store, please see: http://technet.microsoft.com/en-us/library/bb124802(EXCHG.65).aspx

Who has the highest search folder count in an isinteg dump
**********************************************************
1. Take the highest offenders Parent FID and search the isinteg.pri file for this..
2. Look in the ESM and match these items counts and you should have your offending mailbox.

c:\isinteg.pri closed.
FindSearchFolders.txt closed.
Scan completed

3. Searching for the following fid's takes me to objects that look like this with a massive amount of items in the inbox.

4. From here I can look in the ESM (Exchange System Manager) to match up the number of items and I have the user who keeps taking down the exchange server!

[2544] Folder FID=0001-000000DF77E1
       Parent FID=0001-000000DF88C8
       Root FID=0001-000000DF88C7
       Folder Type=1
       Msg Count=118,257
       Msgs Unread=101,783
       Msgs Submitted=0
       Rcv Count=0
       Subfolders=0
       Name=Contacts
       Comment=
       Restriction=
       Search FIDs=0001-000000E0EDB5,0001-000000E0EDB8,0001-000000E35105,0001-000000E35106,0001-000000E35109,0001-000000E3C29C,0001-000000E3C29D,0001-000000E3C29E,0001-000000E3C2A1,0001-000000E3C2A4,0001-000000E3C2CC,0001-000000E3C2CD,0001-000000E3E61A,0001-000000E3E61B,0001-000000E3E61C,0001-000000E3E62E,0001-000000E3E65D,0001-000000E3E693,0001-000000E40831,0001-000000E40832,0001-000000E40869

... Removed to save space ...

       Scope FIDs(search folder only)=
       Recursive FIDs=
       Search Backlinks=0001-000000E0EDB5,0001-000000E0EDB8,0001-000000E35105,0001-000000E35106,0001-000000E35109,0001-000000E3C29C,0001-000000E3C29D,0001-000000E3C29E,0001-000000E3C2A1,0001-000000E3C2A4,0001-000000E3C2CC,0001-000000E3C2CD,0001-000000E3E61A,0001-000000E3E61B,0001-000000E3E61C,0001-000000E3E62E,0001-000000E3E65D,0001-000000E3E693,0001-000000E40831,0001-000000E40832,0001-000000E40869,0001-000000E40894,0001-000000E40895,0001-000000E40896,0001-000000E40897,0001-000000E41E88,0001-000000E41E89

... Removed to save space ... 

If you are looking for a mailbox that has a massive amount of search folders like the one above you can do the following:

1. Put the isinteg.pri in the root of your c:\, or in the same folder that you are running FindSearchFolders.exe from.
2. Run the tool. and this will create the FindSearchFolders.txt file in the root of your users temp directory.
4. Look at the bottom of the log file and find the fid that has the most search folders.
5. Then open the isinteg.pri file and search down for that fid until you cant go anymore, this will be your offender,
6. Get the root fid from that and search up from the bottom and that is your mailbox 

Dave

Published Tuesday, July 01, 2008 9:57 AM by dgoldman

Comments

Saturday, July 05, 2008 8:18 AM by subject: exchange

# Weekend reading

Tutorial: SAN storage for Microsoft Exchange Server How to access SharePoint sites through Microsoft

Wednesday, July 09, 2008 8:38 AM by Matt Johnson's Technical Adventures

# Interesting Links 7/09/2007

The list is a little longer today because of not posting last week. Enjoy! Microsoft Advanced Windows

Friday, August 22, 2008 10:00 AM by Dgoldman's WebLog

# Exchange search folders and performance ramifications

A while back I wrote a few blogs so I could get some detailed information out on how search folders work

Tuesday, August 26, 2008 11:38 AM by Dgoldman's WebLog

# SearchFolderFinder has now been posted.

Today I posted the SearchFolderFinder.exe on http://code.msdn.com/SearchFolderFinder . I hope that this

New Comments to this post are disabled
 
Page view tracker