Calculating the execution time of a Mysql Query based on the number of records

青春壹個敷衍的年華 提交于 2019-12-11 13:45:42

问题


Is there any way by which i can calculate the time that would take for a set of Mysql Queries to execute, may be based on the number of records or something, before executing the query?


回答1:


No. There are many factors that go into how long a query takes to execute, including:

  • Hardware specs
  • Network configuration, bandwidth, and load
  • MySQL Server configuration and server load
  • MySQL index usage and execution plan
  • Size of data
  • Size of index
  • Size of result set

The best way to determine how long a query will take is to run it. You should disable the query cache using SQL_NO_CACHE so that the query cache does not skew the results.

Use SHOW PROFILE to see where MySQL is spending its time.

Use EXPLAIN to see the execution plan so that you can optimize the execution plan.

Using EXPLAIN, you can get a feel for whether the query is efficient or not, but you will still have to run it to see how long it takes in your environment.



来源:https://stackoverflow.com/questions/10702447/calculating-the-execution-time-of-a-mysql-query-based-on-the-number-of-records

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!