alllow filtering, data modeling in cql

后端 未结 1 775
隐瞒了意图╮
隐瞒了意图╮ 2021-02-08 06:17

I\'m currently using and researching about data modeling practices in cassandra. So far, I get that you need have a data modeling based on the queries executed. However, multipl

相关标签:
1条回答
  • 2021-02-08 06:45

    The ALLOW FILTERING warning is because Cassandra is internally skipping over data, rather than using an index and seeking. This is unpredictable because you don't know how much data Cassandra is going to skip over per row returned. You could be scanning through all your data to return zero rows, in the worst case. This is in contrast to operations without ALLOW FILTERING (apart from SELECT COUNT queries), where the data read through scales linearly with the amount of data returned.

    This is OK if you're returning most of the data, so the data skipped over doesn't cost very much. But if you were skipping over most of your data a lot of work will be wasted.

    The alternative is to include time in the first component of your primary key, in buckets. E.g. you could have day buckets and duplicate your queries for each day that contains data you need. This method guarantees that most of the data Cassandra reads over is data that you want. The problem is that all data for the bucket (e.g. day) needs to fit in one partition. You can fix this by sharding the partition somehow e.g. include some aspect of the uid within it.

    0 讨论(0)
提交回复
热议问题