Jay Taylor's notes

back to listing index

mysql - Why remove django DATABASE_OPTIONS's "init_command set engine=INNODB" after table creation? - Stack Overflow

[web search]
Original source (stackoverflow.com)
Tags: stackoverflow.com
Clipped on: 2013-02-08

http://docs.djangoproject.com/en/1.0/ref/databases/#creating-your-tables says:

Another option is to use the init_command option for MySQLdb prior to creating your tables:

   "init_command": "SET storage_engine=INNODB",

This sets the default storage engine upon connecting to the database. After your tables have been created, you should remove this option.

Does anyone know why is it necessary to remove this option after table creation?

asked Aug 20 '09 at 1:33
Image (Asset 1/1) alt= 1087
add comment

4 Answers

up vote 1 down vote accepted

Typically permissions and settings are tree based. Your settings for the session will be a pointer to the default settings one level above yours. You session settings are going to be already created and just referencing the default settings when you first connect.

When you modify a setting, such as by setting the storage_engine value, you are either creating a new copy of all of the settings and changing one value (as in Apache) or adding another layer to the tree that it has to check in when resolving values. I am not actually sure which one MySQL uses, but either way, if you do not need this setting, you should not set it on every round trip.

If you do need it relatively frequently, it might be worth the performance hit. A similar issue occurs in PHP. You do not want to modify variables like the PHP include path in your PHP code, that used to add a ton of overhead.