You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Razi Khaja <ra...@gmail.com> on 2017/11/03 14:29:32 UTC

Questions about maintaining secondary indexes.

Hello,

I have a few questions about secondary indexes.

----
1st Question:

Quoting this FAQ: https://wiki.apache.org/cassandra/SecondaryIndexes

Q: When you write a new row, when/how does the index get updated? What I
> would like to know is the atomicity of the operation--is the "index write"
> part of the "row write"?
>
> A: The row and index updates are one, atomic operation.


Suppose that I have created a table and a secondary index. Since a delete
is considered a write, if I delete rows in my table, is it correct that the
index would automatically be changed as well?

-----
2nd Question:

Quoting this documentation:
https://docs.datastax.com/en/cql/3.1/cql/ddl/ddl_primary_index_c.html

The index indexes column values in a separate, hidden table from the one
> that contains the values being indexed.


Wondering, under what situations is it necessary to run *nodetool
rebuild_index*?

Does it need to be run in order to evict tombstones in the hidden table? I
would think that if the secondary index is stored in a Cassandra table,
whether hidden or not, that *repair* should handle evicting tombstones. My
guess is that *rebuild_index* like *repair* needs to be run in the event of
prolonged network outages or downed nodes, but should be run regularly, but
this is confusing, since if *repair *were to write data to a node, wouldn't
the "*row and index updates occur in one, atomic operation*".  I need
clarification on the reasons to run *rebuild_index*.

Thank you and best regards,
-Razi