Microsoft Knowledge Base Email Alertz

KBAlertz.com: (99321) - Special considerations must be made for performance optimization of queries built on attached SQL database tables. An SQL database, for this article, is defined as any client/server database that supports some level of ANSI SQL as an intrinsic part of...

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]

Search KbAlertz

Advanced Search

Webmasters
Put kbAlertz on your website.
[ Click Here for more! ]





ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
The ad says 3 - but KBAlertz referrals get
** SIX MONTHS FREE **


Bug Tracking Software
For bug tracking software or defect tracking software or issue tracking software, visit Axosoft.


Community Site



We Send hundreds of thousands of emails using ASP.NET Email



Expert Web Design & Graphic Design
Design44.com

ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
The ad says 3 - but KBAlertz referrals get
** SIX MONTHS FREE **




Mentioned In








Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks




Article ID: 99321 - Last Review: June 28, 2004 - Revision: 3.0

Tips for optimizing Access 97 queries on attached SQL tables

This article was previously published under Q99321
Advanced: Requires expert coding, interoperability, and multiuser skills.

SUMMARY

Special considerations must be made for performance optimization of queries built on attached SQL database tables. An SQL database, for this article, is defined as any client/server database that supports some level of ANSI SQL as an intrinsic part of the database's programming language. Optimal query strategy for these queries is to ensure that all query operations are performed on the server. This article outlines tips on how to ensure that queries against attached SQL database tables are performed on the server.

This article assumes a basic understanding of client/server computing environments and architectures.

MORE INFORMATION

The key to improving query performance on attached SQL database tables is to ensure that no data is filtered on the client. Filtering data on the client increases network traffic and does not allow for leveraging of advanced server hardware, essentially turning a client/server system into a file server system. To this end, keeping the query evaluation on the server reduces overhead and keeps an application running as fast as possible.

Generic query optimization techniques should not be ignored when you are using attached SQL database tables. "WHERE clause" restrictions, such as equality or range comparisons, and sorting should still be performed on indexed fields.

Use care when implementing intrinsic or user defined functions (UDFs) in query fields or when using criteria that are not supported on the server. Generally, SQL databases have functionality that corresponds to most standard Microsoft Access functions, but each server will be different.

Many intrinsic Microsoft Access functions have direct back-end correspondents. Microsoft Access asks the ODBC driver about intrinsic function support and performs the appropriate mappings.

You can use UDFs and Microsoft Access intrinsic functions without server equivalents when they are accompanied by server-capable restrictions that restrict the data. For example, the following query
   Query1a: SELECT * FROM MillionRowTable WHERE Funk1(col1) = 10
				

returns the whole table and evaluates Funk1(col1) = 10 locally, whereas the following query
   Query1b: SELECT * FROM MillionRowTable WHERE Funk1(col1) = 10
                      AND LastName BETWEEN 'g' AND 'h'
				

sends the BETWEEN 'g' AND 'h' restriction to the server, returns the qualifying rows, and evaluates Funk1(col1) on only those rows.

Non-remote-capable SELECT list items do not force a query to be executed locally, unless they are used with unique values or a totals query (DISTINCT/GROUP BY). For example, the following query
    Query2a: SELECT * FROM MyTable WHERE Format(col1, ...) = 10
				

returns the whole table and causes the WHERE clause to be evaluated locally. However, the following query
    Query2b: SELECT Format(col1,...) FROM MyTable WHERE col2 = 10
				

sends "SELECT col1 FROM MyTable WHERE col2 = 10" to the server, presumably returning far less data over the network. It then locally evaluates Format() on the col1 values returned.

Of the following two queries, Query3a is sent completely to the server. Query3b sends "SELECT col1 FROM MyTable" and performs the Format() function, and therefore the DISTINCT clause, locally.
    Query3a: SELECT DISTINCT col1 FROM MyTable
    Query3b: SELECT DISTINCT Format(col1,...) FROM MyTable
				

The following two queries are performed as follows: Query4a is sent completely to the server. Query4b sends "SELECT col1 FROM MyTable" and performs the StdDev() aggregate function locally, since it's not a SQL standard function.
    Query4a: SELECT Sum(col1) FROM MyTable
    Query4b: SELECT StdDev(col1) FROM MyTable
				

Crosstab queries present unique restrictions, some pertinent to all queries, some to crosstab queries only:
  1. Only standard aggregate (totals) functions, such as Count(), Sum(), Min(), Max(), and Avg(), can be used.
  2. Aggregate functions cannot be used as row or column headers.
  3. Only one aggregate function can be used in the "value."
  4. Nothing can be sorted.
  5. If a fixed-value list of column headers is supplied, the value cannot be embedded in an expression.
Restriction #1 applies to all queries against SQL databases from Microsoft Access. Except for #4, the others are uncommon and are crosstab/SQL database specific. Crosstab queries are not SQL standard, and are not generally supported on SQL database servers. However, if the rules above are not violated (which is the case for most simple crosstab queries), Microsoft Access can reformulate the query as a standard GROUP BY query, send it remotely, return only the aggregation result, and transform it into a crosstab locally.

Open-ended restrictions do not use indexes on SQL databases. Typically, a SQL WHERE clause reading
   WHERE col1 > 1000
				

will be slower than
   WHERE col1 between 1000 and 1000000000
				

This is a server problem, not a Microsoft Access problem, but it can affect Microsoft Access performance when a SQL database is used as a back end.

When you are using wildcard characters, take special care to make sure that the correct wildcards are used. SQL Server supports the use of % and _ rather than ? and * for wildcards.

APPLIES TO
  • Microsoft Access 97 Standard Edition
Keywords: 
kbhowto kbinfo kbusage KB99321
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate

Be the first to leave feedback, to help others about this knowledge base article.

(Optional) Name

(Optional) Public URL Or Email

Comments
No HTML -- Text Only Please