--
Olivier Michallat
Driver & tools engineer, DataStax
To unsubscribe from this group and stop receiving emails from it, send an email to java-driver-us...@lists.datastax.com.
Thanks Olivier.
Most of the REST query calls would come from other applications to write/read to/from Cassandra which means most queries from an application would be same (same column families but different values).
Thanks
Ajay
On Feb 28, 2015, at 4:25 AM, Ajay <ajay....@gmail.com> wrote:5) Client fires another REST query "SELECT * from Test where Pk = val2";4) Assume we don't cache the PreparedStatement3) Executes the PreparedStatement by setting the values.2) REST service prepares a statement "SELECT * from Test where Pk = ?"1) Client fires a REST query "SELECT * from Test where Pk = val1";Lets take a scenario as below:Now the question is do we really need to cache the PreparedStatement in the client side?.Hi,My earlier question was whether it is safe to cache PreparedStatement (using Java driver) in the client side for which I got it confirmed by Olivier.
6) REST service prepares a statement "SELECT * from Test where Pk = ?"
7) Executes the PreparedStatement by setting the values.
On Feb 28, 2015, at 4:25 AM, Ajay <ajay....@gmail.com> wrote:
5) Client fires another REST query "SELECT * from Test where Pk = val2";4) Assume we don't cache the PreparedStatement3) Executes the PreparedStatement by setting the values.2) REST service prepares a statement "SELECT * from Test where Pk = ?"1) Client fires a REST query "SELECT * from Test where Pk = val1";Lets take a scenario as below:Now the question is do we really need to cache the PreparedStatement in the client side?.Hi,My earlier question was whether it is safe to cache PreparedStatement (using Java driver) in the client side for which I got it confirmed by Olivier.
6) REST service prepares a statement "SELECT * from Test where Pk = ?"
7) Executes the PreparedStatement by setting the values.In this case, is there any benefit of using the PreparedStatement?
From the Java driver code, the Session.prepare(query) doesn't check whether a similar query was prepared earlier or not. It directly call the server passing the query. The return from the server is a PreparedId. Do the server maintains a cache of Prepared queries or it still perform the all the steps to prepare a query if the client calls to prepare the same query more than once (using the same Session and Cluster instance which I think doesn't matter)?.
Joseph,
As per Tyler, the client need not handle stale prepared statements as cassandra and java-driver handle it automatically behind the scene.
But I think it still make sense to have an API in the session to load the prepared statement given prepareId for scenarios as below:
1) When we have webservices using java-driver, the requests can be handled by different JVMs (different Tomcat instance in our case), the 1st JVM will prepare the statement and the subsequent requests might be handled by different JVM and it will not find it in its in memory cache and so have to prepare the statment again.
But I remember it is mentioned somewhere that prepared statement is tied upto the session which prepares it. So not sure whether it can be used from a different session connected to the same cluster.
2) Secondly as I mentioned earlier, it helps to have a LRU based cache for prepared statements and if not found in cache, can be reloaded.
Thanks
Ajay