1
votes

I have the following DDL:

CREATE TABLE mykeyspace.mytable (
a text,
b text,
c text,
d text,
e text,
starttime timestamp,
endtime timestamp,
PRIMARY KEY ((a, b, c), d, e, starttime, endtime)
) WITH CLUSTERING ORDER BY (d ASC, e ASC, starttime ASC, endtime ASC)

and I only have the following SELECT/DELETE query:

SELECT */DELETE FROM mytable WHERE a = ? AND b = ? AND C = ? AND d = ?;

I just wonder if the column d can be included as part of the composite partition key so a row lookup is enough instead of a row lookup + clustering column lookup? In this case it will improve performance as well?

2
Isnt 'd' already a part of composite key?Atmesh Mishra
OK I will clarify that d is part of clustering column and not PARTITION key. I want to make it as part of the composite PARTITION key.user892960

2 Answers

1
votes

The column d include in the composite partition key will absolutely improve performance

  • Your data will distribute well among the cluster.
  • Your SELECT query will be faster, no clustering level filtering is required
  • Your DELETE query will mark that partition as markedForDeleteAt, instead of inserting range tombstone
0
votes

I feel that the more columns I have in the PARTITION KEY the better.

So my suggestion is to incluse as much columns as possible in the PARTITION KEY. It will improve SELECT query performances in general, and will avoid some tombstones problems as well (because you will delete at partition level, unless you recreate the partitions of course).