简体   繁体   English

MYSQL innodb还是myisam? 哪一个最适合这种情况?

[英]MYSQL innodb or myisam? Which one is best for this case?

I'm really lost on which type of database engine should I pick for my table. 我真的迷失在我应该为我的桌子挑选哪种类型的数据库引擎。

+-----------------------+
| id | userid | content |
+-----------------------+

Imagine this table. 想象一下这张桌子。 userid is holding user ids which are stored in another table. userid正在保存存储在另一个表中的用户ID。 Also, some other tables are using the id field of this table. 此外,其他一些表正在使用此表的id字段。 Therefore, I thought that setting id as primary key and userid as a foreign key would speed up the join processes. 因此,我认为将id设置为主键,将userid设置为外键将加速连接过程。 However, if I select my table as InnoDB to set foreign keys, then I cannot conduct a FULLTEXT search on content (which is a TEXT field). 但是,如果我选择我的表作为InnoDB来设置外键,那么我就无法对内容(这是一个TEXT字段)进行FULLTEXT搜索。

So basically, if I switch back to MyISAM to use the FULLTEXT searches, will I have problems when joining, say, 3-4 tables of hundreds of millions of rows? 所以基本上,如果我切换回MyISAM来使用FULLTEXT搜索,那么加入时会有问题吗,比如3-4个数十亿行的表?

PS: If there is another liable way to create tables to handle both joins and fulltexts, please tell me so, I can change the tables structure as well. PS:如果还有另一种可行的方法来创建表来处理连接和全文,请告诉我,我也可以更改表结构。

Take a look at the answer for this question: Fulltext Search with InnoDB 看一下这个问题的答案: 使用InnoDB进行全文搜索

In short, MyISAM locks an entire table when you write to it, so that will be bad for performance when you have a lot of writes to the table. 简而言之,MyISAM在您写入时会锁定整个表,因此当您对表进行大量写操作时,这将对性能造成不利影响。 The solution is to go for the InnoDB tables for the referential integrity, and use a dedicated search engine for the indexing/searchfing of the content (for example Lucene). 解决方案是使用InnoDB表来获取参照完整性,并使用专用搜索引擎来索引/搜索内容(例如Lucene)。

InnoDB scales better than MyISAM. InnoDB比MyISAM更好地扩展。 If you're talking about hundreds of millions of row then go for InnoDB and adapt a search engine. 如果您正在谈论数亿行,那么请转到InnoDB并调整搜索引擎。 AFAIK, FULLTEXT becomes really slow after a certain point. AFAIK,FULLTEXT在某一点之后变得非常缓慢。 Therefore, go for InnoDB + a search engine of your choice. 因此,请选择InnoDB +搜索引擎。

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

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