question

Gangadhara M.B avatar image
Gangadhara M.B asked Erick Ramirez edited

How do I collect slow queries in Apache Cassandra 3.11.6?

How to "collect slow queries" in apache cassandra 3.1.6 .Requirement is to find any queries taking longer than say 02 secs , after identifying long running queries we can concentrate on fine tuning at query level or at table level or can consider to change the table design itself

cassandraperformance
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered Erick Ramirez commented

Slow query logging was added as a feature in Apache Cassandra 3.10 (CASSANDRA-12403). It is enabled by default in cassandra.yaml and queries which take longer than 500ms are logged at DEBUG level:

slow_query_log_timeout_in_ms: 500

Set it to 2000 to only log queries which took longer than 2 seconds. Note that changes to the configuration requires a restart.

If a query is detected to be slow, the following entry will be logged in the system.log at INFO level (at most once every 5 minutes):

INFO  [ScheduledTasks:1] 2020-06-06 20:35:50,209 NoSpamLogger.java:91 - Some operations were slow, details available at debug level (debug.log)

The slow queries are logged in the debug.log every 5 seconds:

DEBUG [ScheduledTasks:1] 2020-06-06 20:35:50,211 MonitoringTask.java:173 - 3 operations were slow in the last 4998 msecs:
<SELECT * FROM community.users LIMIT 5000>, time 3026 msec - slow timeout 500 msec
<SELECT * FROM community.users WHERE user = "jack" LIMIT 5000>, was slow 2 times: avg/min/max 330/825/835 msec - slow timeout 500 msec
<SELECT * FROM community.users WHERE token(id) > 0 LIMIT 5000>, time 1449 msec - slow timeout 500 msec

CQL queries which were repeatedly detected within a 5-second window get aggregated and only logged once like the second example query above (was slow 2 times). Cheers!

2 comments Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Gangadhara M.B avatar image Gangadhara M.B commented ·

thanks lot for quick reply with detailed explanation

0 Likes 0 ·
Erick Ramirez avatar image Erick Ramirez ♦♦ Gangadhara M.B commented ·

Not a problem. Cheers!

P.S. I've converted your post to a comment since it's not an "answer". :)

0 Likes 0 ·