【问题标题】:Cannot execute this query as it might involve data filtering无法执行此查询,因为它可能涉及数据过滤
【发布时间】:2018-07-20 06:44:12
【问题描述】:

Spring 在执行删除请求时返回以下错误:

com.datastax.driver.core.exceptions.InvalidQueryException:无法执行此查询,因为它可能涉及数据过滤,因此可能具有不可预测的性能。如果您想在性能不可预测的情况下执行此查询,请使用 ALLOW FILTERING

我的表格如下所示:

CREATE TABLE askonym.trusted_keys (
    trustkey uuid PRIMARY KEY,
    entityid uuid
)

我的弹簧实体:

@Data
@AllArgsConstructor
@NoArgsConstructor
@Table("trusted_keys")
public class TrustKey {

    @PrimaryKeyColumn(value = "trustkey", type = PrimaryKeyType.PARTITIONED, ordinal = 1)
    private UUID trustKey;

    private UUID entityId;
}

我的删除请求:

getCassandraOperations().delete(key);

这个 getCassandraOperations() 是一个 org.springframework.data.cassandra.core.CassandraOperations 对象。

感谢每一个贡献!

【问题讨论】:

  • 专业提示:Spring Data Cassandra 使用 Cassandra 在幕后做了一些奇怪且不正常的事情。构建成功应用的最佳机会是使用 DataStax Java 驱动程序。
  • 您可以查看此文档以获取有关此docs.datastax.com/en/cql/3.3/cql/cql_reference/cqlSelect.html的更多信息
  • 只是为了添加@Aaron 的建议 - 您可以使用 Java 驱动程序中的 Object Mapper:docs.datastax.com/en/developer/java-driver/3.4/manual/…
  • 只是想知道专业提示......代码是开源的,你在后台是什么意思?
  • 看看吧。我见过他们使用SELECT COUNT(*) unbound 来获取表中的所有行以实现分页的方法。此外,他们采用多行的 INSERT 方法本质上使用 BATCH,如果您一次插入很多行,这很糟糕。

标签: java spring cassandra


【解决方案1】:

我现在使用 spring 包含的方法来自动创建所有数据库。这第一次解决了这个问题。

【讨论】:

  • 你是怎么做到的?请您提供一些代码好吗?
  • 只需更新您的 application.properties 并添加字段 spring.data.cassandra.keyspace-name=ticket_system 和 spring.data.cassandra.schema-action=recreate_drop_unused
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-10-15
  • 1970-01-01
  • 1970-01-01
  • 2016-07-26
  • 1970-01-01
  • 1970-01-01
  • 2017-07-22
相关资源
最近更新 更多