Databases Reference
In-Depth Information
Flag
Description
HA_READ_RANGE
The index can be used to find all records in a range. If an
index returns values in the sort order, it can do ranges
too, automatically. Indexes that do not preserve sort order
sometimes can do ranges anyway, but they will need the
special read_range_first() and read_range_next()
methods, the default implementation will not work correctly
for them.
HA_ONLY_WHOLE_INDEX
The index cannot search for a prefix of a key, say, when
only the first two columns out of a three-column index have
values. Hash indexes usually have this flag set.
HA_KEYREAD_ONLY
The index supports a so called keyread optimization. MySQL
gives a HA_EXTRA_KEYREAD hint to an engine for a query
when it decides to use an index and this index is covering—
all columns that this query uses are part of the index. For
example:
SELECT a FROM tbl WHERE a > 5;
assuming the column a is indexed. In such a case, the
engine does not need to return the complete row, but can
only restore the columns that are part of the key; in a sense,
"unpack" the key into a row. The HA_KEYREAD_ONLY lag
tells MySQL that the engine can do that and it will be faster
than reading the whole row.
Now, we can write our very own index_flags() method. Our indexes are B-tree
like, and they can do pretty much everything from the previous table:
ulong ha_tocab::index_flags(uint inx, uint part,
bool all_parts) const
{
return HA_READ_NEXT | HA_READ_PREV | HA_READ_ORDER |
HA_READ_RANGE | (inx ? HA_KEYREAD_ONLY : 0);
}
Search WWH ::




Custom Search