Timing Linux Script Execution

I am in the process of improving the speed of a MySQL remote connection which connects to an external server on the internet.

In order to test the speed of the remote connection – including query execution and the retrieval of results over the network – I used the time command.

Here is how I used the time command to determine how it took for a remote SQL command to be executed & results received:

time mysql -uroot tsd -A -h myremotesqlserver.com -e "SELECT * FROM orders ORDER BY id DESC LIMIT 5000"

-h defines the host…in my case it was a remote host. I have replaced my remote server hostname with an example one.

-e, followed by an SQL query, executes and retrieves the results for an SQL command.

Here is an example of the results:

real 0m1.251s
user 0m0.033s
sys 0m0.040s

1.251 seconds is a long time for this particular query, as I know how long it should usually take (< 10ms). I decided to move the server to a local network to reduce network speed/latency issues.

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *