简体   繁体   English

为什么在Joomla 3.0.1安装sql脚本中使用ENGINE = InnoDB?

[英]Why in Joomla 3.0.1 installation sql script ENGINE=InnoDB is used?

Can someone please explain why in Joomla! 请有人在Joomla解释原因! 3.0.1 installation sql script for MySQL is used ENGINE=InnoDB !?! 3.0.1安装用于MySQL的sql脚本是使用ENGINE = InnoDB !?! Is there a particular reason !??!? 有什么特别的原因!??!?

The 2 major types of table storage engines for MySQL databases are InnoDB and MyISAM. MySQL数据库的两种主要类型的表存储引擎是InnoDB和MyISAM。 To summarize the differences of features and performance, 总结一下功能和性能的差异,

  1. InnoDB is newer while MyISAM is older. InnoDB较新,而MyISAM较旧。

  2. InnoDB is more complex while MyISAM is simpler. InnoDB更复杂,而MyISAM更简单。

  3. InnoDB is more strict in data integrity while MyISAM is loose. InnoDB在数据完整性方面更加严格,而MyISAM则是松散的。

  4. InnoDB implements row-level lock for inserting and updating while MyISAM implements table-level lock. 当MyISAM实现表级锁时,InnoDB实现了用于插入和更新的行级锁。

  5. InnoDB has transactions while MyISAM does not. InnoDB有交易,而MyISAM没有。

  6. InnoDB has foreign keys and relationship contraints while MyISAM does not. InnoDB有外键和关系约束,而MyISAM没有。

  7. InnoDB has better crash recovery while MyISAM is poor at recovering data integrity at system crashes. InnoDB具有更好的崩溃恢复能力,而MyISAM在恢复系统崩溃时的数据完整性方面表现不佳。

  8. MyISAM has full-text search index while InnoDB has not. MyISAM有全文搜索索引,而InnoDB没有。

    In light of these differences, InnoDB and MyISAM have their unique advantages and disadvantages against each other. 鉴于这些差异,InnoDB和MyISAM各有其优点和缺点。 They each are more suitable in some scenarios than the other. 它们在某些情况下比在另一种情况下更适合。

Advantages of InnoDB InnoDB的优点

InnoDB should be used where data integrity comes a priority because it inherently takes care of them by the help of relationship constraints and transactions. InnoDB应该用于数据完整性优先的地方,因为它通过关系约束和事务的帮助固有地处理它们。

Faster in write-intensive (inserts, updates) tables because it utilizes row-level locking and only hold up changes to the same row that's being inserted or updated. 写入密集型(插入,更新)表更快,因为它使用行级锁定,只保留对正在插入或更新的同一行的更改。

Disadvantages of InnoDB InnoDB的缺点

Because InnoDB has to take care of the different relationships between tables, database administrator and scheme creators have to take more time in designing the data models which are more complex than those of MyISAM. 由于InnoDB必须处理表之间的不同关系,因此数据库管理员和方案创建者必须花费更多时间来设计比MyISAM更复杂的数据模型。

Consumes more system resources such as RAM. 消耗更多的系统资源,如RAM。 As a matter of fact, it is recommended by many that InnoDB engine be turned off if there's no substantial need for it after installation of MySQL. 事实上,许多人都建议,如果在安装MySQL之后没有实际需要,可以关闭InnoDB引擎。

No full-text indexing. 没有全文索引。

Advantages of MyISAM MyISAM的优点

Simpler to design and create, thus better for beginners. 设计和创建更简单,因此对初学者更好。 No worries about the foreign relationships between tables. 不用担心表之间的外来关系。

Faster than InnoDB on the whole as a result of the simpler structure thus much less costs of server resources. 由于结构更简单,整体上比InnoDB更快,因此服务器资源的成本更低。

Full-text indexing. 全文索引。

Especially good for read-intensive (select) tables. 特别适合读取密集型(选择)表。

Disadvantages of MyISAM MyISAM的缺点

No data integrity (eg relationship constraints) check, which then comes a responsibility and overhead of the database administrators and application developers. 没有数据完整性(例如关系约束)检查,这就是数据库管理员和应用程序开发人员的责任和开销。

Doesn't support transactions which is essential in critical data applications such as that of banking. 不支持在关键数据应用程序(如银行业务)中必不可少的事务。

Slower than InnoDB for tables that are frequently being inserted to or updated, because the entire table is locked for any insert or update. 对于经常插入或更新的表,InnoDB比InnoDB慢,因为整个表都被锁定以进行任何插入或更新。

The comparison is pretty straightforward. 比较非常简单。

InnoDB is more suitable for data critical situations that require frequent inserts and updates. InnoDB更适合需要频繁插入和更新的数据关键情况。

MyISAM, on the other hand, performs better with applications that don't quite depend on the data integrity and mostly just select and display the data. 另一方面,MyISAM在不完全依赖于数据完整性的应用程序中表现更好,而且大多只是选择和显示数据。

Read more 阅读更多

Considering the fact that they aren't using any foreign key constraints it's actually a really good question. 考虑到他们没有使用任何外键约束,这实际上是一个非常好的问题。

Since they are not using foreign constraints themselves there are a couple of reasons that come to my mind why they might use InnoDB over MyISAM which are: 由于他们自己没有使用外部约束,因此我想到了为什么他们可能会使用InnoDB而不是MyISAM的几个原因:

  1. They have some future plans to stricten data integrity at some point in time. 他们有一些未来计划在某个时间点严格控制数据完整性。

  2. They want to allow people who write extensions for Joomla to refer to existing data and make hard constraints if that's what the creator desires. 他们希望允许为Joomla编写扩展的人引用现有数据并制定硬约束,如果这是创建者所希望的。 IE: Let's imagine a component that stores notes for users in Joomla system. IE:让我们想象一个为Joomla系统中的用户存储笔记的组件。 An author could then create a table like so: 然后,作者可以创建一个如下表格:

     CREATE TABLE IF NOT EXISTS `#__notes` ( `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, `note` VARCHAR(255) NOT NULL, `owner` INT(11) NOT NULL, PRIMARY KEY (`id`), INDEX (`owner`), CONSTRAINT FOREIGN KEY (`owner`) REFERENCES `#__users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 

    then the author could be sure that an owner for the notes actually exists and he won't have any garbage leftover in case a user is removed from the system as all the notes that belongs to a certain user would be removed as well due to set CASCADE on delete action which is very convenient if you don't want to maintain clean database manually which would not be possible if databases you would want to refer to would use different engine, namely MyISAM. 然后作者可以确定笔记的所有者实际存在,并且如果用户从系统中删除,他将不会有任何垃圾剩余,因为属于特定用户的所有笔记也将被删除关于删除操作的CASCADE,如果您不想手动维护干净的数据库,这是非常方便的,如果您想要引用的数据库使用不同的引擎,即MyISAM,这是不可能的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM