Search code examples
mysqlcaching

How do a really clear cache in MYSQL?


I would like to run the same query multiple times to see how much time it takes without the aid of cache memory. Running the command RESET QUERY CACHE seems not to work because the query takes a really short time on the second run even after the cache reset. What am i missing?


Solution

  • You can use the SQL_NO_CACHE in the SELECT query.

    https://dev.mysql.com/doc/refman/5.5/en/query-cache-in-select.html

    Keep it in mind that Query cache has been removed in later versions of MySQL.

    Depending on the storage engine, (e.g innodb), it loads table data into memory as part the buffer pool. This part you can't really control on what tables to load and which tables not to load (or at least not easily).