As far as I understand there are no secondary indices with multiple columns, only single columns.
So how do I solve the index problem I'm having? This is my table:
CREATE TABLE IF NOT EXISTS logstv.messages ( timestamp timestamp, channelid bigint, userid bigint, message text, PRIMARY KEY ((channelid, timestamp), userid) ) WITH CLUSTERING ORDER BY (timestamp DESC); But this is the error currently: Missing CLUSTERING ORDER for column userid
I want these things:
SELECT WHERE with channelid, userid, timestamp with an order by timestamp and limit
SELECT WHERE with channelid, timestamp with an order by timestamp and limit
Is this possible?
The only option I currently see is setting timestamp as the primary key and then sorting through the rest in my software, which seems very expensive. Or having 2 tables for my data which i want to very much avoid because the data will grow very fast and get big.
Example queries:
SELECT message, timestamp FROM logstv.messages WHERE userid = ? AND channelid = ? AND timestamp >= ? AND timestamp <= ? ORDER BY timestamp DESC LIMIT 100; SELECT message, timestamp FROM logstv.messages WHERE channelid = ? AND timestamp >= ? AND timestamp <= ? ORDER BY timestamp DESC LIMIT 100;