jsi
jsi

Reputation: 11

Multiple statements in single transaction with phantom

Is it possible to execute multiple queries in one transaction with phantom? I don't mean batch inserts/updates, but executing one query based on results of another.
Didn't find anything on the matter in the docs. Have a guess, though, it's meant like that, due to the specifics of Cassandra and NoSQL.

Upvotes: 0

Views: 279

Answers (2)

flavian
flavian

Reputation: 28511

Answering as the project lead on phantom.

I think you are on the money with batches. They have some restrictions, and they are not 100% what you want, but it's certainly possible to achieve some of this.

Combines multiple data modification language (DML) statements (such as INSERT, UPDATE, and DELETE) to achieve atomicity and isolation when targeting a single partition, or only atomicity when targeting multiple partitions.

A batch applies all DML statements within a single partition before the data is available, ensuring atomicity and isolation. A well-constructed batch targeting a single partition can reduce client-server traffic and more efficiently update a table with a single row mutation.

In the strictest sense, you cannot depend on the result of a previous query in an atomic way, but I would try if at all possible to replicate the functionality within a batch, as it's likely going to be your only option of achieving a similar SQL like guarantee.

Upvotes: 0

jsi
jsi

Reputation: 11

As @Laxmikant noted, and I later discovered, this not possible for Cassandra because of the eventual consistency. This is a consistency - availability - partition tolerance tradeoff.

Upvotes: 0

Related Questions