sql - 在 Redshift 中按总运行时间、执行时间、等待/排队时间列出排名靠前的查询?
问题描述
我知道亚马逊为 Redshift 提供了各种管理脚本,比如这个:
https://github.com/awslabs/amazon-redshift-utils/blob/master/src/AdminScripts/top_queries.sql
它按运行时列出了排名靠前的查询,我还发现这是类似的:
https://chartio.com/learn/amazon-redshift/identifying-slow-queries-in-redshift/
但是我想知道是否有一个类似于上述查询但除了执行时间之外还显示队列/等待时间的查询?
从这篇文章:
我收集到 stl_query 表包括执行时间 + 等待时间,但 stl_wlm_query 包括 total_exec_time,这只是执行时间。
更新:我有以下内容可以满足我的需求,但它似乎只返回最后一个月左右的数据,有什么想法可以获取旧数据吗?
SELECT
w.userid,
w.query,
w.service_class_start_time AS "Day",
w.total_queue_time / 60000000 AS "Total Queue Time Minutes",
w.total_exec_time / 60000000 AS "Total Exec Time Minutes",
w.total_queue_time / 60000000 + w.total_exec_time / 60000000 AS "Total Time Minutes"
FROM
stl_wlm_query w
ORDER BY
6 DESC
解决方案
该查询正在使用该stl_wlm_query
表。
来自用于日志记录的 STL 表 - Amazon Redshift:
为了管理磁盘空间,STL 日志表仅保留大约两到五天的日志历史记录,具体取决于日志使用情况和可用磁盘空间。如果要保留日志数据,则需要定期将其复制到其他表或将其卸载到 Amazon S3。
推荐阅读
- java - 如何修复netbeans中的getrowcount()?
- android-studio - RecylerView to pdf
- android - Xamarin.Android 谷歌地图导航模糊
- c# - 硒的 1 行中有 2 个发送键
- python - Python 逻辑不会增加太多时间复杂度
- django - ValueError:字典更新序列元素 #0 的长度为 25;使用字典解包元组时需要 2
- c# - 如何在 dot net 标准应用程序中使用 Dapper 从数据库中读取块中的文件
- iphone - 在 SwiftUI 中,如何使用核心数据将触摸 ID 存储为人员/类的属性并记录它们?
- r - R - 自动排除 quantile_split 函数
- c# - 如何将文件转换为base 64