Improve query performance

Databases, tables, and indexes

Fields, calculations, and criteria

Expressions and Rushmore optimization

Overview of Rushmore optimization

Microsoft Access can optimize simple expressions or complex expressions in the Criteria row of the query design grid, or in a WHERE clause in an SQL SELECT statement. For certain types of complex expressions, Access can use Rushmore, a data access technology used by the Microsoft Jet database engine, to achieve a greater level of optimization. In addition, the Count function is highly optimized for queries using Rushmore.

Rushmore queries will work with Access tables, as well as with Microsoft FoxPro and dBASE tables (.dbf files). You can't use Rushmore with ODBC data sources, since Access sends these queries to the ODBC data source instead of processing them locally.

Simple optimizable expressions

A simple optimizable expression can form an entire expression or can appear as part of an expression. A simple optimizable expression takes one of the following forms:

IndexedField ComparisonOperator Expression

[Order Date] = #09/15/96#

or

Expression ComparisonOperator IndexedField

#11/1/96# < [HireDate]

In a simple optimizable expression:

If you have created indexes for the LastName, Age, and HireDate fields in the Employees table, the following are simple optimizable expressions:

[LastName] = "Smith"

[Age] >= 21

#12/30/90# < [HireDate]

Employees.[LastName] = Customers.[LastName]

[LastName] In ("Smith", "Johnson", "Jones")

[Age] Between 18 And 65

Complex expressions

A complex expression is created by combining two simple expressions with the And or the Or operator. A complex expression takes one of the following forms:

SimpleExpression And SimpleExpression

or

SimpleExpression Or SimpleExpression

A complex expression is fully or partially optimizable depending on whether one or both simple expressions are optimizable, and which operator you used to combine them. A complex expression is Rushmore-optimizable if all three of the following are true:

Note   You can optimize multiple-field indexes if you query the indexed fields in the order they appear in the Indexes window, beginning with the first indexed field and continuing with adjacent fields (up to and including 10 fields). For example, if you have a multiple-field index that includes the LastName and FirstName fields, you can optimize a query on LastName or on LastName and FirstName, but you can't optimize a query on FirstName.

The following different combinations of simple expressions in query criteria indicate the level of query optimization.

Fully optimizable query result (using Rushmore)

Partially optimizable query result (doesn't use Rushmore)

Not optimizable query result

You can also use parentheses to group combinations of simple expressions. The preceding rules also apply to combinations of expressions grouped with parentheses.

Once you've combined simple optimizable expressions into complex expressions, these complex expressions can, in turn, be combined to form even more complex expressions that might be optimizable according to the preceding rules.

These examples assume that you created indexes for the LastName and HireDate fields (simple expressions using them are optimizable) but not the MiddleInitial or FirstName fields (simple expressions using them are not optimizable). The following examples of combined simple expressions show the extent to which the result is optimized.

Fully optimizable query result (using Rushmore)

[LastName] = "Smith" And [Hire Date] < #12/30/90#
[LastName] = "Smith" Or [Hire Date] < #12/30/90#

Partially optimizable query result (doesn't use Rushmore)

[LastName] = "Smith" And [MiddleInitial] = "C"
[FirstName] = "Terry" And [MiddleInitial] = "C"

Not optimizable query result

[LastName] = "Smith" Or [MiddleInitial] = "C"
[FirstName] = "Terry" Or [MiddleInitial]= "C"

General suggestions