#152 MySQL-Query-cache won't work with MySQLdb

MySQLdb-1.3
closed
Andy Dustman
MySQLdb (285)
5
2012-09-19
2005-09-11
Anonymous
No

When using MySQLdb on debian (MySQL 4.0.24;
MySQLdb 1.2) the MySQL-Query-caceh isn't used.
Using _mysql directly it works.

Discussion

  • Andy Dustman
    Andy Dustman
    2005-09-11

    Logged In: YES
    user_id=71372

    You've provided no evidence to support this position.

     
  • Logged In: NO

    I just experience exactly the same thing. I am also on
    Debian, MySql version 4.0.24_Debian-10sarge1-log. And using
    MySQLdb.version_info = (1, 2, 1, 'gamma', 2).

    I am actually using MySQLdb via a Python web framework
    called Django (www.djangoproject.com). And a lot queries
    seem to get cached, because the number
    Qcache_queries_in_cache is increasing. But, the number of
    cache hits stays zero! However when I execute a query
    several times on the MySQL command line the number of cache
    hits actually do increase.

    See also:
    http://groups.google.nl/group/django-users/browse_thread/thread/7f4e3e44b2b311e4/c8c313bb122107a7#c8c313bb122107a7

     
  • Andy Dustman
    Andy Dustman
    2006-04-21

    Logged In: YES
    user_id=71372

    If you can write a test case that demonstrates this, I'll
    try to fix it in 1.3. Your test case should print the result of:

    SELECT query_cache_type

    But I think this is your problem:

    http://dev.mysql.com/doc/refman/4.1/en/query-cache-how.html

    "In MySQL 4.0, the query cache is disabled within
    transactions (it does not return results). Beginning with
    MySQL 4.1.1, the query cache also works within transactions
    when using InnoDB tables (it uses the table version number
    to detect whether its contents are still current)."

    So your problem would appear to be due to using 4.0.x. I'd
    recommend trying with 4.1 or 5.0. I am still pretty certain
    this is not a MySQLdb issue.