I just stumbled upon the maximum column restriction of a fulltext index on adding it to many columns:
ALTER TABLE some_table ADD FULLTEXT (col1, col2, col3, col4, col5, col6, ...);
This can result into the following error:
1070 Too many key parts specified; max 32 parts allowed
This means the index can only be spanned over maximum of 32 columns. To work around this, I could simply create a new column and merge those columns contents:
ALTER TABLE some_table ADD merged_fulltext text NOT NULL;
INSERT INTO some_table(merged_fulltext) SELECT CONCAT_WS(col1, col2, col3, col4, col5, col6, ...);
ALTER TABLE some_table ADD FULLTEXT merged_fulltex;
Now there is a fulltext index over one column with merged content.
Of course now I have duplicated data and the some_table
column must be updated if any of the merged column's content changes, but regarding to the fulltext index:
Is there any difference by using the merged fulltext index instead of one spanned accross multiple columns? Can I use this as a workaround to overcome the too many key parts limitation?
Im just looking to use the fulltext search MATCH(merged_fulltext) AGAINST(...)
always on all columns, so no sorting or searching on just a few columns.