mysql index

What are the advantages and disadvantages of using indexes?

Benefit: greatly speeds up queries

Disadvantages: Reduce the speed of adding, deleting, and modifying, and increase the consumption of disk resources (the index file may even be larger than the data file).

How to use indexes?

1. Don’t overuse indexes

2. Fields that are frequently used as query conditions should be indexed

3. Fields with relatively discrete data distribution are suitable for adding indexes, while fields with relatively concentrated data distribution are not suitable for adding indexes (such as gender)

4.  Fields that are updated very frequently are not suitable for adding indexes .

5.  Fields that do not appear in the where clause are not suitable for adding indexes.

According to the object of the index, what kinds of indexes are there?

Common index ( index ), unique index ( unique ), primary key index ( primary key ), full-text index ( fulltext ).

According to the data structure of the index, what kinds of indexes are there?

Hash index, BTree index.

What are the storage engines that Hash indexes and BTree indexes rely on?

The storage engine that BTree index depends on is myisam or innodb , and the engine that Hash index depends on is memory .

The storage engine that BTree index depends on is myisam or innodb , is there any difference?

Using the MyISAM engine, one table corresponds to three save files (structure files, data files, and index files ) . Using the innodb engine, a table corresponds to a save file, that is to say, using the innodb engine, the data file and the index file are bound together, which we call a clustered index.

What is the time complexity of hash index and BTree index?

The time complexity of BTree index is O(log 2N) , and the time complexity of Hash index is theoretically O(1) .



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324672667&siteId=291194637