简体   繁体   English

如何在mariadb10上获得每个表大小的最大索引?

[英]How can I up max index per table size on mariadb10?

I'm using mariadb10.0.3 with brew on Macosx. 我在Macosx上使用mariadb10.0.3和brew。

One of my table has 40 boolean columns and I would like to add indices on those. 我的一个表有40个布尔列,我想在这些列上添加索引。 However, I have an error on create index ddl. 但是,我在创建索引ddl时出错。 Error Message is below. 错误消息如下。

ERROR 1070 (42000): Too many key parts specified; ERROR 1070(42000):指定的关键部件太多; max 32 parts allowed 最多允许32件

How can I increate MAX-INDEXES ? 如何增加MAX-INDEXES?

The limit to the number of indexes is set per storage engine and cannot be changed in regular use. 每个存储引擎设置索引数量的限制,并且在常规使用中无法更改。 There's a --with-max-indexes parameter when compiling. 编译时有--with-max-indexes参数。

But you really need to look at your table and index structure. 但是你真的需要查看你的表和索引结构。 It's unlikely that having 40 indexes to boolean fields will help in any way. 将40个索引添加到布尔字段不太可能有任何帮助。

Unfortunately MySQL has some arbitrary compile time limits. 不幸的是MySQL有一些任意的编译时间限制。 The default limit for key parts is 16. Most RDBMS allow you to set this kind of limite at startup, not compile time. 关键部件的默认限制是16.大多数RDBMS允许您在启动时设置此类限制,而不是编译时。 It's pretty hard to work with snowflakes in MySQL. 在MySQL中使用雪花非常困难。

Unfortunately adding --with-max-indexes to the ./configure will not do the trick as many people around is suggesting: 不幸的是,在./configure添加--with-max-indexes./configure ,因为很多人建议:

./configure --prefix=/usr/local/mysql --with-max-indexes=N

The above line is innocuous. 以上这条线是无害的。

Max indexes is related to foreign keys, but the smaller from MAX_REF_PARTS and MAX_INDEXES . 最大索引与外键有关,但与MAX_REF_PARTSMAX_INDEXES相关的索引较小。

What appears to be effective is to change MAX_REF_PARTS from 16U to 42U on sql/sql_const.h: 似乎有效的是在sql / sql_const.h上将MAX_REF_PARTS从16U更改为42U:

$ grep -R MAX_REF_PARTS ${MYSQL_SOURCE_FOLDER}
$ ./sql/sql_const.h:#define MAX_REF_PARTS 42U           /* Max parts used as ref */

As everybody knows 42 is a much better arbitrary limit as it is the answer for the ultimate question anyway :p (this is a joke with arbitrary limits). 因为每个人都知道42是一个更好的任意限制,因为无论如何它是最终问题的答案:p(这是一个有任意限制的笑话)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM