Benchmarking MySQL query execution times from the shell.

This is a handy trick to use perf for benchmarking SQL queries. It runs the query saved in a .sql file X times and displays the average runtime. To be sure that there is no cache interfering with correct results (query cache, table hold in memory, etc), add ‘RESET QUERY CACHE;’ in front of the actual query.