!- Zendesk tag -->
You're viewing documentation for an unstable version of ScyllaDB Open Source. Switch to the latest stable version.
Audience: ScyllaDB users
Trying to count all rows in a table using
SELECT COUNT(1) FROM ks.table;
may fail with the ReadTimeout error.
COUNT() runs a full-scan query on all nodes, which might take a long time to finish. As a result, the count time may be greater than the ScyllaDB query timeout. One way to prevent that issue in Scylla 4.4 or later is to increase the timeout for the query using the USING TIMEOUT directive, for example:
SELECT COUNT(1) FROM ks.table USING TIMEOUT 120s;
You can also get an estimation of the number of partitions (not rows) with nodetool tablestats.
ScyllaDB 5.1 includes improvements to speed up the execution of SELECT COUNT(*) queries. To increase the count speed, we recommend upgrading to ScyllaDB 5.1 or later.