Mysql – query execution time in thesql

MySQLmysql-5mysql-5.5mysql-workbench

I have run the query in mysql which consists of approximately 33million records when i have executed the query

  • select population1 < 200000 from city;
    it shows like this after execution

34459393 rows in set (16.04 sec)

My question is what is 16.04 sec because in normal time it has taken morethan 30min but it shows 16.04 sec.
How can i calculate the actual time.

Best Answer

The 16.04 seconds is a timer on the client that measures the amount of time that passed between the call and the execution of the query (if you want to be more specific than that, the wall clock time between calling start_timer() and mysql_end_timer(), something that can lead to hilarious results like this one I got).

The reason that you think that it took you more than 30 minutes to execute is probably because it doesn't have into account the output to the stdout. You can check that it really takes 16 second by doing:

mysql> pager cat > /dev/null 
mysql> <your query here>
mysql> nopager

If you want to measure how much time takes to write to the standard output, you can do:

$ time mysql -u <your user> -p<your password> <your database> \
  -e "select population1 < 200000 from city"

Note: Are you sure you want to print a 0 or a 1 for ALL rows from that table? Maybe the option --safe-updates and/or using a GUI can help you a bit with your queries?