Have a table with about 20 million rows in Cassandra.
The table is ordered by a primary_key
column, which is a string. We are using 'ByteOrderedPartitioner', so the rows are ordered by the primary_key
and not a hash of the primary_key
column.
What is a good way to get the very last record in the table?
Thanks so much!
If for "very last record" you mean the one ordered as last I don't think you can do it like a "GET", you have to scan rows. The best you can do, afaik, is select a good range to scan (good start key) according to your primary key.
From datastax docs:
"Using the ordered partitioner allows ordered scans by primary key. This means you can scan rows as though you were moving a cursor through a traditional index. For example, if your application has user names as the row key, you can scan rows for users whose names fall between Jake and Joe. This type of query is not possible using randomly partitioned row keys because the keys are stored in the order of their MD5 hash (not sequentially)."
If you find better solution let me know.
Regards, Carlo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With