如何在 Vertica 中查询完成时显示查询时间?
使用 vsql 时,我想查看查询完成后运行需要多长时间。例如,当我运行:
select count(distinct key) from schema.table;
我想看到如下输出:
5678 (1 row) total query time: 55 seconds.
如果这是不可能的,是否有另一种方法来测量查询时间?
When using vsql, I would like to see how long a query took to run once it completes. For example when i run:
select count(distinct key) from schema.table;
I would like to see an output like:
5678 (1 row) total query time: 55 seconds.
If this is not possible, is there another way to measure query time?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在
vsql
中键入:,然后按 Enter 键。您会喜欢您所看到的:-)
重复此操作会将其关闭。
In
vsql
type:and then hit Enter. You'll like what you'll see :-)
Repeating that will turn it off.
关于你问题的另一部分:
Vertica 可以记录在集群上执行的所有查询的历史记录,这是查询时间的另一个来源。在6.0之前相关的系统表是QUERY_REPO,从6.0开始它是
QUERY_REQUESTS
。假设您使用的是 6.0 或更高版本,
QUERY_REQUESTS.REQUEST_DURATION_MS
将为您提供以毫秒为单位的查询持续时间。如何使用
QUERY_REQUESTS
的示例:您可能还对
QUERY_PROFILES.QUERY_DURATION_US
和RESOURCE_ACQUISITIONS.DURATION_MS
列感兴趣。如果您还不熟悉,这里是这些表的简短描述:RESOURCE_ACQUISITIONS
- 保留有关资源(内存、打开的文件句柄、线程)的信息,这些资源是由每个资源池的每个运行请求获取的。系统。QUERY_PROFILES
- 提供有关已运行的查询的信息。Regarding the other part of your question:
Vertica can log a history of all queries executed on the cluster which is another source of query time. Before 6.0 the relevant system table was QUERY_REPO, starting with 6.0 it is
QUERY_REQUESTS
.Assuming you're on 6.0 or higher,
QUERY_REQUESTS.REQUEST_DURATION_MS
will give you the query duration in milliseconds.Example of how you might use
QUERY_REQUESTS
:The
QUERY_PROFILES.QUERY_DURATION_US
andRESOURCE_ACQUISITIONS.DURATION_MS
columns may also be of interest to you. Here are the short descriptions of those tables in case you're not already familiar:RESOURCE_ACQUISITIONS
- Retains information about resources (memory, open file handles, threads) acquired by each running request for each resource pool in the system.QUERY_PROFILES
- Provides information about queries that have run.我不确定如何在 vsql 中启用它或者是否可能。但您可以从脚本中获取该信息。
这是伪代码(我曾经使用perl):
或者将时间放入变量中并进行一些减法。
另一种选择是使用 Toad 等工具连接到 Vertica,而不是使用
vsql
。I'm not sure how to enable that in vsql or if that's possible. But you could get that information from a script.
Here's the psuedocode (I used to use perl):
Or put time into a variable and do some subtraction.
The other option is to use some tool like Toad to connect to Vertica instead of using
vsql
.