Tuesday, March 16, 2021

Identifying slow queries in Datastax Enterprise (DSE)

1) By default in DSE the slow query logging is enabled but won't be saving this infromation in to Database(DB)

Configuration in dse.yaml 

cql_slow_log_options:

    enabled: true

    threshold: 200.0

    minimum_samples: 100

    ttl_seconds: 259200

    skip_writing_to_db: true

    num_slowest_queries: 5


Here, 

If parameter 'enabled' is 'true' then slow query logging is enabled.

The parameter 'threshold' in milliseconds is for duration of a query to be considered as slowest.

The parameter 'minimum_samples' implies collecting 1 in 100 samples to observe.

The parameter 'ttl_seconds' is how log to retain the slow query log information.

The parameter 'skip_writing_to_db' implies whether to write the information to DB or not.

The parameter 'num_slowest_queries' is how many to store.


2) Command line utility to make on the fly changes with out restarting dse process.

a) Disable collecting slow query information

dsetool perf cqlslowlog disable

b) Keep slow queries in memory only.

dsetool perf cqlslowlog skip_writing_to_db

c) Write slow query to DB

dsetool perf cqlslowlog write_to_db

d) Set the number of slow queries to keep in memory 

dsetool perf cqlslowlog set_num_slowest_queries 5

e) Getting most recent slow queries

dsetool perf cqlslowlog recent_slowest_queries

f) If you save slow queries to DB, then query by 

$ cqlsh 

cqlsh> USE dse_perf; 

cqlsh:dse_perf> SELECT * FROM node_slow_log;


***