我正在使用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()?
謝謝