Partager via


Improving Query Performance

Applies To: Operations Manager 2007 R2, Operations Manager 2007 SP1, System Center Operations Manager 2007

The Operations Manager database responds to queries from all SDK client applications (many of which run simultaneously), so it is important to consider database performance when you design queries in an SDK client application. The following sections explain how to design optimized database queries.

Using Wildcard Characters

Whenever it is possible, avoid using wildcard characters in the criteria expression for a query. (For more information about wildcard characters, see Criteria Expression Syntax.) If it is necessary to use a wildcard character, limit the criteria as narrowly as possible before you use the character.

For example, when you define a criteria expression to find Management Servers named MSTest01, MSTest02A, and MSTest02B, the criteria expression:

ManagementServerCriteria serverCriteria = new ManagementServerCriteria("Name = 'MSTest0%'");

is more efficient than the expression:

ManagementServerCriteria serverCriteria = new ManagementServerCriteria("Name = 'MSTest%'");

Both of the preceding expressions are more efficient than the following expression:

ManagementServerCriteria serverCriteria = new ManagementServerCriteria("Name = '%Test%'");

Minimizing Query Responses

When you are obtaining information from the Operations Manager database, use a method that returns the minimum amount of necessary information. For example, if you need a specific agent-managed computer object, calling the GetAgentManagedComputers method (with criteria that return a single computer) is more efficient than calling the GetAllAgentManagedComputers method (which returns all agent-managed computers) and then iterating through the resulting collection to find the appropriate computer.

When you query the database for monitoring objects, use partial monitoring objects whenever it is possible. Partial monitoring objects omit any custom properties that are defined for the object's class in a Management Pack. For more information, see Defining Queries for Monitoring Objects.