Cassandra: How to perform upsert in lightweight transaction
<p>In Cassandra, I want to add a row, and if it already exists, only update it if the existing date is earlier than the new date. This is how it's done:</p>

<pre><code>INSERT INTO tbl (...) VALUES (...) IF NOT EXISTS;
</code></pre>

<p>If the first query is not applied, I'm running this second one:</p>

<pre><code>UPDATE tbl SET ...
WHERE ...
IF date &lt;= ?;
</code></pre>

<p>Is it possible to merge the two queries into one? Maybe using the UPDATE as an upsert, while keeping the IF condition. We are having performance issues with these statements (timeouts) so this is the reason why I want to change it.</p>

<p>Regular updates (without IFs) also perform inserts if the row doesn't exist, but the lightweight transaction doesn't. Maybe it's possible to "trick" it into inserting as well.</p>

<p>Thanks!</p>