MySQL如何计算当前词条与江豚一号之间
MySQL how to calculate between the current entry and the porpoise one
我希望我的术语是正确的,但这里是
我需要计算条目之间传输的数据 (MB/s)。我有一个时间序列,其中包含发送和接收数据的时间戳和总和作为利用率。
enter image description here
Table 利用率有一个组件称为 'network'
Time utilisation
2021-11-19 11:14:13 291815568369
2021-11-19 11:14:53 291820740719
2021-11-19 11:15:33 291826081965
2021-11-19 11:16:13 291831134637
因此,为了获得准确的答案,我需要知道时间差异和利用率差异
利用率 = (291820740719 - 291815568369 ) / (11:14:53 -11:14:13)
得到上面的table我用过这个查询
SELECT
time AS "time",
utilisation
FROM hardware
WHERE
$__unixEpochFilter(time) AND
component = 'network'
ORDER BY time
如果您的目标是计算每 2 个连续行之间的公式,我会使用游标使用存储过程来完成(您可以在此处阅读相关信息:
https://dev.mysql.com/doc/refman/8.0/en/cursors.html
然后在循环中,每次在新获取的行和前一个行之间进行计算(确保处理第一轮)
这似乎有效。目的是计算上行和下行的数据速率。
SELECT
time AS "time",
( utilisation - LAG(utilisation,1) OVER ( ORDER BY time) ) / ( time - LAG(time,1) OVER ( ORDER BY time) ) time_usage
FROM hardware
WHERE
$__unixEpochFilter(time) AND
component = 'network'
ORDER BY time
我希望我的术语是正确的,但这里是
我需要计算条目之间传输的数据 (MB/s)。我有一个时间序列,其中包含发送和接收数据的时间戳和总和作为利用率。
enter image description here
Table 利用率有一个组件称为 'network'
Time utilisation
2021-11-19 11:14:13 291815568369
2021-11-19 11:14:53 291820740719
2021-11-19 11:15:33 291826081965
2021-11-19 11:16:13 291831134637
因此,为了获得准确的答案,我需要知道时间差异和利用率差异
利用率 = (291820740719 - 291815568369 ) / (11:14:53 -11:14:13)
得到上面的table我用过这个查询
SELECT
time AS "time",
utilisation
FROM hardware
WHERE
$__unixEpochFilter(time) AND
component = 'network'
ORDER BY time
如果您的目标是计算每 2 个连续行之间的公式,我会使用游标使用存储过程来完成(您可以在此处阅读相关信息: https://dev.mysql.com/doc/refman/8.0/en/cursors.html
然后在循环中,每次在新获取的行和前一个行之间进行计算(确保处理第一轮)
这似乎有效。目的是计算上行和下行的数据速率。
SELECT
time AS "time",
( utilisation - LAG(utilisation,1) OVER ( ORDER BY time) ) / ( time - LAG(time,1) OVER ( ORDER BY time) ) time_usage
FROM hardware
WHERE
$__unixEpochFilter(time) AND
component = 'network'
ORDER BY time