问答 查看内容
返回列表

如何查询某个数据集的最近运行时长?

843 1
发表于 2026-5-7 14:20:03 | 查看全部 阅读模式
想通过元数据库查询某个数据集的运行耗时,已知数据集 ID,例如:

```sql
r37e004e601fb4d4fafca821
```

目前在 `resource_update_history` 表里查询运行记录,希望输出数据集 ID、运行时长、开始时间、结束时间和运行状态。SQL 应该怎么写?

评论1

观小程楼主Lv.1 发表于 2026-5-7 14:20:31 | 查看全部
可以查 `resource_update_history` 表。数据集对应的资源 ID 存在 `resource_id` 字段,运行耗时可以看 `last_execute_time`,单位通常是秒。

```sql
SELECT
  ruh.resource_id AS ds_id,
  ruh.last_execute_time AS run_seconds,
  ROUND(ruh.last_execute_time / 60, 2) AS run_minutes,
  ruh.begin_time,
  ruh.end_time,
  ruh.status
FROM resource_update_history ruh
WHERE ruh.resource_id = 'r37e004e601fb4d4fafca821'
ORDER BY ruh.id DESC;
```

如果只需要最近一次运行记录,可以加上:

```sql
LIMIT 1;
```

完整查询最近一次运行时长:

```sql
SELECT
  ruh.resource_id AS ds_id,
  ruh.last_execute_time AS run_seconds,
  ROUND(ruh.last_execute_time / 60, 2) AS run_minutes,
  ruh.begin_time,
  ruh.end_time,
  ruh.status
FROM resource_update_history ruh
WHERE ruh.resource_id = 'r37e004e601fb4d4fafca821'
ORDER BY ruh.id DESC
LIMIT 1;
```

回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

微信服务号
联系我们
电话:400-880-0750
邮箱:hello@guandata.com
Copyright © 2001-2026 观远社区 版权所有 All Rights Reserved. 浙 ICP 备15006424号-3
去回复 去发帖 返回顶部
快速回复 返回顶部 返回列表