BUG: Parameterized Queries with JET OLE DB Provider May Run Slow (252883)
The information in this article applies to:
- Microsoft OLE DB Provider for Jet 4.0
This article was previously published under Q252883 SYMPTOMS
Running prepared queries on an Access database using OLE DB may be significantly slower than running the same code using ODBC. Note that this does not apply to stored QueryDefs queries that are a part of the Access database.
CAUSE
One of the advantages of using prepared queries is that the query is compiled only once by the Microsoft Jet database engine. Further executions are very fast since Jet has already generated an execution plan for the query. However, the OLE DB provider for Jet doesn't take advantage of this optimization. Instead, it submits the prepared query to be re-compiled each time you re-query. When you use OLE DB, this requery is achieved in the following three steps: - Call IRowset::Close() to close the rowset returned by ICommand::Execute().
- Change the parameter data.
- Call ICommand::Execute() to create a new rowset based on the new parameters provided in step 2.
RESOLUTION
The only resolution to this problem is to use a stored querydef query instead of prepared queries.
STATUSMicrosoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. REFERENCESFor additional information, click the article number below
to view the article in the Microsoft Knowledge Base:
240412 HOWTO: ExecuteParameterized Command Multiple Times with ATL OLEDB Consumer Templates
For more information on how to enable JET's debugging functions search MSDN for "JETSHOWPLAN".
Modification Type: | Major | Last Reviewed: | 10/15/2002 |
---|
Keywords: | kbBug kbDatabase kbDSupport kbJET KB252883 |
---|
|