如何查看MongoDB中存储的时间序列数据的存储桶结构

huangapple go评论49阅读模式
英文:

How to see bucket structure that gets stored for the timeseries data in mongoDB

问题

我已经为天气数据创建了一个时间序列集合。

db.createCollection(
    "weather",
    {
       timeseries: {
          timeField: "timestamp",
          metaField: "metadata",
          granularity: "hours"
       }
    }
)

当我检索数据时,我得到了我存储的数据,但MongoDB以不同的方式存储这些数据。它基于metaFieldgranularity创建存储桶。

如何查看这些原始存储桶?

英文:

I have created a timeseries collection for weather data.

db.createCollection(
    "weather",
    {
       timeseries: {
          timeField: "timestamp",
          metaField: "metadata",
          granularity: "hours"
       }
    }
)

When I retrieve the data I get the data as I stored it, but mongoDB stores these data in different way. It creates buckets based on metaField and granularity.

How to see those original buckets?

答案1

得分: 1

MongoDB 将时间序列集合视为由内部集合支持的可写的非物化视图。

MongoDB 在使用 <database>.system.* 命名空间的集合中存储系统信息,MongoDB 保留该命名空间供内部使用。

system.buckets 存储与时间序列集合关联的底层数据,以一种经过优化的格式和模式存储,以有效表示已持久化的时间序列数据。

在您的情况下,它将是 system.buckets.weather 集合。

英文:

MongoDB treats time series collections as writable non-materialized views backed by an internal collection.

MongoDB stores system information in collections that use the <database>.system.* namespace, which MongoDB reserves for internal use.
system.buckets stores the underlying data associated to a time series collection in an optimized format and schema for an efficient representation of the persisted time series data.

In your case, it will be system.buckets.weather collection.

huangapple
  • 本文由 发表于 2023年2月16日 13:53:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/75468340.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定