Вопрос

My purpose:
I need to make SELECT WHERE string IN ('...') queries, and string is a VARCHAR (1000)

The question:
I do not know if I should use a FULLTEXT index for it or just a simple INDEX

The problem:
The search will be done making a multiple UNION in the query with two similar tables, which contain both the string field, so I don't neither know if the FULLTEXT will make this faster or not.
(My idea of FULLTEXT indexes is using them with MATCH AGINST queries)

The structure:
You can see how I structured my multiple string fields in the different tables in a question I did before at How to structure this DATABASE idea

Note:
This question is about which type of INDEX is better for the case. I just linked the structuring question to give readers more references on what I am doing. It is not a duplicated.

Это было полезно?

Решение

1-N

If you’re words and phrases are common and will be duplicated between many rows, you should consider separating them out into a 1-n relationship. That way searching and querying the data could be more efficient by joining them with your data. This may not meet your requirements – it totally depends on the type of words and phrases.

FULLTEXT

Indexing a varchar 1000 is a bad idea (I don’t like to make assumptions but this is generally always bad). Not only will this use a HUGE amount of memory and index space if your dataset grows it will be a hard performance bottle neck to fix when it starts to become an issue. This is the very reason FULLTEXT is there, if you’re using MySQL 5.6 or greater you can now use FULLTEXT on INNODB tables too – if you’re using an older version it will unfortunately only be supported in MyISAM and that storage engine has is downsides (some rather large ones so please research that before opting for it).

Proper search

The best solution would be to use a proper search engine such as Lucene, Sphinx or Xapian

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top