我有这个代码
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/