Forums

MySQL slower than SQLite

Hi, I changed db from SQLite to MySQL and I'm getting slower response time on each simple PUT method call. This is suspicious to me, since it should be faster using MySQL. So I tested the same application on a different account that was already using MySQL and I get response times = [0.047, 0.031, 0.034, 0.032, 0.032 ... ] which is very satisfactory; however on this account, I am getting [0.126, 0.113, 0.110, 0.134, 0.123 ...]

Clearly I did something terrible in between the steps. To describe how I set up MySQL this time, I did following steps:

  1. Setup password by going into Database tab
  2. pip install mysqlclient
  3. Changed setting.py DATABASE configuration (https://help.pythonanywhere.com/pages/UsingMySQL/)
  4. python manage.py migrate (I would like note that this process took about 10 min)

Also, If I switch the DATABASE configuration from MySQL to SQLite on Django Setting.py, I get relatively faster response time. This is very strange.

Although, this performance drop isn't too significant (but yes it still bothers me :D), I still want to know why and possibly learn few things from this experience. I would appreciate for any advice/enlightenment!

Sorry for the slow reply! That does sound strange. Which account did you see the better MySQL performance on, so that we can check what the differences between the two are?

Thank you for your reply!

it is username: jeffrey. jeffrey.pythonanywhere.com/frontend. I tested with complete/incomplete (round check mark).

We've had users reporting long migrates in the past and the usual cause was locks from their web app that were preventing the migrate from getting the locks that it needed to run. So when they stopped their web app (or task) from using the database, the migrate ran moire quickly.

That could be the cause of the slower queries between accounts and for MySQL being slower - if there are other processes with table locks they may be preventing your query from getting the lock it needs. If you're using a PUT, that suggests that you're writing to the database, so locking would become more important. If you see similar time differences with reads, then that may be an issue that we should look at more in-depth.