5
Contributors
4
Replies
6
Views
9 Years
Discussion Span
Last Post by linzyxer
0

if you are using mysql 5.1 versions
then u can query general_log table to get the execution time

i dont think we can do it in Mysql 5.0 or lesser versions

if you got any thing show us some light

0

In php, we make use of microtime to find the execution time.

$starttime = microtime();
$query = mysql_query("select * from table");
$endtime = microtime();

Then calculate the difference between $starttime and $endtime. I am sure you can do the same in java as well !

0

i have found another solution

it is in mysql it self
1st. u need to sent a query to mysql with "set profiling=1" i do this after mysql connects & selects the db,

next i made a pretty little function that returns th query time
here is the function:

function Query_time ($displ = false) {
	$qt = 0;
	$qn = 0;
	$sql_time = QueryResultsAsArray("SHOW profiles");
	foreach ($sql_time as $o) {
	$qt = number_format($o->Duration + $qt,6,'.',' ');
	$qn++;
	}
	if ($displ == false)
	return $qt;
	else echo "$qn Querys in ".$qt." sec.";
	return ;
}

and u simply use this function to display the time it took the mysql to execute the query
i hope it helpd :)

0

i have found another solution

it is in mysql it self
1st. u need to sent a query to mysql with "set profiling=1" i do this after mysql connects & selects the db,

next i made a pretty little function that returns th query time
here is the function:

function Query_time ($displ = false) {
	$qt = 0;
	$qn = 0;
	$sql_time = QueryResultsAsArray("SHOW profiles");
	foreach ($sql_time as $o) {
	$qt = number_format($o->Duration + $qt,6,'.',' ');
	$qn++;
	}
	if ($displ == false)
	return $qt;
	else echo "$qn Querys in ".$qt." sec.";
	return ;
}

and u simply use this function to display the time it took the mysql to execute the query
i hope it helpd :)

I want to show profiles data to php....

Can U show me a full code... code i got error at
$sql_time = QueryResultsAsArray("SHOW profiles");

thnks so much :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.