I’m having an issue with slowness in my Django project caused by slow mysql queries. Cut and paste the query from the Django log, execute it via the mysql client (to the same database, from same server project is on) and usually they are quite fast.
So say regularly 5 secs from DJango .20 seconds via mysql client (again to same db, from same server) typical result.
Sometimes I will see it slow from mysql client, usually the first time it’s tried if it’s going to happen. I can try it again even 20 minutes later and it will still be fast typically.
Say it just executed fast via mysql client, if I immediately execute it via the problem Django http request, it will still be slow.
Debug is off for Django.
I can reproduce this problem across mysql server versions.
Production server and database are under very light use and have good resources available.
I’ve tried totally recreating the database same issue.
I tried using django-db-connection-pool with no effect.
I’ve tried profiling and stepping into the code to make sure it’s the query, it is.
Slow query log is not showing these problem queries, though I’m not sure how it’s configured.
any suggestions? cheers