<legend id='9XJ3X'><style id='9XJ3X'><dir id='9XJ3X'><q id='9XJ3X'></q></dir></style></legend>
        <bdo id='9XJ3X'></bdo><ul id='9XJ3X'></ul>
    1. <tfoot id='9XJ3X'></tfoot>

    2. <small id='9XJ3X'></small><noframes id='9XJ3X'>

      <i id='9XJ3X'><tr id='9XJ3X'><dt id='9XJ3X'><q id='9XJ3X'><span id='9XJ3X'><b id='9XJ3X'><form id='9XJ3X'><ins id='9XJ3X'></ins><ul id='9XJ3X'></ul><sub id='9XJ3X'></sub></form><legend id='9XJ3X'></legend><bdo id='9XJ3X'><pre id='9XJ3X'><center id='9XJ3X'></center></pre></bdo></b><th id='9XJ3X'></th></span></q></dt></tr></i><div id='9XJ3X'><tfoot id='9XJ3X'></tfoot><dl id='9XJ3X'><fieldset id='9XJ3X'></fieldset></dl></div>

      我应该为 MySQL 数据库使用 MyISAM 还是 InnoDB 表?

      Should I use MyISAM or InnoDB Tables for my MySQL Database?(我应该为 MySQL 数据库使用 MyISAM 还是 InnoDB 表?)

          <tbody id='uSt1u'></tbody>

      1. <tfoot id='uSt1u'></tfoot>
      2. <small id='uSt1u'></small><noframes id='uSt1u'>

        1. <legend id='uSt1u'><style id='uSt1u'><dir id='uSt1u'><q id='uSt1u'></q></dir></style></legend>

            <bdo id='uSt1u'></bdo><ul id='uSt1u'></ul>
              • <i id='uSt1u'><tr id='uSt1u'><dt id='uSt1u'><q id='uSt1u'><span id='uSt1u'><b id='uSt1u'><form id='uSt1u'><ins id='uSt1u'></ins><ul id='uSt1u'></ul><sub id='uSt1u'></sub></form><legend id='uSt1u'></legend><bdo id='uSt1u'><pre id='uSt1u'><center id='uSt1u'></center></pre></bdo></b><th id='uSt1u'></th></span></q></dt></tr></i><div id='uSt1u'><tfoot id='uSt1u'></tfoot><dl id='uSt1u'><fieldset id='uSt1u'></fieldset></dl></div>
              • 本文介绍了我应该为 MySQL 数据库使用 MyISAM 还是 InnoDB 表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我的数据库中有以下两个表(索引完整,因为它将基于我使用的引擎):

                I have the following two tables in my database (the indexing is not complete as it will be based on which engine I use):

                表 1:

                CREATE TABLE `primary_images` (
                  `imgId` smallint(6) unsigned NOT NULL AUTO_INCREMENT,
                  `imgTitle` varchar(255) DEFAULT NULL,
                  `view` varchar(45) DEFAULT NULL,
                  `secondary` enum('true','false') NOT NULL DEFAULT 'false',
                  `imgURL` varchar(255) DEFAULT NULL,
                  `imgWidth` smallint(6) DEFAULT NULL,
                  `imgHeight` smallint(6) DEFAULT NULL,
                  `imgDate` datetime DEFAULT NULL,
                  `imgClass` enum('jeans','t-shirts','shoes','dress_shirts') DEFAULT NULL,
                  `imgFamily` enum('boss','lacoste','tr') DEFAULT NULL,
                  `imgGender` enum('mens','womens') NOT NULL DEFAULT 'mens',
                  PRIMARY KEY (`imgId`),
                  UNIQUE KEY `imgDate` (`imgDate`)
                )
                

                表 2:

                CREATE TABLE `secondary_images` (
                  `imgId` smallint(6) unsigned NOT NULL AUTO_INCREMENT,
                  `primaryId` smallint(6) unsigned DEFAULT NULL,
                  `view` varchar(45) DEFAULT NULL,
                  `imgURL` varchar(255) DEFAULT NULL,
                  `imgWidth` smallint(6) DEFAULT NULL,
                  `imgHeight` smallint(6) DEFAULT NULL,
                  `imgDate` datetime DEFAULT NULL,
                  PRIMARY KEY (`imgId`),
                  UNIQUE KEY `imgDate` (`imgDate`)
                )
                

                表 1 将用于创建一个缩略图库,其中包含指向更大版本图像的链接.imgClassimgFamilyimgGender 将细化显示的缩略图.

                Table 1 will be used to create a thumbnail gallery with links to larger versions of the image. imgClass, imgFamily, and imgGender will refine the thumbnails that are shown.

                表 2 包含与表 1 中的图像相关的图像.因此使用 primaryId 将表 1 中的单个图像与表 2 中的一个或多个图像相关联. 这就是我想到使用InnoDB的Foreign Key能力的地方,但我也熟悉MyISAM中Indexes的能力.

                Table 2 contains images related to those in Table 1. Hence the use of primaryId to relate a single image in Table 1, with one or more images in Table 2. This is where I was thinking of using the Foreign Key ability of InnoDB, but I'm also familiar with the ability of Indexes in MyISAM to do the same.

                无需深入研究剩余字段,imgDate 用于对结果进行排序.

                Without delving too much into the remaining fields, imgDate is used to order the results.

                最后但并非最不重要的是,我应该提到这个数据库是只读.所有数据将由我输入.有人告诉我,如果数据库是只读的,它应该是 MyISAM,但我希望你能阐明在我的情况下会做什么.

                Last, but not least, I should mention that this database is READ ONLY. All data will be entered by me. I have been told that if a database is read only, it should be MyISAM, but I'm hoping you can shed some light on what you would do in my situation.

                推荐答案

                默认使用 InnoDB.

                在 MySQL 5.1 以后,你应该使用 InnoDB.在 MySQL 5.1 中,您应该启用 InnoDB 插件.在 MySQL 5.5 中,默认启用 InnoDB 插件,因此只需使用它.

                Always use InnoDB by default.

                In MySQL 5.1 later, you should use InnoDB. In MySQL 5.1, you should enable the InnoDB plugin. In MySQL 5.5, the InnoDB plugin is enabled by default so just use it.

                多年前的建议是 MyISAM 在许多情况下都更快.但如果您使用当前版本的 MySQL,则情况不再如此.

                The advice years ago was that MyISAM was faster in many scenarios. But that is no longer true if you use a current version of MySQL.

                可能存在一些奇特的极端情况,其中 MyISAM 对于某些工作负载(例如表扫描或高容量 INSERT-only 工作)的表现略好,但默认选择应该是 InnoDB,除非您可以证明em> 你有一个例子,MyISAM 做得更好.

                There may be some exotic corner cases where MyISAM performs marginally better for certain workloads (e.g. table-scans, or high-volume INSERT-only work), but the default choice should be InnoDB unless you can prove you have a case that MyISAM does better.

                InnoDB 的优点除了通常提到的对事务和外键的支持还包括:

                Advantages of InnoDB besides the support for transactions and foreign keys that is usually mentioned include:

                • InnoDB 比 MyISAM 更能抵抗表损坏.
                • 行级锁定.在 MyISAM 中,读取器会阻止写入器,反之亦然.
                • 支持数据和索引的大型缓冲池.MyISAM 密钥缓冲区仅用于索引.
                • MyISAM 停滞不前;所有未来的开发都将在 InnoDB 中进行.

                另见我对MyISAM 与 InnoDB 的回答

                这篇关于我应该为 MySQL 数据库使用 MyISAM 还是 InnoDB 表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Import CSV to Update rows in table(导入 CSV 以更新表中的行)
                Importing MaxMind#39;s GeoLite2 to MySQL(将 MaxMind 的 GeoLite2 导入 MySQL)
                How to save a Google maps overlay shape in the database?(如何在数据库中保存谷歌地图叠加形状?)
                Is there a performance hit using decimal data types (MySQL / Postgres)(使用十进制数据类型(MySQL/Postgres)是否会影响性能)
                MySQL truncates concatenated result of a GROUP_CONCAT function(MySQL 截断 GROUP_CONCAT 函数的连接结果)
                How to reduce size of SQL Server table that grew from a datatype change(如何减少因数据类型更改而增长的 SQL Server 表的大小)

                <small id='xxrNS'></small><noframes id='xxrNS'>

                      <tbody id='xxrNS'></tbody>
                      <bdo id='xxrNS'></bdo><ul id='xxrNS'></ul>
                      <i id='xxrNS'><tr id='xxrNS'><dt id='xxrNS'><q id='xxrNS'><span id='xxrNS'><b id='xxrNS'><form id='xxrNS'><ins id='xxrNS'></ins><ul id='xxrNS'></ul><sub id='xxrNS'></sub></form><legend id='xxrNS'></legend><bdo id='xxrNS'><pre id='xxrNS'><center id='xxrNS'></center></pre></bdo></b><th id='xxrNS'></th></span></q></dt></tr></i><div id='xxrNS'><tfoot id='xxrNS'></tfoot><dl id='xxrNS'><fieldset id='xxrNS'></fieldset></dl></div>

                      <tfoot id='xxrNS'></tfoot>
                        • <legend id='xxrNS'><style id='xxrNS'><dir id='xxrNS'><q id='xxrNS'></q></dir></style></legend>