MySQL:如何将整个 myisam 表保留在内存中?
我的服务器上有大量 RAM (1 GB),并且我有一个表 (100 MB),我想提高其速度。是否可以将整个表保留在内存中(同时保留 MYISAM)?这会让事情变得更快吗(我已经有了正确的索引)。
谢谢
I have a lot of RAM (1 gb) on my server, and I have a table (100 mb) that I would like to increase the speed of. Is it possible to keep the entire table in memory (while keeping it MYISAM)? Would this make things faster (I already have the proper indexes).
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
更好的建议是增加查询缓存大小,让 mysql 进行内部优化
更多细节 - http://dev.mysql.com/doc/refman/5.5/en/query-cache.html
A better suggestion will be increase query cache size, let mysql do the internal optimization
more details - http://dev.mysql.com/doc/refman/5.5/en/query-cache.html
如果你的机器有大量内存并且主要用于 MySQL,那么操作系统应该处理好这一点。使用 MyISAM 的想法是让文件系统将最需要的页面保留在其缓存中。有了大量 RAM,您的表无论如何都不会频繁访问磁盘的可能性就会增加。
恕我直言,这比尝试创建 MEMORY 类型的表更好,因为那样你就必须担心写入 - 无论如何,这些通常应该是持久的。
所以最后,除非机器承受来自 MySQL 服务器以外的其他应用程序的并发内存压力 - 在这种情况下 1GB 对于当今的服务器来说似乎并不多 - 你可能不需要做任何事情来实现你的目标:)
If you have lots of memory in the machine and you use it for MySQL primarily, the OS should take care of that. With MyISAM the idea is to let the filesystem keep the pages in its cache that are mostly needed. With lots of RAM, chances increase that your table will not hit the disk very much anyway.
This is IMHO even better than trying to make the table of type MEMORY, because then you would have to worry about writes - those should usually be persistent anyway.
So in the end, unless the machine is under much concurrent memory pressure from other apps than the MySQL server - in which case 1GB would not seem to much for a server nowadays - you will probably not have to do anything to achieve your goal :)
您可以将表引擎更改为MEMORY,它将把完整的表存储在内存中。
You can change the table engine to MEMORY and it will store the full table in memory.