简体   繁体   English

是否有一种高效的方法可以通过 crateDB 中的非分区列进行搜索?

[英]Is there a performant way to search by a non-partitioned column in crateDB?

My team and I have been using crate for one of our projects over the passed few years.在过去的几年里,我和我的团队一直在为我们的一个项目使用 crate。 We have a table with hundreds of millions of records and performance is key.我们有一个包含数亿条记录的表,性能是关键。

As we've developed more and more features on this project, we've ran into interesting problem.随着我们在这个项目上开发了越来越多的功能,我们遇到了有趣的问题。 We have a column on this table labeled 'persist_date' which is when the record actually got persisted into the table.我们在这个表上有一列标记为“persist_date”,这是记录实际持久化到表中的时间。 These dates may not always align and we could have a start_date of 2021-06-21 with a persist_date of 2021-10-14.这些日期可能并不总是一致的,我们可以将 start_date 设为 2021-06-21,并将persist_date 设为 2021-10-14。

All of our queries up this point have easily been able to add a partition against start_date.到目前为止,我们所有的查询都可以轻松地针对 start_date 添加一个分区。 Now we are encountering a problem which requires us to use a non-partitioned column (persist_date) to query against.现在我们遇到了一个问题,需要我们使用非分区列(persist_date)来查询。

As I understand it, crateDB is really performant but only when you query against 1 specific partition at a time.据我了解,crateDB 确实具有高性能,但仅当您一次查询 1 个特定分区时才有效。 My question now is how would I go about creating a partition for this other date column without duplicated my data?我现在的问题是如何在不复制数据的情况下为另一个日期列创建分区? Is there anything other than a partition that might help, like the way the table is clustered?除了分区之外还有什么可以帮助的,比如表的集群方式?

You could use both columns as partition values.您可以将两列都用作分区值。 eg例如

CREATE TABLE two_parted (a TEXT, b TEXT, val DOUBLE) PARTITIONED BY (a,b);

If either a or b are used in a selection, this would limit queries to shards that have either value.如果在选择中使用ab ,这会将查询限制为具有任一值的分片。 However this could lead to more shards, so you might want to partitions not on a daily, but weekly or monthly basis.然而,这可能会导致更多的分片,因此您可能希望不是每天分区,而是每周或每月分区。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM