MySQL单表缓存
我正在使用一堆简单的 SELECT 查询访问一个相当静态的表。
为了提高性能,我正在考虑为该数据编写自己的内存缓存。
但这感觉就像在做数据库的肮脏勾当。
是否有针对特定表的粒度缓存机制?
I am hitting a fairly static table with bunch of simple SELECT queries.
In order to increase performance, I am considering writing my own memory cache for that data.
But it feels like doing DB's dirty deeds.
Is there such a thing as a granular caching mechanism for a specific table?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您使用 InnoDB,MySQL 会自动为您缓存表,并为索引的常用部分创建哈希索引。
我建议您增加 MySQL 可以使用的内存量,它应该可以自行解决您的问题。
默认情况下,MySQL 的设置是为了节省空间,而不是为了快速运行。
以下是一些可帮助您进行调整的链接:
http://www.debianhelp.co.uk /mysqlperformance.htm
http://www.mysqlperformanceblog.com/2006/09/29/what-to-tune-in-mysql-server-after-installation/" mysqlperformanceblog.com/2006/09/29/what-to-tune-in-mysql-server-after-installation/
还可以使用索引并编写更智能的查询。
但如果您不向我们展示查询,我无法为您提供帮助。
If you use InnoDB, MySQL will automatically cache the table for you, and create hash-indexes for often used parts of the index.
I suggest you increase the amount of memory MySQL has at its disposal and it should take care of your problems all by itself.
By default MySQL is setup to conserve space, not to run fast.
Here are a few links to get you going with tuning:
http://www.debianhelp.co.uk/mysqlperformance.htm
http://www.mysqlperformanceblog.com/2006/09/29/what-to-tune-in-mysql-server-after-installation/
Also use indexes and write smarter queries.
But I cannot help you there if you don't show us the query.
有一个内存数据库(如innodb)。您可以在创建表时选择它。
There is a memory database (like innodb). You select that at table creation time.
您可以尝试将静态 ISAM 表复制到定义为内存驻留的临时表中。 OTOH,在我看来,该表可能已经被缓存,所以这可能没有多大帮助。请向我们展示您的查询怎么样?
You can try copying your static ISAM table into a temporary table that is by definition ram-resident. OTOH, it seems likely to me that the table is already cached, so that might not help much. How about showing us your query?