CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 1999
    Location
    Wisconsin, USA
    Posts
    953

    How do I select which database index to use through the ODBC API?

    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?



  2. #2
    Join Date
    May 1999
    Location
    Wisconsin, USA
    Posts
    953

    Re: How do I select which database index to use through the ODBC API?

    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.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured