ablog

不器用で落着きのない技術者のメモ

cqlsh の TIMING ON コマンドで CQL の実行時間を計測する

cqlsh の TIMING ON コマンドで CQL の実行時間を計測する方法。
以下は cqlsh 6.8 から Amazon Keyspaces に接続して CQL 実行時間を計測した手順。

インストール

$ wget https://downloads.datastax.com/enterprise/cqlsh-6.8.40-bin.tar.gz
  • cqlsh 6.8 をインストールする
$ tar xfvz  cqlsh-6.8.40-bin.tar.gz 
$ cd cqlsh-6.8.40/bin
$ ./cqlsh --version
cqlsh 6.8.0

CQL の実行時間を計測する

  • cqlsh でログインする
$ cd cqlsh-6.8.40/bin
$ ./cqlsh vpce-********-********-ap-northeast-1a.cassandra.ap-northeast-1.vpce.amazonaws.com 9142 -u "keyspaces_user+1-at-123456789012" -p "Password" --ssl
  • 時間計測を有効化する
Connected to Amazon Keyspaces at vpce-********-********-ap-northeast-1a.cassandra.ap-northeast-1.vpce.amazonaws.com:9142.
[cqlsh 6.8.0 | Cassandra 3.11.2 | CQL spec 3.4.4 | Native protocol v4 | TLS]
Use HELP for help.
keyspaces_user+1-at-123456789012@cqlsh> TIMING ON;
Now Timing is enabled
keyspaces_user+1-at-123456789012@cqlsh>  SELECT * FROM tutorialkeyspace.tutorialtable;

 email            | age | name
------------------+-----+----------
 john@example.com |  21 |     John
   p@muramura.com |   1 |   murata
  yusuke@oyama.jp |  28 |    Oyama
  bob@example.com |  22 |      Bob
    chrai@co2.com |   1 |  shiotsu
 shohei@otani.com |  29 |    Otani
        e@co2.com |   1 |  shiotsu
   chrai@co22.com |   1 | shiotsu2

0.028483 seconds elapsed
(8 rows)
keyspaces_user+1-at-123456789012@cqlsh>  SELECT * FROM tutorialkeyspace.tutorialtable;

 email            | age | name
------------------+-----+----------
 john@example.com |  21 |     John
   p@muramura.com |   1 |   murata
  yusuke@oyama.jp |  28 |    Oyama
  bob@example.com |  22 |      Bob
    chrai@co2.com |   1 |  shiotsu
 shohei@otani.com |  29 |    Otani
        e@co2.com |   1 |  shiotsu
   chrai@co22.com |   1 | shiotsu2

0.007293 seconds elapsed
(8 rows)
keyspaces_user+1-at-123456789012@cqlsh>  SELECT * FROM tutorialkeyspace.tutorialtable;

 email            | age | name
------------------+-----+----------
 john@example.com |  21 |     John
   p@muramura.com |   1 |   murata
  yusuke@oyama.jp |  28 |    Oyama
  bob@example.com |  22 |      Bob
    chrai@co2.com |   1 |  shiotsu
 shohei@otani.com |  29 |    Otani
        e@co2.com |   1 |  shiotsu
   chrai@co22.com |   1 | shiotsu2

0.009202 seconds elapsed
(8 rows)

環境

$ cat /etc/system-release
Amazon Linux release 2023 (Amazon Linux)
$ uname -a
Linux ip-172-31-29-161.ap-northeast-1.compute.internal 6.1.52-71.125.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Sep 12 21:41:38 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
 pyenv versions
  system
  2.7.18
* 3.10.13 (set by /home/ec2-user/.pyenv/version)

参考

TIMING
Enables or disables simple request round-trip timing, as measured on the current CQL shell session.
To start, use TIMING ON. To stop, use TIMING OFF. If run without arguments, the command shows the current timing status.
Synopsis

TIMING [ ON | OFF ]
TIMING