如何对范围进行非规范化并将其存储在数据仓库中?

发布于 2024-08-16 22:47:41 字数 178 浏览 2 评论 0原文

我的自定义 Web 服务器以挂钟时间戳(会话开始)和会话持续的挂钟秒数的形式报告会话信息。

我想将此信息存储在数据仓库(MySQL + 启动模式)中,这样我就可以查询特定实体在特定时间的会话数。要求是我们必须能够提取将输入到图表中的时间序列数据。

除了在会话的每一绝对秒插入一行之外,还有其他方法来存储数据吗?

My custom web servers report session information in the form of a wall clock timestamp (start of session) and the number of wall click seconds the session lasted.

I want to store this information in a data warehouse (MySQL + start schema) in a way that will allow me to for example query the number of sessions for a particular entity at a specific time. A requirement is that we must be able to extract time series data that will be feed to a graph.

Is there any other way to store the data than to insert a row for every absolute second of the session?

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

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

发布评论

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

评论(1

甜柠檬 2024-08-23 22:47:41

我想说,最简单的方法是在事实表中使用 StartTime、EndTime 为每个会话存储一行。

假设我们有 factSession

  ( 
   ...
  ,SessionID int
  ,StartTime datetime
  ,EndTime datetime
  ,EntityID int
   ...
  ) ;

并且

TimeSeries TABLE ( TimePoint datetime ) ;

您可以:

SELECT  t.TimePoint
       ,f.EntityID
       ,COUNT(f.SessionID) AS cnt
FROM    TimeSeries AS t
        LEFT JOIN factSessions AS f ON ( f.StartTime <= t.TimePoint
                                          AND t.TimePoint <= f.EndTime
                                        )
GROUP BY t.TimePoint ,f.EntityID
ORDER BY t.TimePoint

I would say that the simplest way is to store one row per session with StartTime, EndTime in the fact table.

Let's say we have factSession with:

  ( 
   ...
  ,SessionID int
  ,StartTime datetime
  ,EndTime datetime
  ,EntityID int
   ...
  ) ;

and

TimeSeries TABLE ( TimePoint datetime ) ;

You can:

SELECT  t.TimePoint
       ,f.EntityID
       ,COUNT(f.SessionID) AS cnt
FROM    TimeSeries AS t
        LEFT JOIN factSessions AS f ON ( f.StartTime <= t.TimePoint
                                          AND t.TimePoint <= f.EndTime
                                        )
GROUP BY t.TimePoint ,f.EntityID
ORDER BY t.TimePoint
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文