TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Caching MySQL queries

6 pointsby sangguinealmost 17 years ago
Hi. memcached is not really good for MySQL. Then, what is a good way or practice to cache MySQL queries? Do you recommend any reading on caching?

4 comments

bigbeealmost 17 years ago
The easiest way is to use MySQL's own query cache. Increasing its size yields wonderful results.<p>On linux, edit my.cnf and add the following:<p><pre><code> [mysqld] ... query_cache_type=1 query_cache_limit=1M query_cache_size=128M # or more - depends on you total available RAM key_buffer=128M # or more </code></pre> Note that you'll need to restart mysql to make these changes count
andrewfalmost 17 years ago
The biggest thing you need to sort out when caching is exactly how well synced your cache needs to be.<p>Once you've written fresh data to the database, is it okay for you to keep receiving stale data in response to later queries?<p>If you've got multiple web servers, do they all have to return the same data, or is it okay if some lag behind the others?<p>If you're happy to serve stale (versus some tunable time metric) data inconsistently across different servers, then just find a database client library that does client-side result set caching (ADODB for PHP will do this, either in the filesystem or against memcache) and run with it.
gtanialmost 17 years ago
<a href="http://www.databasejournal.com/features/mysql/article.php/3110171" rel="nofollow">http://www.databasejournal.com/features/mysql/article.php/31...</a> <a href="http://dev.mysql.com/doc/refman/5.0/en/query-cache-how.html" rel="nofollow">http://dev.mysql.com/doc/refman/5.0/en/query-cache-how.html</a> <a href="http://www.mysqlperformanceblog.com/2008/01/29/how-mysql-query-cache-works-with-transactions/" rel="nofollow">http://www.mysqlperformanceblog.com/2008/01/29/how-mysql-que...</a>
aaroneousalmost 17 years ago
What do you mean memcached is not good for MySQL?
评论 #206464 未加载