1

How to create index for text data type column in mysql efficiently,for a table having more than 10 L rows (each row has 500 chars).

1 Answer 1

3

If you are using innodb, you should create a FULLTEXT index.

FULLTEXT indexes are created on text-based columns (CHAR, VARCHAR, or TEXT columns) to help speed up queries and DML operations on data contained within those columns, omitting any words that are defined as stopwords.

Please see the MySQL FULLTEXT documentation.

mysql> CREATE TABLE opening_lines (
   id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
   opening_line TEXT(500),
   author VARCHAR(200),
   title VARCHAR(200),
   FULLTEXT idx (opening_line)
) ENGINE=InnoDB;
Sign up to request clarification or add additional context in comments.

3 Comments

I'm using mysql 5.5 and engine is innodb. mysql can't provide FULLTEXT idx option in 5.5, what should i do?
It does exist in 5.5, see docs.
Full-text indexes can be used only with MyISAM tables. (In MySQL 5.6 and up, they can also be used with InnoDB tables.) Full-text indexes can be created only for CHAR, VARCHAR, or TEXT columns.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.