Max size of UNIQUE index in MySQL

前端 未结 1 746
[愿得一人]
[愿得一人] 2020-12-15 22:46

Is there a max size of a UNIQUE index in MySQL? I have six dimensions in my index, which leads to a massive index. Is there a cardinality limit to UNIQUE<

相关标签:
1条回答
  • 2020-12-15 23:41

    For InnoDB tables, the limit is 3072 bytes across all indexed columns, presumably taking only the first 767 bytes of each column.

    An index key for a single-column index can be up to 767 bytes. The same length limit applies to any index key prefix. See Section 13.1.13, “CREATE INDEX Syntax”.

    The InnoDB internal maximum key length is 3500 bytes, but MySQL itself restricts this to 3072 bytes. This limit applies to the length of the combined index key in a multi-column index.

    http://dev.mysql.com/doc/refman/5.1/en/innodb-restrictions.html

    So, based strictly on the documentation, I'd say you could have up to 1000 columns in your index (the max number of columns on an InnoDB table), provided that the average size of each is 3 bytes or less.

    For MyISAM tables, it's the lesser of 16 columns or 1000 bytes.

    The maximum number of columns per index is 16.

    The maximum key length is 1000 bytes. This can also be changed by changing the source and recompiling. For the case of a key longer than 250 bytes, a larger key block size than the default of 1024 bytes is used.

    http://dev.mysql.com/doc/refman/5.0/en/myisam-storage-engine.html

    0 讨论(0)
提交回复
热议问题