I've observed that if I run a simple "SELECT *" command on a two-row table, 
the query takes anywhere from half a second to four seconds:
 >>>
mysql> select * from pet;
+--------------+---------+---------+------+------------+-------+----+
| name         | owner   | species | sex  | birth      | death | ID |
+--------------+---------+---------+------+------------+-------+----+
| snort        | bennett | mammal  | m    | 1986-12-08 | NULL  |  1 |
| fluttersnort | bennett | mammal  | m    | NULL       | NULL  |  2 |
+--------------+---------+---------+------+------------+-------+----+
2 rows in set (3.95 sec)
 >>>

but if I enter the same command several times in succession, the time taken 
is always "0.00 sec".  In fact, it looks like if I re-enter the query less 
than 15 seconds after the last time it was entered, it takes "0.00 sec" to 
rerun it.  (After the 15-second cutoff, the query times start going back up 
again.)

What causes this?  Does MySQL do any caching of query results?  The first 
alternative explanation that came to mind was that if you re-enter a recent 
query, then the disk files storing the data will still be cached in 
memory.  This is supported by the observation that if you have recently run 
the query
        select * from pet;
then the query
        select * from pet where name="snort";
is also very fast -- i.e. the data itself is being cached (either by MySQL 
or by the file system), not the query results.  However, if that's the 
cache, shouldn't the data still be cached, say, 60 seconds later?  I don't 
think the machine is busy enough that data would be pushed out of virtual 
memory less than 60 seconds after the last time it was placed there, 
although I don't know anything about virtual memory on Linux.

        -Bennett

[EMAIL PROTECTED]     http://www.peacefire.org
(425) 649 9024


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to