Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force django to create tables using MYISAM storage engine

How to force django to use MYISAM storage engine when creating database using syncdb command? This page does not help much to shed light in this issue.

MYISAM is the perfect choice since the database is almost only used for reading and MYISAM is significantly faster that InnoDB. There are still some models.ForeignKey fields in the model, but they are only being used to create master detail admin pages. There is not need of having the actual foreign keys in the database.

like image 509
bman Avatar asked Dec 16 '14 03:12

bman


1 Answers

See this page. Using an OPTIONS variable in your DATABASES setting should do the trick, but migrating an existing database to a new engine isn't so easy (think you'd have to re-initialize).

DATABASES = { 
  'default': {
    'ENGINE': 'django.db.backends.mysql',
    'NAME': '',                      
    'USER': '',     
    'PASSWORD': '',
    'OPTIONS': {
           "init_command": "SET storage_engine=MYISAM",
    }   
  }   
}
like image 158
Ian Price Avatar answered Nov 08 '22 07:11

Ian Price