I have this schema

CREATE TABLE IF NOT EXISTS "inbox" (
  "groupId"               BIGINT,
  "createTime"           TIMEUUID,
  "mailId"               BIGINT,
  "body"                 TEXT,
  PRIMARY KEY ("groupId","createTime","mailId")
)WITH CLUSTERING ORDER BY ("createTime" DESC);


This table is frequency updated (250K per second) and each between 10-1000
new record is inserted in each "groupId" per day

The problem is I want to count `Unread mails` that based on a TIMEUUID
compare, that means I want to count

SELECT count(1) FROM inbox WHERE "groupId"=123456 AND "createTime">
specificTimeUUID

But this query is inefficiend and slow sometimes


If we have <1000 unread message there is no problem but when we have 50K+
unread message we have huge issue


What is the best solution for the problem?

Reply via email to