Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
345 views
in Plugins by

I just realized that the query:

UPDATE qa_achievements SET questions_read=questions_read+1 WHERE user_id=1 

took 1313.06 ms which is way too long.

The table is created by the badges plugin, see https://github.com/NoahY/q2a-badges/blob/master/qa-badge-admin.php#L232

I have set "user_id" to primary, but that did not help.

Any ideas how to speed up the query? I bet it has to do with the index.

by
An index with userid and questions_read?
by
Actually having userid primary/unique should solve that - and from my knowledge, does not require an additional index (I might be wrong though). ... I researched a bit and it is said, that long query times could be due to locked tables sometimes. - Because I realized that the same UPDATE query of the plugin takes sometimes 100 ms only.

Please log in or register to answer this question.

...