With the below schema in Cassandra database:
CREATE TABLE IF NOT EXISTS stackoverflow_sorted_by_key_part_two (
key_part_one UUID,
key_part_two UUID,
idempotence_key int,
data TEXT,
PRIMARY KEY((key_part_one, idempotence_key), key_part_two)
);
(key_part_one, idempotence_key)
is a partition key & key_part_two
is clustering key.
With the above schema, records are sorted(as part of table indexing) order by key_part_two
in ascending order
But, for faster select query(with WHERE key_part_one == "some_uuid"
), we want the records sorted(as part of table indexing) order by key_part_one
.
Does the below schema enhance the select query performance?
CREATE TABLE IF NOT EXISTS stackoverflow_sorted_by_key_part_one (
key_part_one UUID,
key_part_two UUID,
idempotence_key int,
data TEXT,
PRIMARY KEY((key_part_one, idempotence_key), key_part_two)
)WITH CLUSTERING ORDER BY (key_part_one ASC);