I am developing a query browser, working with some large database and I need to know the time taken for executing the query.
I can see the time once the query is executed succesfully in PHPMYADMIN.
Profiling or Showing rows 0 - 29 (2,000 total, Query took 0.0145 sec)
Ex: Profiling
SELECT * FROM `larger_table`;
Status Time
starting 0.000026
checking permissions 0.000006
Opening tables 0.000014
System lock 0.000010
init 0.000022
optimizing 0.000004
statistics 0.000007
preparing 0.000005
executing 0.000001
Sending data 0.014138
end 0.000004
query end 0.000002
closing tables 0.000005
freeing items 0.000091
logging slow query 0.000003
cleaning up 0.000002
In Query Browser I can see the time it takes in the bottom of the browser window.
So how can I get the execution time of the query when submit the query for execution.
i.e When I give the following query:
SELECT * FROM `larger_table`;
The query should return the time for execution it.
This I should catch in PHP and show to the Users.When the user gives some query to executed in browser.
Is there any way to find the execution time when the query is submitted.?
Kindly check the Images where I marked the estimated time.
I found some thing Check this
Please use the code below
$sql_query = 'SELECT * FROM larger_table';
$msc = microtime(true);
mysql_query($sql_query);
$msc = microtime(true) - $msc;
echo $msc . ' seconds'; // in seconds
echo ($msc * 1000) . ' milliseconds'; // in millseconds
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With