我正在使用Cassandra作为我的项目,并且在写入期间我正面临超时问题,这个人在这篇文章中收到的同样是Cassandra cluster with bad insert performance and insert stability(目前我只用一个节点进行测试,Java驱动程序,Cassandra的最新版本)。该应用程序必须为每个用户每天(夜间)插入大量数据。我有一个休息控制器接受文件,然后处理它们并行到达Cassandra插入值。我必须为每个用户插入100万条记录,其中一个条目最多有8个值(时间不是那么重要,也可能需要10分钟)。根据Cassandra cluster with bad insert performance and insert stability提供的答案,我决定将executeAsync(),Semaphore和PreparedStatement添加到我的应用程序中,而以前我没有使用它们。Cassandra PreparedStatement vs普通插入
现在的问题是,使用变量键空间(每个用户一个)并且有必要更新数据库中的列表,我无法在初始化阶段初始化我的PreparedStatements,但我必须至少每次执行一次文件处理(一个文件包含10 + k条目),用户必须每天上传100个文件。出于这个原因,我得到这样的警告:
Re-preparing already prepared query INSERT INTO c2bdd9f7073dce28ed973238ac85b6e5d6162fce.sensorMonitoringLog (timestamp, sensorId, isLogging) 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.
我的问题是:这是一个很好的做法,使用PreparedStatement的这样或最好是使用正常的插有executeAsync()?
谢谢