cassandra - 数据税 : Re-preparing already prepared query warning

标签 cassandra datastax-java-driver cql3

我有这个代码

    UUID notUuid = UUIDs.timeBased();        
    PreparedStatement   pstmt           = cqlSession.prepare("INSERT INTO mytable(userId, notifId, notification, time, read, deleted) VALUES(?, ?, ?, ?, ?, ?)");
    BoundStatement      boundStatement  = new BoundStatement(pstmt);
    cqlSession.execute(boundStatement.bind(userId, notUuid, notfMsg, System.currentTimeMillis(), MigificConstants.UNREAD, "false"));

当我运行此代码时,它会在日志中显示

Re-preparing already prepared query INSERT INTO mytable(userId, notifId, notification, time, read, deleted) VALUES(?, ?, ?, ?, ?, ?). Please note that preparing the same query more than once is generally an anti-pattern and will likely affect performance. Consider preparing the statement only once.

最佳答案

这段代码是被多次调用的方法的一部分吗?

每个集群实例只需准备一次语句,您应该在应用程序的某些初始化部分中执行此操作。

关于cassandra - 数据税 : Re-preparing already prepared query warning,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26922538/

相关文章:

java - 作为 CQL 的简单语句

java - Spring未初始化bean

go - 与 Spark 集成的最佳方式

Java:如何创建 Class<T> 参数?

java - 如果结果集很大,则使用 Cassandra 和 DataStax Java 驱动程序时会出现 NoHostAvailableException

java - 使用java模拟多个用户连接到Cassandra

cassandra - 从 CQL 导出数据时出现 RPC 超时错误

适用于大数据的 Cassandra 复制

java - 从 Java 应用程序将数据导入 Cassandra 2 的最快方法是什么?

使用集合类型的 Cassandra 二级索引