explain select

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

 



Explain select will only explain how mysql is going to use different keys and indexes to optimize query not actually give you a time estimate. The actual time it takes to handle indexes and such, especially if you are using joins, has to do with the Key_buffer and join_buffer values in your my.cnf or my.ini. If you raise these values then it might be faster because there will need to be less disk seeks when doing querry. The speed of a database depends on how much disk accessing need be done on any querry, as I'm sure you know.

So check these values if you really need to speed up queries that use a lot of indexes to generate your results.

C.

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-sta

Carl Furst
cfurst@xxxxxxxxxxxxxxxxxxxx

--
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