Reputation: 1712
I'm not completely shure I get the concepts of prepared statements right, but according to the python driver docs a prepared statement is "A statement that has been prepared against at least one Cassandra node"
. To me that reads that somewhere in the cluster there is information on what queries have already been prepared.The documentation furthermore states that "A PreparedStatement should be prepared only once. Re-preparing a statement may affect performance (as the operation requires a network roundtrip)."
.
If I get the concept right it would be beneficial to receive already prepared statements from the cluster instead of repeatedly regenerating them(1). Is there a way to do so? And if yes, how do I only receive statements I am interested in?
(1)I'm not talking about the scope of one instance of a programm, but multiple instances without shared memory executing the same queries.
Upvotes: 1
Views: 311
Reputation: 7365
You are correct: each node in the cluster caches prepared statements. However, there is no mechanism for obtaining already-prepared statements in the client. There are a number of reasons for this that I won't expound upon here.
Your application your prepare a statement once and keep it around for the lifetime of the cluster/session. The drivers handle things like preparing the statement on all nodes, and re-preparing on nodes that lose them due to cache eviction or restarts.
Upvotes: 1