3 ms·
MySQL already caches these. You've added a cache on top of a cache. Is a round trip to the database so slow?
by ars 16y ago
MySQL already caches these. You've added a cache on top of a cache. Is a round trip to the database so slow?
- lukesandberg 16y agoif you are doing 15-20 COUNTS per page (as he said he was) even if you are on a fast local network those few milliseconds of latency can probably add up, also he said he was directly managing updating/invalidating the count cache entries which is probably more effective (because the caching strategy is so specific) than whatever more generic strategy mysql is using.
- kylebragger 16y agoI was under the perhaps false impression that count star queries with or without where conditions are not cached on innodb tables.
- ars 16y agoNot exactly. On isam table the count(*) queries can sometimes directly lookup the answer from the index, or the table statistics. On innodb, because of transactions, this is not possible, and it needs to actually count the rows. BUT, the query itself is still cached - at least until the underlying table gets updated, which invalidates the cache (I'm not sure of the exact invalidation strategy, but it's part of MySQL and doesn't depend on the engine).
- chrisbolt 16y agoUpdating the table invalidates all cached queries that refer to that table, making the query cache useless for any site that gets a decent amount of updates.
- iamjustlooking 16y agoDepending on your database engine and WHERE conditions it may not be cached as you assume it to be.