[英]No Of Queries Hitting Redshift tables in a Time Frame
How can I know the number of queries hitting a table in a particular time frame and what are those queries我如何知道在特定时间范围内命中表的查询数量以及这些查询是什么
Is it possible to get those stats for live tables hitting a redshift table?是否有可能获得实时表命中红移表的统计信息?
If by "hitting a table you mean scan then they system table stl_scan lists all the accesses to a table and lists the query number that causes this scan. By writing a query to aggregate the information in stl_scan you can look at it by time interval and/or originating query. If this isn't what you mean you will need to clarify.如果“命中表是指扫描,则系统表 stl_scan 会列出对表的所有访问并列出导致此扫描的查询编号。通过编写查询来聚合 stl_scan 中的信息,您可以按时间间隔和/或原始查询。如果这不是您的意思,您需要澄清。
I don't understand what is meant by 'stats for live tables hitting a redshift table?'.我不明白“实时表命中红移表的统计数据?”是什么意思。 What is meant by a table hitting a table?
桌子撞桌子是什么意思?
This will give you the number of queries hitting a redshift table in a certain time frame:这将为您提供在特定时间范围内命中红移表的查询数量:
SELECT
count(*)
FROM stl_wlm_query w
LEFT JOIN stl_query q
ON q.query = w.query
AND q.userid = w.userid
join pg_user u on u.usesysid = w.userid
-- Adjust your time frame accordignly
WHERE w.queue_start_time >= '2022-04-04 10:00:00.000000'
AND w.queue_start_time <= '2022-04-05 22:00:00.000000'
AND w.userid > 1
-- Set the table name here:
AND querytxt like '%my_main_table%';
If you need the actual queries text hitting the table in a certain timeframe, plus the queue and execution time and the user (remove if not needed):如果您需要在特定时间范围内访问表的实际查询文本,加上队列和执行时间以及用户(如果不需要则删除):
SELECT
u.usename,
q.querytxt,
w.queue_start_time,
w.total_queue_time / 1000000 AS queue_seconds,
w.total_exec_time / 1000000 exec_seconds
FROM stl_wlm_query w
LEFT JOIN stl_query q
ON q.query = w.query
AND q.userid = w.userid
join pg_user u on u.usesysid = w.userid
-- Adjust your time frame accordignly
WHERE w.queue_start_time >= '2022-04-04 10:00:00.000000'
AND w.queue_start_time <= '2022-04-05 22:00:00.000000'
AND w.userid > 1
-- Set the table name here:
AND querytxt like '%my_main_table%'
ORDER BY w.queue_start_time;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.