Concepts
>
Attributes (MetaAttributes)
> PACK_KEYS \ MySQL
PACK_KEYS \ MySQL
PACK_KEYS takes effect only with MyISAM tables. Set this option to 1 if you want to have smaller
indexes. This usually makes updates slower and reads faster. Setting the option to 0 disables all
packing of keys. Setting it to DEFAULT tells the storage engine to pack only long CHAR or
VARCHAR columns.
If you do not use PACK_KEYS, the default is to pack strings, but not numbers. If you use
PACK_KEYS=1, numbers are packed as well.
When packing binary number keys, MySQL uses prefix compression:
- Every key needs one extra byte to indicate how many bytes of the previous key are the same for
the next key.
- The pointer to the row is stored in high-byte-first order directly after the key, to improve compression.
This means that if you have many equal keys on two consecutive rows, all following "same" keys
usually only take two bytes (including the pointer to the row). Compare this to the ordinary case
where the following keys takes storage_size_for_key + pointer_size (where the
pointer size is usually 4). Conversely, you get a significant benefit from prefix compression only if
you have many numbers that are the same. If all keys are totally different, you use one byte more per
key, if the key is not a key that can have NULL values. (In this case, the packed key length is stored
in the same byte that is used to mark if a key is NULL.)
Translations
Type
String (63) Enumeration
List of MetaClasses
SQL Clause
.
Value
(0), (1), (2).
This site works best with JavaScript enabled