MyRocks and index-only scans
This article is about MyRocks and index-only scans on secondary indexes. It applies to MariaDB's MyRocks, Facebook's MyRocks, and other variants.
MyRocks indexes use "mem-comparable keys" (index records are compared with memcmp
). For some datatypes, it is easily possible to convert between the column value and its mem-comparable form, while for others the conversion is one-way.
For example, in case-insensitive collations capital and regular letters are considered identical, i.e. 'c' ='C'. For some datatypes, MyRocks stores some extra data which allows it to restore the original value back. (For latin1_general_ci
collation, for example, it will store one bit which says whether the original value was a small 'c' or a capital letter 'C'). This doesn't work for all datatypes, though.
In particular, index-only scans are not supported for
BIT(n)
columns (this could be implemented but at the moment it is not supported)SET(...)
columns (same as above)ENUM(...)
columns (same as above)