Adding index support to a storage engine revolves around two tasks: providing information to the optimizer and implementing index-related methods. The information provided to the optimizer helps the optimizer to make better decisions about which index to use or even to skip using an index and instead perform a table scan.
The indexing methods either read rows that match a key, scan a set of rows by index order, or read information directly from the index.
The following example shows the method calls made during an
UPDATE query that uses an index, such as
UPDATE foo SET ts = now() WHERE id = 1:
ha_foo::index_init ha_foo::index_read ha_foo::index_read_idx ha_foo::rnd_next ha_foo::update_row
In addition to index reading methods, your storage engine must support the creation of new indexes and be able to keep table indexes up to date as rows are added, modified, and removed from tables.