Srikar Appalaraju
Srikar Appalaraju

Reputation: 73588

Django Models, tables in InnoDB

In order to get Django to output innodb tables in MySQL, you either need to

  1. output ALL tables as innodb or
  2. selectively issue alter table commands

The first is sub-optimal (MyISAM is faster for query-dominant tables) and the second is a pain and hack-ish.

Are there any other ways?

UPDATE: Adding more clarity to my question - I want my models (or tables) that Django creates initially (using syncdb) to be using INNODB engine (not MyISAM). In my database, I'll be having some tables in InnoDB & some in MyISAM. How can I do this in Django?

Upvotes: 3

Views: 1434

Answers (1)

payne
payne

Reputation: 14177

This page should be good starting point: http://code.djangoproject.com/wiki/AlterModelOnSyncDB

It documents a way to hook into the post_syncdb hook to dynamically issue ALTER SQL commands to change the engine for the tables. (Note that this was written 4 years ago, and may need to be updated to the current version of Django).

It should be straightforward for you to add metadata to your models, that specify which storage engine to use for each table. Then you can modify the above example to key off of that metadata.

Upvotes: 2

Related Questions