简体   繁体   English

Mysql搜索 - InnoDB和事务与MyISAM进行FULLTEXT搜索

[英]Mysql Search - InnoDB and transactions vs MyISAM for FULLTEXT search

I'm currently doing research on the best ways to provide an advanced search for my php project. 我目前正在研究为我的php项目提供高级搜索的最佳方法。

I have narrowed it down to using FULLTEXT search rather than using LIKE to find matching strings in a table row. 我已经缩小到使用FULLTEXT搜索而不是使用LIKE来查找表行中的匹配字符串。 However, to do this it appears I need to sacrifice using the InnoDB engine which will make me lose the ACIDity of transactions and table relationships. 然而,为了做到这一点,似乎我需要牺牲使用InnoDB引擎,这将使我失去交易和表关系的ACIDity。

Is it really worth using the MYISAM mysql engine or are there better ways of providing search functionality. 是否真的值得使用MYISAM mysql引擎,或者有更好的方法来提供搜索功能。

Any pointers would be appreciated! 任何指针将不胜感激!

It really depends on the application... Using MyISAM for anything that needs referential integrity is an instant fail. 这实际上取决于应用程序......使用MyISAM进行任何需要参照完整性的事情都是即时失败。 At the same time, it's text search isn't all that efficient. 与此同时,它的文本搜索是不是所有的效率。

Basically, there are two ways to go. 基本上,有两种方法可以去。 If you find you don't need true referential integrity, consider a NoSQL datastore. 如果您发现不需要真正的参照完整性,请考虑使用NoSQL数据存储。 MongoDB is a great document store database. MongoDB是一个很棒的文档存储数据库。

If, on the other hand, you really need referential integrity, but also need fast, indexed full-text searching, you might do better to use Sphinx or Apache Solr to create an indexed cache for full-text search. 另一方面,如果您确实需要参照完整性,但还需要快速索引的全文搜索,那么最好使用SphinxApache Solr为全文搜索创建索引缓存。

Either way, I consider MyISAM to be a legacy datastore. 不管怎样,我认为MyISAM是一个遗留数据存储区。 I wouldn't use it on a new project. 我不会在新项目中使用它。 YMMV. 因人而异。

MyISAM has several drawbacks - lack of transaction support, table-level locks which makes it very slow in heavy read+write load type. MyISAM有几个缺点 - 缺少事务支持,表级锁定使得它在繁重的读取和写入负载类型中非常慢。 Another inconvenience of MyISAM tables - they are not crash safe so you can lost some data in case of unexpected shutdown or power loss on server. MyISAM表的另一个不便之处 - 它们不是崩溃安全的,因此在服务器意外关闭或断电时可能会丢失一些数据。 However MyISAM is very fast on some queries. 然而,MyISAM在一些查询上非常快。

Regarding the FullText search I would suggest to use InnoDB + external search engine like Lucene or Sphinx so you could benefit from both safe and reliable storage engine and fast Full-text queries. 关于FullText搜索,我建议使用InnoDB +外部搜索引擎,如Lucene或Sphinx,这样您就可以从安全可靠的存储引擎和快速全文查询中受益。

For quick start with InnoDB and Sphinx you can refer to http://astellar.com/2011/12/replacing-mysql-full-text-search-with-sphinx/ 有关InnoDB和Sphinx的快速入门,请参阅http://astellar.com/2011/12/replacing-mysql-full-text-search-with-sphinx/

MySQL 5.6 supports FULLTEXT indexes with InnoDB (released Feb 2013). MySQL 5.6支持InnoDB的FULLTEXT索引(2013年2月发布)。 See: 看到:

http://dev.mysql.com/doc/refman/5.6/en/fulltext-search.html http://dev.mysql.com/doc/refman/5.6/en/fulltext-search.html

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

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