patternsqlMinor
query execution time in mysql
Viewed 0 times
querymysqlexecutiontime
Problem
I have run the query in mysql which consists of approximately 33million records when i have executed the query
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.
- select population1
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.
Solution
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:
If you want to measure how much time takes to write to the standard output, you can do:
Note: Are you sure you want to print a 0 or a 1 for ALL rows from that table? Maybe the option
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>
mysql> nopagerIf you want to measure how much time takes to write to the standard output, you can do:
$ time mysql -u -p \
-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?Code Snippets
mysql> pager cat > /dev/null
mysql> <your query here>
mysql> nopager$ time mysql -u <your user> -p<your password> <your database> \
-e "select population1 < 200000 from city"Context
StackExchange Database Administrators Q#72027, answer score: 5
Revisions (0)
No revisions yet.