镜像 MySQL 表的不好做法?
为了进行全文搜索而在 InnoDB 表中创建记录的镜像表 (MyISAM) 是一种不好的做法吗?我这样想,我只是搜索数据的副本,如果该数据发生任何事情,也没什么大不了的,因为它总是可以重新创建。但是,就是感觉很尴尬。
(MyISAM是唯一支持全文搜索的引擎,但我需要使用InnoDB提供的外键约束)
我应该避免这种情况吗?
Is it bad practice to create a mirrored table (MyISAM) of the records in an InnoDB table for the purposes of doing full-text searches? I figure this way I'm just searching a copy of the data and if anything happens to that data it's not as big of a deal because it can always be re-created. But, it just feels awkward.
(MyISAM is the only engine that supports full-text searching, but I need to use the foreign key constraints offered by InnoDB)
Should I avoid this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,您是否考虑过使用好的搜索索引器?例如 lucene : http://lucene.apache.org/java/docs/ 将由于它构建了自己的索引表,因此大大加快了搜索速度。
如果你确实想使用内置的 mysql 全文搜索,你可以削减 myisam 表,使其只包含你想要搜索的文本数据和主键 - 然后从普通的 innodb 表中检索正确的数据一次你知道pkey。这将避免表中其他数据的重复。
first of all, have you considered using a good search indexer? for example lucene : http://lucene.apache.org/java/docs/ will speed up searches a lot as it builds its own index tables.
if you definitely want to use the inbuilt mysql full-text search, you could cut down the myisam table so that it just contains the text data you want to search and the primary key - and then retrieve the proper data from the normal innodb tables once you know the pkey. that would avoid duplication of the other data in the table.