开发者

pitfalls with mixing storage engines in mysql with django?

开发者 https://www.devze.com 2023-02-16 20:43 出处:网络
I\'m running a django system over mysql in amazon\'s cloud, and the database default is innodb. But now I want to put a fulltext index on a couple of tables for searching, which evidently requires myi

I'm running a django system over mysql in amazon's cloud, and the database default is innodb. But now I want to put a fulltext index on a couple of tables for searching, which evidently requires myisam.

The obvious solution is to just tell mysql to ALTER TABLE to myisam, but are there going to be any issues with that?

One that comes to mind is that I'll have to remember to do that any time I build a new version of the database, which should theoretically be rare, but there doesn't seem to be a w开发者_如何学Pythonay to tell django to please set the storage engine at the table level. I guess I could write a migration (we use south).

Any other things I might be missing? What could possibly go wrong?


Will the application notice? Probably not.

Will it cause problems? Only when things go wrong. MyISAM is not a transactional storage engine. If you change the data in a MyISAM table while inside of a transaction, then have to roll back changes, the changes in that table won't be rolled back. 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.

You should seriously consider external search software instead of a fulltext index, like ElasticSearch (integrates at the application level), or Sphinx (integrates at the MySQL level, though if you're using RDS instead of MySQL directly, I don't think you'll be able to use it).


the following may be of help:

use a myisam fulltext table to index back into your innodb tables for example: Build your system using innodb:...

Any way to achieve fulltext-like search on InnoDB

0

精彩评论

暂无评论...
验证码 换一张
取 消