Database Manual / Data Modeling / Schema Design Patterns

Group Data分组数据

If your schema contains a large series of data, grouping that data into multiple smaller series can improve performance.如果模式包含大量数据,将这些数据分组到多个较小的系列中可以提高性能。

Your schema may also need to handle outliers in a series that cause poor performance for more common data values. 模式可能还需要处理一系列异常值,这些异常值会导致更常见的数据值性能不佳。To improve performance and organization for groups of data, you can use the bucket and outlier patterns.为了提高数据组的性能和组织,您可以使用离群值模式。

Use Cases用例

Scenario场景Design Pattern Application设计模式应用
Your database stores a large array of product reviews, and your application paginates reviews in groups of 10.数据inventory储了大量的产品评论,应用程序以10个为一组对评论进行分页。Use the bucket pattern to group product reviews and handle pagination on the server. 使用桶模式对产品评论进行分组,并在服务器上处理分页。This approach reduces the application workload and simplifies pagination logic.这种方法减少了应用程序的工作量,简化了分页逻辑。
Your database stores reviews for books. A new, popular book receives many more reviews than other books in the collection.数据inventory储书籍的评论。一本新的、受欢迎的书收到的评论比集合中的其他书多得多。Use the outlier pattern to separate the popular book's reviews into separate documents. 使用离群模式将流行书籍的评论分成单独的文档。With this approach, you do not have one large document that disrupts data retrieval for smaller, more typical sized documents.使用这种方法,您不会有一个大型文档会干扰较小、更典型大小的文档的数据检索。

Tip

Time series collections apply the bucket pattern automatically, and are suitable for most use cases of the bucket pattern.时间序列集合自动应用桶模式,适用于桶模式的大多数用例。

Get Started开始使用

To learn how to apply design patterns to group data, see these pages:要了解如何将设计模式应用于分组数据,请参阅以下页面:

Learn More了解更多