Re: how to get time cost for MySQL query
| From: | Richard Lynch | Date: | Tue, 12 Jul 2005 05:59:16 +0000 |
| Subject: | Re: how to get time cost for MySQL query | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-218509@lists.php.net to get a copy of this message | ||
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@philip.pjkh.com> wrote in message
> news:20050711100227.W82043@wolf.pjkh.com...
>>> 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