Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enumerate indexes on a Extensible Storage Engine (ESENT) table

Tags:

windows

esent

Background

I'm writing an adapter for ESE to .NET and LINQ in a Google Code project called eselinq. One important function I can't seem to figure out is how to get a list of indexes defined for a table. I need to be able to list available indexes so the LINQ part can automatically determine when indexes can be used. This will allow much more efficient plans for user queries if appropriate indexes can be found.

There are two related functions for querying index information:

  • JetGetTableIndexInfo - get index information by tableID
  • JetGetIndexInfo - get index information by tableName

These only differ in how the related table is specified (name or tableid). It sounds like these would support the function I want but all the info levels seem to require that I already have a certain index to query information for. The only exception is JET_IdxInfoCount, but that only counts how many indexes are present.

JET_IdxInfo with its JET_INDEXLIST sounds plausible but it only lists the columns on a specific index.

Alternatives

I am aware that I could get the index information another way, like annotations on .NET types corresponding to database tables, or by requiring a index mapping be provided ahead of time. I think there's enough introspection implemented to make everything else work out of the box without the user supplying extra information, except for this one function.

Another option may be to examine the system tables to find related index objects, but this is would mean depending on an undocumented interface.

To satisfy this question, I want a supported method of enumerating the indexes (just the name would be sufficient) on a table.

like image 292
Chris Smith Avatar asked Feb 25 '10 19:02

Chris Smith


People also ask

What is Extensible Storage?

The Extensible Storage Engine (ESE) is an advanced indexed and sequential access method (ISAM) storage technology. ESE enables applications to store and retrieve data from tables using indexed or sequential cursor navigation.

What is Esent database?

ESENT is an embeddable, transactional database engine that allows you to create custom applications that need reliable, high-performance, low-overhead storage of data.

What is ese exchange?

ESE is the core of Microsoft Exchange Server, Active Directory, and Windows Search. It's also used by a number of Windows components including Windows Update client and Help and Support Center. Its purpose is to allow applications to store and retrieve data via indexed and sequential access. Extensible Storage Engine.


1 Answers

You are correct about JetGetTableIndexInfo and JetGetIndexInfo and JET_IdxInfo. The twist is that the data is returned in a somewhat complex: a temporary table is returned containing a row for the index and then a row for each column in the table. To just get the index names you will need to skip the column rows (the column count is given by the value of the columnidcColumn column in the first row).

For a .NET example of how to decipher this, look at the ManagedEsent project. In the MetaDataHelpers.cs file there is a method called GetIndexInfoFromIndexlist that extracts all the data from the temporary table.

like image 58
Laurion Burchall Avatar answered Oct 23 '22 03:10

Laurion Burchall