On 4/16/09 8:14 AM, Clint Webb wrote:
I think a more important question is... what do you hope to gain by caching sql queries? mysql and postgresql already have query caches, which work about as good as using memcached as a query cache. However, people dont like it because it clears a table cache whenever the table is modified.
That is a common misconception. At least for MySQL. In many cases, the MySQL query cache can cause more overhead for an application than no caching at all. The process of checking the cache, clearing the cache and so on can be quite burdensome on a write heavy application. In those cases controlling the cache ttl with memcached can give you much better performance.
How are you handling removing cache entries when data is changed? If the data doesn't change, then what benefit is it over mysql built in cache. If the data does change, how are you removing the queries that are invalidated by that change?
Unnecessary connections to the database for one thing. In high load applications, hitting MySQL for the same data 100 times per second, even if from the query cache is not as efficient as memcached. It also becomes a single point of failure.
Brian.
