Search code examples
databasewinapiextensible-storage-engine

in ESE (JetBlue) is there a way to limit a search with multiple keys?


In Extensbile Strage Engine (ESE/JetBlue) I've got a table that contains data I'd like to locate using two indexes

assuming that each row has three integers X, Y, and Z. I'd like to quickly locate all the rows where X=10 and Y=20 (for example)

the resulting set would contain all the entries where X=10, Y=20, and Z= whever Z happened to be

is this possible?

the sequence of

JetSetCurrentIndex(), JetMakeKey(), JetSeek(), and JetMove() confuse me. i'm not 100% this is even possible without searching for X=10 and then filtering all values where Y!=20 myself?

thanks!


Solution

  • You can do that with the JetIntersectIndexes API, which returns all records contained in two index ranges. You need to:

    1. For the first key value:

    2. For the second key value:

    3. Call JetIntersectIndexes with the two index ranges to create a temporary table of matching bookmarks.

    4. Enumerate the temporary table returned by the call (JetMove). Retrieve the record bookmarks (JetRetrieveColumn) and go to the records (JetGotoBookmark).
    5. Close the temporary table when done! (JetCloseTable).