Cassandra Notes
When to use Cassandra
- CASSANDRA USE CASES: WHEN TO USE AND WHEN NOT TO USE CASSANDRA
- When to use Cassandra and when to steer clear
Upgrade to cassandra 4.x driver and spring-data-cassandra 2.3.+
CQL Tips
Using timestamp columns in cql where clause
Although Cassandra stores timestamp fractions using the .ffffff
format defined by the ISO 8601 standard. However, when interacting with the database (ie. INSERT, SELECT, …) you need to use the .fff
format like so:
cqlsh:test_keyspace> select * from timestamp_table ;
timestamp | other_field
---------------------------------+---------------
2018-05-18 03:08:58.246000+0000 | Other content
2018-05-18 03:08:58.000000+0000 | Other content
cqlsh:test_keyspace> select * from timestamp_table WHERE timestamp='2018-05-18 03:08:58.123+0000';
timestamp | other_field
---------------------------------+---------------
2018-05-18 03:08:58.123000+0000 | Other content
Data modeling
Limitations of Materialized View
- Known limitations of materialized views
- Cassandra Materialized Views ready for Production?
- Materialized Views marked experimental
- 14 Things To Do When Setting Up a New Cassandra Cluster
- It’s interesting that this article suggest disabling the materialized view when you setup a cassandra cluster. This might be a good advice!
Performances
- Cassandra performance: the most comprehensive overview you’ll ever see
- Materialized View Performance in Cassandra 3.x
- Avoid pitfalls in scaling your Cassandra cluster: lessons and remedies
- 7 mistakes when using Apache Cassandra
- Garbage Collection Tuning for Apache Cassandra
How to partition the data
Pagination
Tombstones
- Partition tombstones
- Row tombstones
- Range tombstones
- ComplexColumn tombstones
- Cell tombstones
- TTL tombstones
Reference: What are tombstones
Another very nice article describes issues around tombstones: https://thelastpickle.com/blog/2018/07/05/undetectable-tombstones-in-apache-cassandra.html
Allow filtering
In Query
Not using in
query across multiple partitions, as explained in this article
Batch
batch_size_warn_threshold_in_kb
If you use batch
with cassandra and saw warning in logs like this:
BatchStatement.java:287 - Batch of prepared statements for [test, test1] is of size 6419, exceeding specified threshold of 5120 by 1299.
Normally this is not really harmful as it’s just a warning. But you need to be careful about the usage of the batch
and should avoid sending large paylaod to batch
statement, especially when the statements are not against the same partition.
Comments