Prepared statements and tombstones

757 views
Skip to first unread message

Philip Luckhurst

unread,
May 19, 2014, 9:45:25 AM5/19/14
to java-dri...@lists.datastax.com
We have a CQL table with approx 20 columns and are using a prepared statement to insert records. The problem is that we do not always have a value to bind for each column so the inserts work but generate a tombstone entry for each column that doesn't have a value; this can result in a large number of tombstones. We could avoid the tombstones by building the inserts with QueryBuilder but then we lose the performance benefit of using prepared statements. Is there anyway to use prepared statements where you don't have a value for each column that doesn't create tombstones?

We're using Cassandra 2.0.7 and Java Driver 2.0.2.

Thanks
Philip

Alex Popescu

unread,
May 19, 2014, 4:32:16 PM5/19/14
to java-dri...@lists.datastax.com
On Mon, May 19, 2014 at 6:45 AM, Philip Luckhurst <luck...@gmail.com> wrote:
We have a CQL table with approx 20 columns and are using a prepared statement to insert records. The problem is that we do not always have a value to bind for each column so the inserts work but generate a tombstone entry for each column that doesn't have a value; this can result in a large number of tombstones. We could avoid the tombstones by building the inserts with QueryBuilder but then we lose the performance benefit of using prepared statements. Is there anyway to use prepared statements where you don't have a value for each column that doesn't create tombstones?

We're using Cassandra 2.0.7 and Java Driver 2.0.2.


If you don't have too many combinations you could be able to have prepared statements for all of them... 
 
Thanks
Philip

To unsubscribe from this group and stop receiving emails from it, send an email to java-driver-us...@lists.datastax.com.



--

:- a)


Alex Popescu
Sen. Product Manager @ DataStax
@al3xandru

Philip Luckhurst

unread,
May 19, 2014, 5:08:36 PM5/19/14
to java-dri...@lists.datastax.com
Thanks Alex, we already do that for another table that only has a couple of possible combinations but we were hoping there was a better way :-)

Phil

Drew Kutcharian

unread,
May 21, 2014, 1:18:07 AM5/21/14
to java-dri...@lists.datastax.com
So what’s the reason that PreparedStatements create tombstones for null values? Is there a way to circumvent it besides omitting the column name in the insert statement?

oded peer

unread,
May 21, 2014, 2:10:14 AM5/21/14
to java-dri...@lists.datastax.com
+1

I am facing the same issue. The number of combinations is very large and I resorted to using QueryBuilder.
Message has been deleted

Sylvain Lebresne

unread,
May 21, 2014, 10:35:03 AM5/21/14
to java-dri...@lists.datastax.com
On Wed, May 21, 2014 at 7:18 AM, Drew Kutcharian <dr...@venarc.com> wrote:
So what’s the reason that PreparedStatements create tombstones for null values?

It's really Cassandra that creates tombstones for null values, and that's because it's the semantic. If you explicitly set a column value to null, this is akin to removing it. 
 
Is there a way to circumvent it besides omitting the column name in the insert statement?

There isn't.

--
Sylvain

Drew Kutcharian

unread,
May 21, 2014, 12:54:30 PM5/21/14
to java-dri...@lists.datastax.com
I understand that Cassandra tombstones for null values and I’m not asking to change the semantics of Cassandra. What I’m asking for is that would it make sense to improve prepared statements to either have a flag that says ignore null columns or even better have an “UNSET” value which makes Cassandra skip the column and not tombstone it? Basically “null” value currently means delete, but we don’t have anything that means “ignore” when it comes to prepared statements (besides creating a new prepared statement without the ignored column).

Yariv Amar

unread,
May 25, 2014, 5:50:21 PM5/25/14
to java-dri...@lists.datastax.com
I vote for that kind of fix :), i also had to use QueryBuilder instead of PreparedStatment because of the huge amount of tombstones that PS created.

Yariv Amar

Sylvain Lebresne

unread,
May 26, 2014, 3:49:02 AM5/26/14
to java-dri...@lists.datastax.com
And i'm saying that this is not in the hand of the java driver. There is nothing the driver can do that you can't in that respect. What you suggest would have to be added to Cassandra one way or the other. So you'll want to open a ticket on Cassandra's JIRA for instance.

--
Sylvain

Drew Kutcharian

unread,
May 26, 2014, 4:01:56 PM5/26/14
to java-dri...@lists.datastax.com
Hey Guys,

I just created this JIRA https://issues.apache.org/jira/browse/CASSANDRA-7304 . Please review and make sure I haven’t left anything out and vote ;)

- Drew

J Jayaprakash

unread,
Jul 15, 2019, 12:29:45 PM7/15/19
to DataStax Java Driver for Apache Cassandra User Mailing List, dr...@venarc.com
Hey Guys,

Is this fixes? I am using c# driver. How can I avoid tombstone issues for insert statement?
Please let me know.
Thanks,
Jay
- Drew

Thanks
Philip

To unsubscribe from this group and stop receiving emails from it, send an email to java-dri...@lists.datastax.com.



--

:- a)


Alex Popescu
Sen. Product Manager @ DataStax
@al3xandru

To unsubscribe from this group and stop receiving emails from it, send an email to java-dri...@lists.datastax.com.


To unsubscribe from this group and stop receiving emails from it, send an email to java-dri...@lists.datastax.com.


To unsubscribe from this group and stop receiving emails from it, send an email to java-dri...@lists.datastax.com.


To unsubscribe from this group and stop receiving emails from it, send an email to java-dri...@lists.datastax.com.


To unsubscribe from this group and stop receiving emails from it, send an email to java-dri...@lists.datastax.com.

Olivier Michallat

unread,
Jul 15, 2019, 3:02:27 PM7/15/19
to java-dri...@lists.datastax.com
Hi,

Yes, the C# driver supports unset values since 2.6.0 (CSHARP-304).

PS: this is the Java driver mailing list. The csharp-driver-user mailing list is a better place for C#-related questions.

--

Olivier Michallat

Driver & tools engineer, DataStax



--
To unsubscribe from this group and stop receiving emails from it, send an email to java-driver-us...@lists.datastax.com.

J Jayaprakash

unread,
Jul 15, 2019, 3:22:32 PM7/15/19
to java-dri...@lists.datastax.com
Thanks,
I have posted my questions in C# mailing list.
Reply all
Reply to author
Forward
0 new messages