Ways to optimize query performance

Ways to optimize query performance

There are many things you can do to make your query run faster. In addition to the following tips, you can use the Performance Analyzer to analyze specific queries in your database. For information on using the Performance Analyzer, click .

Because the IIf expression in Q1 cannot be optimized, Q2 also cannot be optimized. If an expression that can't be optimized is nested within a subquery, the entire query cannot be optimized.

An alternative way to construct the query is as follows:

Q1: SELECT * FROM MyTable WHERE MyColumn = "Yes";

If expressions are necessary in the output, try to place them in a control on a form or report. For example, you could change the previous query into a parameter query that prompts for the value of MyColumn, and then base a form or report on the query. On the form or report, you could then add a calculated control that displays "Hello" or "Goodbye" depending on the value in MyColumn.

Construct the query as follows:

PARAMETERS [To see confirmed orders, enter Yes. To see unconfirmed orders, enter No.] Text;
SELECT *
FROM MyTable
WHERE MyColumn = [To see confirmed orders, enter Yes. To see unconfirmed orders, enter No.];

In the calculated control on the form or report, enter:

=IIF([MyColumn]="Yes","Order Confirmed","Order Not Confirmed")

Note   For tips on optimizing external SQL database performance .