简体   繁体   English

大表中的MyISAM与InnoDB

[英]MyISAM vs InnoDB in a very large table

I have a very simple table 我有一张非常简单的桌子

CREATE TABLE IF NOT EXISTS `largecache` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `tooltip` varchar(255) NOT NULL,
  `name` varchar(100) NOT NULL,
  `attributes` text NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `tooltip` (`tooltip`)
) ENGINE=InnoDB

With about 8 million entries that is used almost entirely for reads. 大约有800万个条目,几乎全部用于读取。 I'm trying to make sure I'm accessing the data as quickly as possible. 我试图确保我尽快访问数据。 I'm currently using InnoDB, is it worth it to switch to MyISAM? 我当前正在使用InnoDB,是否值得切换到MyISAM? My only concern is performance on reads. 我唯一关心的是读取性能。 Also any other recommends I could use to speed up since the DB reads are pretty much my only bottleneck in my application. 我还可以使用其他任何建议来加快速度,因为数据库读取几乎是我应用程序中的唯一瓶颈。

I'm using MySQL client version: 5.1.47 我使用的是MySQL客户端版本:5.1.47

Thanks. 谢谢。

[edit: More details] I'm using php, and I'm querying based on exact matches of the tooltip field. [编辑:更多详细信息]我正在使用php,并且正在根据工具提示字段的完全匹配进行查询。 It's being hosted on a shared VPS with 1 gig of ram, any tweaks to mysql that I can make I'll try, but I know mysql tweaking is a pretty complex issue. 它托管在具有1 gig内存的共享VPS上,我可以尝试对mysql进行的任何调整,但是我知道mysql调整是一个非常复杂的问题。

Example query: 示例查询:

select * from largecache where `tooltip` = "Cm8IuIyq9QMSBwgEFS0iGWAd30SUNR2EHJ0nHYYCY-odxZ6okR0pEnPgHWzQbvIiCwgBFXZCAwAYCCAiMAk4_gNAAEgPUBBg_gNqJQoMCAAQvKHZ5oCAgIA6EhUIrcC1xggSBwgEFUn1i18wCTgAQAEY2ojJgQxQAlgA"

I do have APC installed, but not memcached 我确实安装了APC,但没有memcached

It would be good to have the exact query you do. 拥有您执行的确切查询会很好。 But based on what you have posted here goes- 但是根据您在此处发布的内容,

Are you planning to do any full text search (read myISAM)? 您是否打算进行全文搜索(请阅读myISAM)? Since innodb does row level locking as opposed to myISAM which does table level locking by the looks of it innodb suits your requirements. 由于innodb进行行级锁定,而myISAM进行表级锁定,因此innodb适合您的要求。 Try the following using innodb engine- 使用innodb engine-

  1. Put an index on tooltip field. tooltip字段上放置一个索引。
  2. Try to disable transaction management from innodb config. 尝试从innodb配置禁用事务管理 Although this is more for writes than reads. 尽管这更多的是写而不是读。
  3. Try to increase the cache size for innodb . 尝试增加innodb的缓存大小 All these DB engines are suckers for memory, its as simple as throwing more memory at them & suddenly they behave well. 所有这些数据库引擎都是内存的吸引者,就像向它们扔更多的内存一样简单,突然它们表现良好。
  4. Finally, I cannot end this post without mentioning memcached . 最后,我不能不提及memcached而结束这篇文章。 This is a distributed cache management module & it awesomely integrates with mysql. 这是一个分布式缓存管理模块,它与mysql完美集成。 This can significantly boost your read operations. 这可以大大提高您的读取操作。

Provided links wherever appropriate. 在适当的地方提供链接。

Check this for completeness sake - Why use InnoDB over MySIAM 为完整性起见,请检查此内容- 为什么在MySIAM上使用InnoDB

With the default innodb in 5.1x, all things equal, you might eek ou a little performance boost from myisam if properly tweaked based on only your limited details. 在5.1x中使用默认的innodb,在所有条件相同的情况下,如果仅根据有限的细节进行适当的调整,您可能会发现myisam的性能有所提高。

My suggestIon is go to 5.5 and innodb. 我的建议是去5.5和innodb。

In reality, we need to see some of your queries to understand how you are accessing it. 实际上,我们需要查看一些查询以了解您如何访问它。 Do youhave lots of count(*) 's? 您有很多count(*)吗?

Also, if you're dealing with million of rows 1G of RAM might a little tight--assuming this is not the only table you have. 另外,如果您要处理一百万行,那么1G RAM可能会有点紧-假设这不是您拥有的唯一表。 This is probably your biggest issue regardless of type of table type you choose. 无论选择哪种表类型,这都可能是最大的问题。

Seems like it's more on the MyISAM side. 似乎更多是在MyISAM方面。 In response of "any other recommends I could use to speed up" you can implement full-text search. 作为“我可以用来加快速度的任何其他建议”的回应,您可以实施全文搜索。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM