I am trying to figure out how to diagnose a mysql connection issue.
- When I run a group of queries locally on my machine it takes about 1s to run.
- When I run that same group of queries on an AWS machine that has an RDS-backed mysql instance, it takes roughly 8x longer, 8s to run. The machines are roughly comparable in size.
Two questions here:
- How would I go about diagnosing what the issue is? It isn't the query or database, as they are the same in both cases. For example, what are some tools or commands that I could use to pinpoint the possible issue?
- What are some ways to speed up the connection from my ec2 server to the rds server? I was under the impression that an rds-backed instance was relatively the same in speed (if not faster) than having the db on the server.
You should use profiling.
set profiling=1;
Then do your queries in the same session. Then look for profiles:
show profiles;
And display them:
show profile for query X;
, where X - is a number of profile.