简体   繁体   English

mysql-MyISAM或InnoDB-连接速度与查找速度

[英]mysql - MyISAM or InnoDB - Join speed vs Lookup speed

Read question before closing as duplicate pls., because there are many questions about this, but at least I didn't find what I was looking for. 在关闭之前,请先阅读问题作为重复的pl。,因为对此有很多疑问,但至少我没有找到想要的东西。

What is clear by now: 现在清楚的是:

 MyIsam is faster at searching strings (much faster)
 InnoDB is faster at joins (much faster)

So my problem is this: I have the following setup: 所以我的问题是这样的:我有以下设置:

Two tables, lets say t1 having columns id , bla1 , bla2 , ..., blan ; 两个表,假设t1的blan idbla1bla2 ,..., blan and t2 having columns t1Id , extra1 , extra2 , ..., extran . 和t2具有列t1Idextra1extra2 ,..., extran

Table 1 (t1) is InnoDB (needs transactions on it so that's clear). 表1(t1)是InnoDB(需要进行事务处理,这很清楚)。 Table 2 (t2) is always used with t1 (is extra data for some specific cases), so there will always be a join between those to where ever t2 appears. 表2(t2)始终与t1一起使用(某些情况下是额外的数据),因此在t2出现的位置之间始终存在连接。 That would point to InnoDB. 那将指向InnoDB。 The thing is that after the join a search will be also done (always) for a string inside one of the columns. 问题是在连接之后,还将(总是)搜索其中一列内的字符串。 This would point to MyISAM. 这将指向MyISAM。

Time to get something is obviously the sum between the join time and the search time. 获得时间的时间显然是加入时间和搜索时间之间的总和。 The problem is that if I optimize one I make the other slower. 问题是,如果我优化一个,我会使另一个变慢。

Bonus facts: Tables are really really big, t2 never needs transactions, row lock or whatever usually impose InnoDB. 值得一提的事实:表确实非常大,t2永远不需要事务,行锁或通常需要使用InnoDB的任何东西。

What is the better choice? 有什么更好的选择? MyISAM or InnoDB? MyISAM还是InnoDB?

The only way to say for sure is to create two tables, load them with sample data and measure your queries. 可以肯定地说的唯一方法是创建两个表,向它们加载示例数据并衡量您的查询。

In general I would recommend you to use InnoDB: 通常,我建议您使用InnoDB:

  1. Since MySQL 5.6 full-text search is also availiable in InnoBD ( http://dev.mysql.com/doc/refman/5.6/en/fulltext-search.html ) so I think you will lose your MyISAM fast string search as main betefit 由于InnoBD( http://dev.mysql.com/doc/refman/5.6/en/fulltext-search.html )中也提供MySQL 5.6全文搜索,因此我认为您将失去MyISAM快速字符串搜索的主要功能福利
  2. With MyISAM you lose not only row-locking support but foreign keys also as well as data integrity + don't forget about MyISAM "crashes" 使用MyISAM,您不仅会丢失行锁定支持,而且还会丢失外键以及数据完整性,而且不要忘记MyISAM的“崩溃”

I would do this way: 我会这样:

Check here for a free mysql query analyzer. 在这里检查免费的 mysql查询分析器。

In this way you can see which is the cost for the join and for the search. 这样,您可以看到加入和搜索的费用。 Then you should choice the format based on the results! 然后,您应该根据结果选择格式! If the search "cost" more, then choice mYisam, for example. 如果搜索“花费”更多,则选择mYisam。

In addition to that: here there is a nice comparison which helps you to find which could be best for you depending even on number of insert etc. 除此之外: 这里有一个很好的比较,它可以帮助您找到最佳的选择,甚至取决于插入的数量等。

Hope it helps. 希望能帮助到你。 It's difficult to say: one is better. 很难说:一个更好。 in GENERAL, It really depends on your query, your data, etc. 在一般情况下,它实际上取决于您的查询,您的数据等。

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

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