如何查看 MemSQL 或 MySQL 中的所有查询?

How to view all queries in MemSQL or MySQL?

如何查看 MemSQL database/cluster 或 MySQL 中所有查询的 list/history,包括已完成和正在进行的 运行 查询?我想查看任何查询的状态,例如它是否已完成、是否为 运行 或是否已中止。有没有我可以 运行 查看的查询?谢谢。

MemSQL 有 information_schema 个视图来获取有关 运行ning 和 completed/failed 查询的信息。看看https://docs.memsql.com/concepts/v6.0/workload-profiling/

例如,以下查询将显示过去 10 分钟内 运行 的所有查询: select query_text,success_count,failure_count from information_schema.mv_activities_cumulative join information_schema.mv_queries using (activity_name) where last_finished_timestamp > now() - interval '10' minute;

您还可以使用这些视图来更深入地了解查询的资源使用情况。

根据关于 Management View Reference 的官方 memsql 文档,他们说 "mv_activities determines recent resource use by computing the change in mv_activities_cumulative over an interval of time. This interval is controlled by the value of the activities_delta_sleep_s session variable."

所以如果我正确阅读了文档,类似这样的事情应该在执行时将变量 activities_delta_sleep_s 设置为 30 秒,然后当查询为 运行 时,您将看到所有数据库活动都在减少 cpu 次。我的问题是我似乎没有看到我执行的所有活动,而且很多查询文本都是空白的。根据 memsql forums 的 activities_delta_sleep_s 表示变量 simple 使所有管理视图调用在返回结果之前在此可变时间段内休眠。我认为这个想法是,这将允许节点和网络流量中的活动聚合。

#set the lookback period desired
set activities_delta_sleep_s = 30;

#This query is supposed to show resource costs of server activities, but not sure how to ID specific queries.
SELECT * #look at QUERY_TEXT
from information_schema.MV_ACTIVITIES a
LEFT JOIN information_schema.mv_queries q ON a.ACTIVITY_NAME = q.ACTIVITY_NAME
order by 4 DESC;