[development] MySQL query cache

Hans Wolters hans at lonki.xs4all.nl
Thu Aug 30 16:50:47 UTC 2007


Hi all,

With all the talking about caching I would like to ask some things.

Currently I am using MyISAM tables. I have a small moodle site and  
was puzzled about
the amount of memory being used. Tinkered with apache and enabled the  
mysql query_cache.

The last tweak, the cache, is a MySQL only thing, PostgreSQL does not  
use it.

Running the site a few days I kept wondering why it still does not  
really speed up. I think I now
found part of the problem. There are some tables that are unfit to be  
used with the
query cache. This is not due to drupal but more to the specifics the  
query cache is using.
MySQL will optimize queries and will store select queries, when  
possible, in the cache. There
for it does not need to recompile/optimize the query the next time it  
is called. Whenever a value
is updated or inserted in a table the queries that are questioning  
these tables will be invalidated.

For a few Drupal tables this will only generate extra cpu cycles  
without any benefit. Both the session and cache tables are updated  
when enabled in the config on almost every page view.

A solution would be to add SQL_NO_CACHE after the selects on these   
queries. This however
would break the queries for PostgreSQL.

What would be the best way to submit a patch for this?

Best regards,

Hans


More information about the development mailing list