I have a racesByID table. I also need to find the races by year. What are the pros and cons of using a secondary index on year column over creating a racesByYear table?
- 3how many races are there in a year? Secondary indexes are almost never better than creating another table. Unless you have ~50 races a year and a small cluster the racesByYear table will be strictly better.Chris Lohfink– Chris Lohfink2019-11-04 01:14:07 +00:00Commented Nov 4, 2019 at 1:14
Add a comment |
1 Answer
It depends on how many race you have per year, Secondary indexes doesn't perform well if you have low or very high carnality, you will have performance issues in those case. for details check this link : https://docs.datastax.com/en/cql/3.3/cql/cql_using/useWhenIndex.html#useWhenIndex__when-no-index
In most cases separates tables will perform better, the cons is that you have to manage the consistency and keep table in sync
I hope this help.