Click to See Complete Forum and Search --> : How do I select which database index to use through the ODBC API?


PeterK
June 3rd, 1999, 12:54 PM
I have an MS Access database that contains one table. The table has two indexes: the primary key and an additional index. Both indexes contain multiple fields. I am using the ODBC API to access the database.

My select statement looks like one of these statements depending on which key should be used.

strSQLString.Format("SELECT "
"[INSTITUTION ID],"
"[DOCUMENT ACCOUNT],"
"[PROCESSOR ACCOUNT]"
" FROM accimage WHERE "
"[Institution ID] = ? AND "
"[Document Account] = ? ");

or

strSQLString.Format("SELECT "
"[INSTITUTION ID],"
"[DOCUMENT ACCOUNT],"
"[PROCESSOR ACCOUNT]"
" FROM accimage WHERE "
"[Institution ID] = ? AND "
"[Processor Account] = ? ");

How do I tell ODBC which index to use or does it happen automatically? This section of code happens to be very time critical and the use of the proper index will be important. Is it possible to designate which index to use through the ODBC API?

PeterK
June 21st, 1999, 12:25 PM
I received this reply...

There is no ODBC function to specify which index to use. In general, the
query optimizer will determine the best access method, whether to use an
index, and which index to use.

Some products allow you to provide optimizer hints with your SQL
statements, but not Access.