Search code examples
mysqldatabasequery-optimization

MySQL query result: What does the time shown mean?


I am running some MySQL queries from a shell. At the end of the query result, MySQL prints the total number of rows in the result and a time duration.

mysql>select * from mytable;
[Query result here]
1000000 rows in set (1.50 sec)

What does the 1.50 sec mean? From my trials, I understood it is not the total query duration. Is it the query processing time within the database engine? Or something else?


Solution

  • It is a period of time between start_timer and mysql_end_timer calls within a function that executes your query. As I understand, it is the time spent on the preparation of the result set on the server side, before you started to fetch the result set from the server.

    There is a similar question and the answer with links on the neighbor site: https://dba.stackexchange.com/a/72076/16185.