【发布时间】:2019-03-16 09:33:20
【问题描述】:
在我的 cassandra 数据库中搜索具有特定 PID 的记录时,我需要使用 where 子句
id = uuid
pid= Property Id (text)
created_at = timestamp
我需要查找特定属性 ID 的前 5 条记录。所以我的创建表是这样的。
CREATE TABLE property_tax (
id uuid,
state text,
area text,
balance_type text,
created_at timestamp,
created_by text,
last_paid_at timestamp,
max_tax float,
min_tax float,
pid text,
prev_balance float,
prev_interest float,
property_type text,
tax_cess float,
tax_year timestamp,
total_paid float,
total_paid_cess float,
total_paid_tax float,
PRIMARY KEY (pid,created_at,id)
);
我的查询看起来像这样
select * from property_tax where pid = 'property1' ORDER BY created_at DESC LIMIT 5;
它按照我的要求工作,但我的方法是否正确?还是需要改变。将来是否会出现任何性能问题。我正在查看 5 亿条记录并且还在增长。
新编辑:
我添加了两列 1.state 2.area 该州将有多个地区
属性 ID(pid) 会有多条记录,不超过 100 条记录
So, I need to query TABLE property_tax for below
1. Find all the pid
2. find all the pid in the area
3. find all the pid in the state
4. find Limit 5 for pid (ORDER_BY created_at DESC)
非常感谢 沙市
【问题讨论】:
-
单个 pid 分区内有 5 亿个 pid 或 id?
-
500 万个 pid,每个 pid 下有 100 个 Id。
标签: cassandra nosql datastax cql