I have a table in my Cassandra db.
CREATE TABLE table (
pk uuid,
status int,
location text,
type text,
id text,
updatedtimestamp timestamp,
PRIMARY KEY (pk)
);
CREATE INDEX tablelocation ON table (location);
CREATE INDEX tabletype ON table (type);
CREATE INDEX tableid ON table (id);
CREATE INDEX tableupdatedtimestamp ON table (updatedtimestamp);
The query I run is :
Select * from table
where location='A1'
and type='T1'
and status=001
and id='NA'
allow filtering;
Cassandra is taking more than 5 seconds to return 4000 records for this query.
I already have secondary index on all of these columns. As per the DBA, issue is in id='NA'
condition. There are too many rows where this condition is true.
But, that condition is there due to a business use case and can not be removed without some other mechanism to filter for the value.
I was thinking of creating a new index with all 4 columns inside. But, I am worried that it will hamper the write performance. The status column gets updated very frequently.
Is there anything we can do to tune performance of this query?