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

  • <small id='Va7O9'></small><noframes id='Va7O9'>

    <tfoot id='Va7O9'></tfoot>

      <bdo id='Va7O9'></bdo><ul id='Va7O9'></ul>

        MySQL中的UUID性能?

        时间:2023-05-23

          <bdo id='HRkbR'></bdo><ul id='HRkbR'></ul>

                    <tbody id='HRkbR'></tbody>
                • <small id='HRkbR'></small><noframes id='HRkbR'>

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

                  本文介绍了MySQL中的UUID性能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我们正在考虑使用 UUID 值作为 MySQL 数据库的主键.插入的数据是从数十、数百甚至数千台远程计算机生成的,并且以每秒 100-40,000 次插入的速度插入,我们永远不会进行任何更新.

                  We're considering using UUID values as primary keys for our MySQL database. The data being inserted is generated from dozens, hundreds, or even thousands of remote computers and being inserted at a rate of 100-40,000 inserts per second, and we'll never do any updates.

                  在我们开始剔除数据之前,数据库本身通常会达到大约 5000 万条记录,因此不是一个庞大的数据库,但也不是很小.我们还计划在 InnoDB 上运行,但如果有更好的引擎来支持我们的工作,我们愿意改变这种情况.

                  The database itself will typically get to around 50M records before we start to cull data, so not a massive database, but not tiny either. We're also planing to run on InnoDB, though we are open to changing that if there is a better engine for what we're doing.

                  我们已准备好使用 Java 的 Type 4 UUID,但在测试中发现了一些奇怪的行为.一方面,我们存储为 varchar(36),我现在意识到我们最好使用 binary(16) - 尽管我不确定有多好.

                  We were ready to go with Java's Type 4 UUID, but in testing have been seeing some strange behavior. For one, we're storing as varchar(36) and I now realize we'd be better off using binary(16) - though how much better off I'm not sure.

                  更大的问题是:当我们有 50M 记录时,这些随机数据对索引的影响有多严重?例如,如果我们使用最左边的位带有时间戳的类型 1 UUID,我们会不会更好?或者我们应该完全放弃 UUID 并考虑使用 auto_increment 主键?

                  The bigger question is: how badly does this random data screw up the index when we have 50M records? Would we be better off if we used, for example, a type-1 UUID where the leftmost bits were timestamped? Or maybe we should ditch UUIDs entirely and consider auto_increment primary keys?

                  我正在寻找有关将不同类型的 UUID 存储为 MySQL 中的索引/主键时的性能的一般想法/提示.谢谢!

                  I'm looking for general thoughts/tips on the performance of different types of UUIDs when they are stored as an index/primary key in MySQL. Thanks!

                  推荐答案

                  UUID 是通用唯一 ID.这是您在这里应该考虑的通用部分.

                  A UUID is a Universally Unique ID. It's the universally part that you should be considering here.

                  真的需要 ID 是普遍唯一的吗?如果是这样,那么 UUID 可能是您唯一的选择.

                  Do you really need the IDs to be universally unique? If so, then UUIDs may be your only choice.

                  我强烈建议,如果您确实使用 UUID,请将它们存储为数字而不是字符串.如果你有 50M+ 的记录,那么节省的存储空间会提高你的性能(虽然我说不上多少).

                  I would strongly suggest that if you do use UUIDs, you store them as a number and not as a string. If you have 50M+ records, then the saving in storage space will improve your performance (although I couldn't say by how much).

                  如果您的 ID 不需要普遍唯一,那么我认为您不会比使用 auto_increment 做得更好,这保证 ID 在表中是唯一的(因为值每次都会增加)

                  If your IDs do not need to be universally unique, then I don't think that you can do much better then just using auto_increment, which guarantees that IDs will be unique within a table (since the value will increment each time)

                  这篇关于MySQL中的UUID性能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:MySQL 删除一些外键 下一篇:MySQL 根密码更改

                  相关文章

                  1. <i id='3akKS'><tr id='3akKS'><dt id='3akKS'><q id='3akKS'><span id='3akKS'><b id='3akKS'><form id='3akKS'><ins id='3akKS'></ins><ul id='3akKS'></ul><sub id='3akKS'></sub></form><legend id='3akKS'></legend><bdo id='3akKS'><pre id='3akKS'><center id='3akKS'></center></pre></bdo></b><th id='3akKS'></th></span></q></dt></tr></i><div id='3akKS'><tfoot id='3akKS'></tfoot><dl id='3akKS'><fieldset id='3akKS'></fieldset></dl></div>
                  2. <legend id='3akKS'><style id='3akKS'><dir id='3akKS'><q id='3akKS'></q></dir></style></legend>

                    <small id='3akKS'></small><noframes id='3akKS'>

                        <bdo id='3akKS'></bdo><ul id='3akKS'></ul>
                      <tfoot id='3akKS'></tfoot>