Getting the warning:
Re-preparing already prepared query is generally an anti-pattern and will likely affect performance. Consider preparing the statement only once.
I saw various similar questions like this Datastax: Re-preparing already prepared query warning but they didn't address re-assigning the keyspace or table that the query uses.
I could generally re-use the query , but it will require caching it per keyspace and table, and I don't want to manage state. Alternatively I could rebind the keyspace and table before executing the query (and then no need to recreate):
// the insertion query I am using
def insertQuery(keyspace: String, table: String): Insert = QueryBuilder.insertInto(keyspace, table)
.value("c1", QueryBuilder.bindMarker())
.value("c2")
.value(...)
.value("c_n")
Would need something like this:
QueryBuilder.insertInto(keyspace = ???BIND MARKER????, table = ???BIND MARKER???)