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

MySQLdb (285)

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


  • Andy Dustman

    Andy Dustman - 2005-09-11

    Logged In: YES

    You've provided no evidence to support this position.

  • Nobody/Anonymous

    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:

  • Andy Dustman

    Andy Dustman - 2006-04-21

    Logged In: YES

    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:


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


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks