Re: how to get time cost for MySQL query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Try doing an "explain $query" query.

I *think* MySQL might cache the query/results enough that you'd get an
accurate estimate...

You could also turn MySQL Logging on.

Or, rather crudely, time it in PHP:

$query_start_time = microtime();
$result = mysql_query($query);
$query_end_time = microtime();

It's not going to be 100% accurate, of course, as the overhead from PHP to
MySQL is there, and if you get a *TON* of data in the query, then there's
maybe a LOT of overhead there...

But maybe you're better off including that anyway.

On Mon, July 11, 2005 10:23 am, x said:
> I did checked both of them and it seems they do not provide such info...
> thanks
> "Philip Hallstrom" <php@xxxxxxxxxxxxxxx> wrote in message
> news:20050711100227.W82043@xxxxxxxxxxxxxxxx
>>> Hi, Is there any MySQL lib function which can provide time cost for
>>> last
>>> query?
>>>
>>
>> Maybe...
>>
>> http://us2.php.net/manual/en/function.mysql-info.php
>> http://us2.php.net/manual/en/function.mysql-stat.php
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux