Mysql, UPDATE is slow

1. The cause of the incident

  1. I wrote a small program that uses the database, and everything else is normal for debugging, but the program is slow. I suspected that there was a problem with my thread pool. After careful investigation, it was found that it was a problem with the database. Because the code related to the database was removed, the speed was fast.
  2. It is determined that it is a database problem, then further in-depth discovery is a SQL statement problem, the execution time is 0.5 seconds, but half a second, it is unacceptable.

    2. Problem sql statement

  3. This sql is very simple, it is a statement to update the state, update grabthe statefields in the table

    UPDATE grab SET state=1 WHERE qid=6896366954471473416

Mysql, UPDATE is slow

3. Why is this happening?

After frantically searching information on search engines, everyone said it was 索引a problem , isn’t it?
I found that for all questions about the database, the unified law is an index problem

  • In fact, it is caused by the difference between the WHERElatter condition and the field type in the data table. Damn mysql, will you report an error if it is different?

4. Try adding double quotes

My field is of varchar type, yours can handle it by itself

UPDATE grab SET state=1 WHERE qid="6896366954471473416"

Mysql, UPDATE is slow

Guess you like

Origin blog.51cto.com/15052689/2603430