QueryOptionsSetPrepareOnAllHosts Method |
A statement is normally prepared in two steps: prepare the query on a single host in the cluster; if that succeeds, prepare on all other hosts.
This option controls whether step 2 is executed. It is enabled by default.
Namespace: Cassandra
public QueryOptions SetPrepareOnAllHosts( bool prepareOnAllHosts )
The reason why you might want to disable it is to optimize network usage if you have a large number of clients preparing the same set of statements at startup. If your load balancing policy distributes queries randomly, each client will pick a different host to prepare its statements, and on the whole each host has a good chance of having been hit by at least one client for each statement.
On the other hand, if that assumption turns out to be wrong and one host hasn't prepared a given statement, it needs to be re-prepared on the fly the first time it gets executed; this causes a performance penalty (one extra roundtrip to resend the query to prepare, and another to retry the execution).