Cassandra 中的 COUNT(*) 与 COUNT(1) 性能

COUNT(*) vs. COUNT(1) performance in Cassandra

根据 docs:

A SELECT expression using COUNT(*) returns the number of rows that matched the query. Alternatively, you can use COUNT(1) to get the same result.

使用后一种方法是否有任何性能优势(如在 RDBMS 中)?

COUNT(*) 和 COUNT(1) 没有区别。我认为 COUNT(1) 只是为了向后兼容一些旧东西。 selectCountClause returns 清空 RawSelector 列表,不管内容如何,​​但如果它是一个数字而不是 1 或不是 '*',它将抛出异常。

如果担心性能,一般情况下您可能希望避免计数。而是使用计数器或将计数保持在更高级别。