当前位置:网站首页>Briefly describe the differences between indexes, primary keys, unique indexes, and joint indexes in mysql, and how they affect the performance of the database (in terms of reading and writing)

Briefly describe the differences between indexes, primary keys, unique indexes, and joint indexes in mysql, and how they affect the performance of the database (in terms of reading and writing)

2022-07-06 06:51:00 CHENFENG Muyang

1. Preface


A brief description MySQL in , Indexes , Primary key , unique index , Joint index The difference between , What is the impact on the performance of the database ( From reading and writing )

This is a very classic MySQL Index interview questions , It is intended to see whether the interviewer understands several types of indexes, as well as the advantages and disadvantages of indexes

2. The difference between several index types


Index is a kind of data structure that helps database get data efficiently , The index file records the reference pointer to the data of the data table

A primary key is a special unique index , There can only be one primary key index in a table , The primary key index is used to uniquely identify a record

A unique index is used to ensure that a column contains only different values , in other words , Unique index can ensure the uniqueness of data records

A federated index is an index built through multiple columns , Such as the : Union primary key index , Union unique index

3. The impact of index reading and writing on database performance


read : Indexing can greatly improve the speed of data query , The index file will be generated after indexing , So essentially, indexing is space for time .

Write : The index lowers the insertion rate , Delete , The speed of updates , Because when the data changes , Will re index , Then the index file will be rebuilt , As a result, the operation of adding, deleting and modifying becomes slower

原网站

版权声明
本文为[CHENFENG Muyang]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207060641426791.html