profiles

MySQL5.0.37 version above supports PROFILING debugging, allowing you to learn more about the resources consumed by SQL statements. PROFILING is for processes, not threads, and other applications on the server may affect your debugging results. Therefore, this tool is suitable for debugging during development, but be aware of its limitations if you want to use it in a production environment.

  • show variables like '%profiling%': Checks whether profiles is enabled. This function is disabled by default
  • set profiling=on; Open the profiles
  • show profile: Queries the elapsed time of each step of the previous SQL statement.
  • show profiles: Records all SQL after all profiles are opened and how long it takes.
  • show profile all for query 2:: Queries the message consumption time for each step of the SQL statement with id 2.
  • show profile cpu,blockio for query 2: