What are the biggest benefits of using INDEXES in mysql?

后端 未结 7 1853
无人共我
无人共我 2020-12-09 17:44

I know I need to have a primary key set, and to set anything that should be unique as a unique key, but what is an INDEX and how do I use them?

What are the benefits

相关标签:
7条回答
  • 2020-12-09 18:30

    Pros:

    Faster lookup for results. This is all about reducing the # of Disk IO's. Instead of scanning the entire table for the results, you can reduce the number of disk IO's(page fetches) by using index structures such as B-Trees or Hash Indexes to get to your data faster.

    Cons:

    • Slower writes(potentially). Not only do you have to write your data to your tables, but you also have to write to your indexes. This may cause the system to restructure the index structure(Hash Index, B-Tree etc), which can be very computationally expensive.

    • Takes up more disk space, naturally. You are storing more data.

    0 讨论(0)
提交回复
热议问题