使用分层数据结构对数据库进行分片

发布于 2024-08-13 07:38:18 字数 101 浏览 4 评论 0原文

我正在使用 MySQL 来存储我的父子关系。数据在一张表中。

我查询没有任何问题;然而,桌子的尺寸却急剧增大。我想分片或使用一些技术来提高查询(和连接)的性能。我该怎么做呢?

I am using MySQL to store my parent-child relation. The data is in one table.

I do not have any problem quering; however, the table has grown in size dramatically. I would like to shard or use some techniques to improve the performance of my queries (and joins). How would I do it?

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

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

发布评论

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

评论(3

全部不再 2024-08-20 07:38:18

这篇文章中没有足够的信息来给你一个好的答案。
我们首先需要知道的是表结构是什么。
您是否定义了非聚集索引,或者只是一个聚集索引。

您的应用程序使用此数据库,它对数据做什么?

此外,您是否正在搜索名称字段或特定日期?如果是这样,这些可能是索引类型的候选者。

不过,要注意的第一件事是索引

There is not enough information in this post to give you a good answer.
The first thing we would need to know is what the table structure is.
Do you have non-clustered indexes defined or is it simply one clustered index.

Your application that uses this database, what does it do with the data?

In addition, are you searching for say a name field, or a specific date? If so these could be candidates for an index type.

The number one thing to look after though is indexes.

溺ぐ爱和你が 2024-08-20 07:38:18

最好使用专业的分片中间件,例如: Apache ShardingSphere

可以用简单的方式对数据库进行分片,通过 SQL 路由和重写表,无需跨数据库连接。
它可以使用复杂的方式处理联合查询的跨数据库连接
由阿帕奇方解石提供动力。

It is better to use professional sharding middleware, for example: Apache ShardingSphere

It can use simple way to shard databases and tables by SQL route and rewrite without join cross databases.
It can use complex way to handle join cross databases with federation query
powered by Apache Calcite.

沉默的熊 2024-08-20 07:38:18

我认为如果您的产品发展到那么大,您将需要更高级的帮助。 dbShards 是一个很好的起点。他们将帮助您为数据设计分片策略,并且可以轻松地对任何需要它的表进行分片。如果您的一张表变得太大,那么分片是一个不错的选择。我会检查 dbShards。对于这种情况可能会很有效。

I think you will need more advanced help if your product is growing that large. dbShards is a good place to start. They will help you design a sharding strategy for your data and can easily shard any tables that need it. If your one table is getting too large, sharding is not a bad choice. I would check out dbShards. Might work well for this situation.

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