Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-5527

Deletion by Secondary Key

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Low
    • Resolution: Later
    • None
    • Legacy/CQL
    • None

    Description

      Given Cassandra's popularity as a time ordered list store, the inability to do deletes by anything other than the primary key without re-implementing tombstones in the application is a bit of an achilles heel for many use cases. It's a data modeling problem that seems to come up quite often, and given that we now have the CQL3 abstraction layer sitting on top of the storage engine, I think there's an opportunity to take this burden off of the application layer. I've spent several weeks thinking about this problem within the context of Cassandra, and I think I've come up with a reasonable proposal.

      It would involve addition of a secondary key facility to CQL3 tables:

      CREATE TABLE timeline (
      timeline_id uuid,
      entry_id timeuuid,
      entry_key blob,
      entry_payload blob,
      PRIMARY KEY (timeline_id, entry_id),
      KEY (timeline_id, entry_key)
      );

      Secondary keys would be required to share the same partition key with the primary key. They would be included to support deletion by secondary key operations:

      DELETE FROM timeline WHERE timeline_id = <X> and entry_key = <Y>;

      Underneath, the storage engine row would contain additional secondary key tombstones. Secondary key deletion would be read-free, requiring a single tombstone write. The cost of reads would necessarily go up. Queries would need to be modified to perform an additional step to find any matching secondary key tombstones and perform the regular convergence process. The secondary key tombstones should be cleaned up by the regular tombstone GC process.

      While I didn't want to complicate this idea too much, it might be also worth having a discussion around supporting secondary key queries as well, or at least making the schema compatible with potential future support (maybe rename KEY to DELETABLE KEY or something).

      Attachments

        Activity

          People

            Unassigned Unassigned
            rbranson Rick Branson
            Votes:
            5 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: