gpt4 book ai didi

java - Cassandra Query执行时间分析

转载 作者:塔克拉玛干 更新时间:2023-11-01 22:42:22 26 4
gpt4 key购买 nike

我是 Cassandra CQL 的新手,我想获取 Cassandra 查询执行时间。我可以通过将当前时间存储在变量中来在 CQL shell 中执行此操作,执行查询,然后将当前时间存储在另一个变量中,并通过取两个变量的差值来计算实际执行时间。谁能指导我。

最佳答案

在 cqlsh 中,您最好的选择可能是使用跟踪(为简洁起见缩短了输出):

aploetz@cqlsh:stackoverflow> tracing on;
Now Tracing is enabled
aploetz@cqlsh:stackoverflow> SELECT * FROM sujata WHERE id=2;

id | roll_number | age
----+-------------+-----
2 | 10 | 26
2 | 20 | 26

(2 rows)

Tracing session: 35072590-99fb-11e5-beaa-8b496c707234

activity | timestamp | source | source_elapsed
-------------------------------------------------------------------------------------------------+----------------------------+-----------+----------------
Execute CQL3 query | 2015-12-03 14:19:51.027000 | 127.0.0.1 | 0
Parsing SELECT * FROM sujata WHERE id=2; [SharedPool-Worker-1] | 2015-12-03 14:19:51.034000 | 127.0.0.1 | 12378
Preparing statement [SharedPool-Worker-1] | 2015-12-03 14:19:51.035000 | 127.0.0.1 | 13415
Executing single-partition query on roles [SharedPool-Worker-2] | 2015-12-03 14:19:51.036000 | 127.0.0.1 | 14052
.................................................
Read 2 live and 0 tombstone cells [SharedPool-Worker-2] | 2015-12-03 14:19:51.054001 | 127.0.0.1 | 32768
Request complete | 2015-12-03 14:19:51.063069 | 127.0.0.1 | 36069

编辑:

can I store this tracing log report to some file...?

是的,你可以。如果我要从 Linux 命令行运行上面的跟踪,并将其输出到一个文件,我将首先创建一个文件来保存我的 cqlsh 命令:

aploetz@dockingBay94:~/cql$ cat traceSujata.cql 

use stackoverflow;
tracing on;
SELECT * FROM sujata WHERE id=2;

然后,我会在 cqlsh 上使用 -f 标志从该文件运行命令,然后将输出重定向到另一个文本文件。

aploetz@dockingBay94:~/cql$ cqlsh -f traceSujata.cql > queryTrace_20151204.txt

现在您可以在闲暇时细读查询跟踪文件!

关于java - Cassandra Query执行时间分析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34075261/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com