Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql - difference between fulltext and "normal" index

Tags:

indexing

mysql

I need to understand the difference between just INDEX and a FULLTEXT index.

When I try

SHOW INDEXES FOR all_schools

What I get is a table of rows of indexes. I can obviously tell the Non_Unique indexes, but how can I tell if an index is a fulltext index? Have not found anything specific to this here or elsewhere.

-- EDIT -- The accepted answer below gives me the understanding (concisely) of the difference in nature between a regular and fulltext index.

As to how to differentiate, the link given below is a great way to IDENTIFY the fulltext indexes, so I'll repeat it here: Show a tables FULLTEXT indexed columns

like image 920
Oliver Williams Avatar asked Oct 19 '25 21:10

Oliver Williams


1 Answers

A normal index works pretty intuitively:

id    name
--    -------------------------------
 1    Smith, John
 2    Adams, John
 3    Hancock, John

The whole string in the name field is put in the index and ordered by the collating sequence (usually alphabetically).

A FULLTEXT does almost the same thing, but words are indexed. So, for the above, the fulltext index might contain:

Adams      2
Hancock    3
John       1
John       2
John       3
Smith      1

If this were the full table, then John would not be indexed for fulltext purposes because it is present in more than 50% of the records.

like image 145
wallyk Avatar answered Oct 22 '25 06:10

wallyk