Tables are almost empty - just a few(<10) records for testing.
It seems that those slow queries happen sporadically, one time it
takes 3.4sec, the next time 0.0002sec.
But the interesting part is that it always takes very short or very
long amount of time - never in between.
So because the whole database holds just a few records, and there are
moments that it works as it should - i think it is a server/caching
issue.
I just started developing this app, and it only has primary keys on
"id" column, no other indexes etc.
Fixed! - sort of.
If anybody is interested - it helped changing DB type from InnoDB to
MyISAM.
Somehow InnoDB transactions took very long - it might be a config
problem, i'll investigate it later, but for now, i can continue
developing
Hard to really answer
without seeing what else is going on on that server. Is it idle or is
there traffic on it? Off the cuff, I’m guessing contention in the
db–it’s your updates that are taking a long time. Is this MySQL or
another db?
It also looks like you’re updating your users table with
‘last_updated_at’ on every request… I don’t think that’s gonna scale.