1. The cause of the incident
- 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.
- 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
- This sql is very simple, it is a statement to update the state, update
grab
thestate
fields in the tableUPDATE grab SET state=1 WHERE qid=6896366954471473416
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
WHERE
latter 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"