What is an index?

后端 未结 7 1841
無奈伤痛
無奈伤痛 2020-12-15 06:42

What is an index in MySQL ????

7条回答
  •  囚心锁ツ
    2020-12-15 07:26

    Indexes speed up select queries. They make the difference between the database having to check every single row in a table for the results and knowing exactly where to go to find the information. It's kind of the same concept as looping through a dictionary type data structure to find what you are looking for instead of just finding the value you want by it's key(index). Indexes will slow down Inserts, updates and deletes though if you have too many because every alteration of the table will now have to create the indexes as well.

    A popular strategy in very very high volume/high performance applications is to have two databases. One that is optimally indexed for fast retrievals and another that has very few indexes for fast inserts. The only issue with this is, you lose real time data when the retrieval database has not synced yet with the insert database.

    There are also two different kinds of indexes. Clustered and non-clustered indexes. If I'm not mistaken, in MySQL primary keys are clustered and all other indexes are non clustered. A good introduction article about the difference is here. It covers SQL Server, but the concept should be the same.

    I haven't worked much with MySQL but from what I can see online, FULLTEXT provides a way to search using a Natural Language full text search. Basically, in the query, you will provide terms to search the full text indexed column(s) on and it will pull back all of the results. Here are a few articles I found on the topic you might find useful.
    MySQL Docs on Full Text Search
    Article 1
    Article 2

提交回复
热议问题