简体   繁体   English

将MyISAM和InnoDB表与Doctrine混合

[英]Mixing MyISAM and InnoDB tables with Doctrine

I am currently trying to optimize a search function in our website. 我目前正在尝试优化我们网站上的搜索功能。 We are using doctrine as our ORM and all tables are currently InnoDB. 我们使用主义作为ORM,并且所有表当前都是InnoDB。 Below is a rough outline of our table structure. 下面是我们表结构的粗略概述。

Table: Person
Columns:
  personId
  firstName
  middleName
  lastName

Table: Obituary
  obitId
  content  <--- LONG TEXT
  personId

There is a one to many relationship from Person to Obituary. 人与Ob告之间存在一对多的关系。

Currently a user can enter a person's name, our site will search for the occurrence of the search text in the person table (first name, last name, middle name etc.) as well as the content of the obituary. 当前用户可以输入一个人的名字,我们的网站将在人表中搜索出现的搜索文本(名字,姓氏,中间名等)以及the告的内容。

Now, this search is slow because the content column of the obituary table is Long text. 现在,此搜索很慢,因为itu告表的内容列是长文本。 Switching this to MyISAM from InnoDB increases performance greatly. 从InnoDB切换到MyISAM可以大大提高性能。 Currently any changes in Person cascade to Obituary as well. 目前,“人”的任何更改也将级联为“ itu告”。 Right now any updates occur on an hourly bases, so writing is not nearly as common as searching. 现在,任何更新都是按小时进行的,因此写作并不像搜索那样普遍。

My question is, if I switch the Obitary table to MyISAM, will this have any negative side affects with Doctrine when I save and update Person records? 我的问题是,如果我将Obitary表切换到MyISAM,那么在保存和更新Person记录时,这对教义会有负面影响吗?

Will Doctrine notice? 主义会注意吗? Probably not. 可能不是。

Will it cause problems? 会引起问题吗? Only when things go wrong. 只有当事情出错时。 MyISAM is not a transactional storage engine. MyISAM不是事务存储引擎。 If you change a MyISAM table while inside of a transaction, then have to roll back changes, they won't roll back in that table. 如果在事务内部更改MyISAM表,则必须回滚更改,这些更改将不会在该表中回滚。 It's been a while since I tried to break it horribly, but I'm willing to wager that MySQL won't even issue a warning when this happens. 自从我试图可怕地破解它已经有一段时间了,但是我敢打赌MySQL在这种情况发生时甚至不会发出警告。 This will lead to data consistency issues. 这将导致数据一致性问题。

If you control the server, you should seriously consider external search software to take the load off the database, like ElasticSearch (integrates at the application level), or Sphinx (integrates at the MySQL level). 如果控制服务器,则应认真考虑使用外部搜索软件来减轻数据库负担,例如ElasticSearch (在应用程序级别集成)或Sphinx (在MySQL级别集成)。

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

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