当前位置:网站首页>Throwing a question? The execution speed of the Count operation in the Mysql environment is very slow. You need to manually add an index to the primary key---MySql optimization 001

Throwing a question? The execution speed of the Count operation in the Mysql environment is very slow. You need to manually add an index to the primary key---MySql optimization 001

2022-08-09 09:59:00 cool brain

Find a table in the project, select count(1) is very, very slow in about 10 seconds, the solution:

Add unique so on the primary key of the table, and then perform the select count operation, you can find that this time becomes 0.28 seconds

The speed is very fast, but it is very strange why the speed is slow, because the primary key is generally indexed by default, why do you need it

It's weird to manually re-index.

I don't understand...hey..what's going on...experts tell me..

原网站

版权声明
本文为[cool brain]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/221/202208090948337169.html