Datastax: Re-preparing already prepared query warning

a 夏天 提交于 2019-12-11 09:37:11

问题


I have this code

    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"));

when i run this code, in the log it shows

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.

回答1:


Is this code part of a method that is called multiple times?

Statements need only be prepared once per Cluster instance, you should do it in some initialization part of your application.



来源:https://stackoverflow.com/questions/26922538/datastax-re-preparing-already-prepared-query-warning

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!