本文介绍了为什么要删除django DATABASE_OPTIONS的“init_command set engine = INNODB”表创建后?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

的文档说:

另一个选择是在创建表之前使用MySQLdb的init_command选项:

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

DATABASE_OPTIONS = {
   "init_command": "SET storage_engine=INNODB",
}



有没有人知道为什么在创建表后需要删除此选项?

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

推荐答案

通常,权限和设置是基于树的。您的会话设置将是一个指向默认设置的指针。您的会话设置将被创建,并且在首次连接时仅引用默认设置。

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.

当您修改设置(例如设置storage_engine值)时,您正在创建所有设置的新副本并更改一个值(如在Apache中)或者在树中添加另一个图层,以便在解析值时必须检入。我并不确定MySQL使用哪一个,但无论如何,如果您不需要此设置,则不应每次往返设置。

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.

如果你确实需要它比较频繁,那可能是值得的。在PHP中也会出现类似的问题。您不想修改PHP代码中的PHP包含路径的变量,这些变量用于添加大量开销。

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.

Jacob

这篇关于为什么要删除django DATABASE_OPTIONS的“init_command set engine = INNODB”表创建后?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 09:53