MYSQL innodb 还是 myisam?哪一个最适合这种情况?
我真的不知道应该为我的表选择哪种类型的数据库引擎。
+-----------------------+
| id | userid | content |
+-----------------------+
想象一下这张桌子。 userid 保存存储在另一个表中的用户 ID。另外,其他一些表正在使用该表的 id 字段。因此,我认为将 id 设置为主键,将 userid 设置为外键会加快加入过程。但是,如果我选择表作为 InnoDB 来设置外键,那么我无法对内容(这是一个文本字段)进行全文搜索。
所以基本上,如果我切换回 MyISAM 以使用 FULLTEXT 搜索,那么在连接(例如,数亿行的 3-4 个表)时会遇到问题吗?
PS:如果有另一种可靠的方法来创建表来处理连接和全文,请告诉我,我也可以更改表结构。
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. Also, some other tables are using the id field of this table. Therefore, I thought that setting id as primary key and userid as a foreign key would speed up the join processes. 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).
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?
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看看这个问题的答案: Fulltext Search with InnoDB
简而言之,MyISAM 锁定了一个写入时会写入整个表,因此当对表进行大量写入时,这会降低性能。解决方案是使用 InnoDB 表来实现引用完整性,并使用专用搜索引擎来对内容进行索引/搜索(例如 Lucene)。
Take a look at the answer for this question: Fulltext Search with 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. 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 的扩展性比 MyISAM 更好。如果你谈论的是数亿行,那么就选择 InnoDB 并适应搜索引擎。 AFAIK,全文在某个点之后变得非常慢。因此,选择 InnoDB + 您选择的搜索引擎。
InnoDB scales better than MyISAM. If you're talking about hundreds of millions of row then go for InnoDB and adapt a search engine. AFAIK, FULLTEXT becomes really slow after a certain point. Therefore, go for InnoDB + a search engine of your choice.