尽管设置正确,但Aurora无服务器MySQL仍使“索引列大小过大”

时间:2019-05-20 20:33:09

标签: mysql serverless amazon-rds-aurora aws-serverless aws-aurora

我正在尝试将索引添加到现有表中,作为Invision社区论坛升级过程的一部分。该数据库托管在具有MySQL 5.6兼容性的AWS Aurora Serverless中。但是,每次,我都会收到错误消息:

ERROR 1709 (HY000): Index column size too large. The maximum column size is 767 bytes.

以下是有关表和架构的详细信息:

+---------------+--------+---------+------------+-------+----------------+-------------+-----------------+--------------+-----------+----------------+-------------+-------------+------------+--------------------+----------+--------------------+---------+
| Name          | Engine | Version | Row_format | Rows  | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time | Update_time | Check_time | Collation          | Checksum | Create_options     | Comment |
+---------------+--------+---------+------------+-------+----------------+-------------+-----------------+--------------+-----------+----------------+-------------+-------------+------------+--------------------+----------+--------------------+---------+
| ibf_core_tags | InnoDB |      10 | Dynamic    | 36862 |            299 |    11026432 |               0 |     13189120 |   4194304 |          95183 | NULL        | NULL        | NULL       | utf8mb4_unicode_ci |     NULL | row_format=DYNAMIC |         |
+---------------+--------+---------+------------+-------+----------------+-------------+-----------------+--------------+-----------+----------------+-------------+-------------+------------+--------------------+----------+--------------------+---------+
+--------------------+--------------+------+-----+---------+----------------+
| Field              | Type         | Null | Key | Default | Extra          |
+--------------------+--------------+------+-----+---------+----------------+
| tag_id             | bigint(20)   | NO   | PRI | NULL    | auto_increment |
| tag_aai_lookup     | char(32)     | NO   | MUL |         |                |
| tag_aap_lookup     | char(32)     | NO   | MUL |         |                |
| tag_meta_app       | varchar(200) | NO   | MUL |         |                |
| tag_meta_area      | varchar(200) | NO   |     |         |                |
| tag_meta_id        | int(10)      | NO   |     | 0       |                |
| tag_meta_parent_id | int(10)      | NO   |     | 0       |                |
| tag_member_id      | int(10)      | NO   | MUL | 0       |                |
| tag_added          | int(10)      | NO   | MUL | 0       |                |
| tag_prefix         | int(1)       | NO   |     | 0       |                |
| tag_text           | varchar(255) | YES  |     | NULL    |                |
+--------------------+--------------+------+-----+---------+----------------+

该表的默认字符集为utf8mb4,innodb_large_prefix设置为ON

我要执行的操作是:

ALTER TABLE `ibf_core_tags` ADD KEY `tag_text` (`tag_text`(191));

我认为191 * 4 = 764,小于它表示超出的767字节值。这是Aurora Serverless中的错误吗?有没有解决这个问题的方法?我曾尝试将表更改为MyISAM以添加索引,但是当我尝试这样做时,实际上却遇到了相同的错误。

使用本地安装的MySQL 5.6,我能够在同一数据库上运行此ALTER TABLE查询,因此我不确定Aurora Serverless为何有所不同。

1 个答案:

答案 0 :(得分:1)

在使用Laravel进行数据库连接的Slim PHP项目中,我遇到了同样的问题。默认情况下,AWS Aurora Serverless使用的文件格式为Antelope,默认为行格式为COMPACT。我们需要Barracuda的文件格式和DYNAMIC的行格式,以允许使用较大的索引键前缀(reference)。

我创建了一个自定义参数组,并明确设置了以下参数:

  • innodb_file_format = Barracuda
  • innodb_file_per_table = 1
  • innodb_large_prefix = 1

允许根据AWS's Aurora Serverless documentation设置这些参数。

设置这些参数本身并不能解决问题。仍以COMPACT行格式创建表。在数据库连接参数中,我还必须设置'engine' => 'InnoDB ROW_FORMAT=DYNAMIC'reference)。这种语法适用于Laravel,但希望它能为其他人指明正确的方向,因为我整个下午都在弄清楚:)

相关问题