1

I wanted to have one specific column be unique and also optimized for searching and sorting. Meanwhile the same column should have fulltext search capability. Should I add all three indexing types (Unique, Index, and Fulltext) together on this column or not?

Please help and thanks.

--Edit

Thanks @Fuujin for the quick comment.

What if I have the following indexing, no need for adding "Index" indexing anymore on neither of them, right?

ALTER TABLE `mytable` ADD UNIQUE (`column_1`, `column_2`); 
3

1 Answer 1

2

One column:

UNIQUE(x) FULLTEXT(x) 

Adding INDEX would be redundant, since UNIQUE is an INDEX.

Two columns:

UNIQUE(x,y) -- the order depend on what your queries look like (see below) FULLTEXT(x,y) FULLTEXT(x), FULLTEXT(y) -- may need these (see below) 

WHERE x > 5 AND y = 2 needs (y,x) order

If you search only one of the two columns, such as MATCH(x) AGAINST(...), then InnoDB, but not MyISAM, needs the extra FULLTEXT indexes.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks @rick. So, you're saying if I'm on MyISAM only FULLTEXT(x,y) would be enough for any fulltext searching? Also ordering point you mentioned was not completely clear for me.
In a list of people ordered by (last_name, first_name), you can quickly find last_name='James' AND first_name LIKE 'R%', but it is much harder to find first_name = 'Rick' AND last_name LIKE 'J%'.
Thanks. Can you also take a look at this question of me: stackoverflow.com/questions/35267528/…

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.