Explanation
1. If the storage engine does not support hash index and you want to improve the performance brought by hash index, you can simulate InnoDB to create a hash index.
2. Create a pseudo-hash index based on B-tree. This is not the same as a real hash index. Because B-Tree is still used to search, but the hash value is used instead of the key itself. Just manually specify the hash function in the where clause of the query.
Example
For example, if you need to save a large number of URLs, you need to retrieve them based on the URLs. If you use B-Tree to store URLs, the stored content will become larger.
select id from url where url = "www.baidu.com";
If you delete the index on the original url column, add an indexed url_crc column, and use crc32 as the hash function, you can use the following method to query:
select id from url where url = "www.baidu.com" and url_crc=CRC32("www.baidu.com");
The above is the detailed content of How to create a hash index in mysql. For more information, please follow other related articles on the PHP Chinese website!