在 MySQL 中存储非常大的整数

发布于 2024-07-29 23:38:41 字数 513 浏览 3 评论 0原文

我需要在 MySQL 表中存储大量(数千万)512 位 SHA-2 哈希值。 为了节省空间,我想以二进制形式存储它们,而不是十六进制数字的字符串。 我正在使用 ORM (DBix::Class)因此存储的具体细节将从代码中抽象出来,代码可以将它们膨胀为我选择的任何对象或结构。

MySQL 的 BIGINT 类型是 64 位。 因此,理论上我可以将哈希值分成八个 BIGINT 列。 但这似乎很荒谬。 我的另一个想法是只使用单个 BLOB 列,但我听说它们的访问速度可能很慢,因为 MySQL 将它们视为可变长度字段。

如果有人可以提供一些帮助我节省几个小时对各种方法进行基准测试的知识,我将不胜感激。

注意:对于任何说“只使用 postgres!”的人,自动为 -1 :)

I need to store a very large number (tens of millions) of 512-bit SHA-2 hashes in a MySQL table. To save space, I'd like to store them in binary form, rather than a string a hex digits. I'm using an ORM (DBix::Class) so the specific details of the storage will be abstracted from the code, which can inflate them to any object or structure that I choose.

MySQL's BIGINT type is 64 bits. So I could theoretically split the hash up amongst eight BIGINT columns. That seems pretty ridiculous though. My other thought was just using a single BLOB column, but I have heard that they can be slow to access due to MySQL's treating them as variable-length fields.

If anyone could offer some widsom that will save me a couple hours of benchmarking various methods, I'd appreciate it.

Note: Automatic -1 to anyone who says "just use postgres!" :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

谁把谁当真 2024-08-05 23:38:41

您考虑过“二进制(64)”吗? 请参阅 MySQL 二进制 类型。

Have you considered 'binary(64)' ? See MySQL binary type.

ㄟ。诗瑗 2024-08-05 23:38:41

使用类型 BINARY(64) ?

Use the type BINARY(64) ?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文