A faster way to count the total number of columns in a row of cassandra with a hector

I want to calculate the total number of columns for a Cassandra row using the Hector client. I am currently doing this with CountQuery , but to me it seems very slow. Also for a row, for only 60 thousand columns, it takes about 2 seconds. Currently my code is as follows:

 QueryResult<Integer> qr = HFactory.createCountQuery(ksp, se, se). setColumnFamily("ColumnFamily1"). setKey("RowKey"). setRange(null, null, 1000000000).execute(); 

PS: I need to set the range to such a large number, otherwise it will consider me the maximum. to the number that I provided in the range.

Any ideas how I can improve this?

+6
source share
1 answer

Counting columns in Kassandra is inherently slow. Cassandra must iterate over the entire string to return the score.

You probably want to denormalize the bill. You can use the counter column that you update every time you insert.

+8
source

Source: https://habr.com/ru/post/904992/


All Articles