incubator-cassandra-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Cohen <mcohe...@gmail.com>
Subject reuse PreparedStatements?
Date Sun, 04 Aug 2013 00:37:54 GMT
More specifically, is it "best practice" to reuse PreparedStatements,
rather than creating a new one  via session.prepare() on each database
access? Is there any performance benefit to this? I've glanced at the java
driver code and it does appear that if I were doing something like:

public List fetchSomething() {
    return this.session.execute(
      new BoundStatement(this.session.prepare("some cql").bind("some
vars")))
}

that the call to prepare() would in fact make a trip to the cluster
to....do something. I'm just asking if you should create the PS and hold on
to it, and keep reusing it for each actual query call, or if it matters, if
you can just create a new one each time.

Thanks,
Mike

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message