简体   繁体   中英

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. 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.

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.

Now, this search is slow because the content column of the obituary table is Long text. Switching this to MyISAM from InnoDB increases performance greatly. Currently any changes in Person cascade to Obituary as well. 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?

Will Doctrine notice? Probably not.

Will it cause problems? Only when things go wrong. MyISAM is not a transactional storage engine. 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. 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. 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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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