Hello. How can I get the k-millisecond for the request? I read that there is a function Explain, but it does not display the time of the request.

So will it be ok?

$startTime = microtime(); ЗАПРОС $endTime = microtime(); 
  • Correctly asked question - is this half the answer? )) - Deonis

1 answer 1

MySQL> 5.0.37 has a built-in profiler. It can be included like this:

 set profiling=1; select count(*) from comment; select count(*) from message; show profiles; 

As a result, we get:

 +----------+------------+------------------------------+ | Query_ID | Duration | Query | +----------+------------+------------------------------+ | 1 | 0.00012700 | select count(*) from comment | | 2 | 0.00014200 | select count(*) from message | +----------+------------+------------------------------+ 2 rows in set (0.00 sec) 

So you can track the "honest" query execution time, bypassing the time to connect with MySQL :)

That's actually a subject

  • one
    And the page was not found)) I'd add from myself that for obtaining information about a specific query you should use show profile for query 1; Thus, you can see what is slowing down in the request. Original Source - BOPOH
  • Thanks turned out. - zloctb
  • @BOPOH but it seems to me that it was found :) - papagaj
  • It is clear that Habr had some problems, now he has been found with me) - BOPOH